Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #31 from richtier/rename-package
Browse files Browse the repository at this point in the history
Rename package to alexa_client
  • Loading branch information
Richard Tier authored Jan 17, 2019
2 parents 7587a4d + e9fac75 commit 61b7276
Show file tree
Hide file tree
Showing 32 changed files with 55 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
omit =.venv/*,venv/*,tests/*,setup.py,avs_client/refreshtoken/serve.py,avs_client/avs_client/device.py,avs_client/demo/*
omit =.venv/*,venv/*,tests/*,setup.py,alexa_client/refreshtoken/serve.py,alexa_client/alexa_client/device.py,alexa_client/demo/*
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
clean:
-find . -type f -name "*.pyc" -delete
-find . -type d -name "__pycache__" -delete

build:
rm -rf build
rm -rf dist
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

## Installation
```sh
pip install avs_client
pip install alexa_client
```

or if you want to run the demos:

```sh
pip install avs_client[demo]
pip install alexa_client[demo]
```

## Usage

### File audio ###
```py
from avs_client import AlexaVoiceServiceClient
from alexa_client import AlexaClient

alexa_client = AlexaVoiceServiceClient(
alexa_client = AlexaClient(
client_id='my-client-id',
secret='my-secret',
refresh_token='my-refresh-token',
Expand All @@ -45,7 +45,7 @@ Now listen to `output_0.wav` and Alexa should tell you the time.
```py
import io

from avs_client import AlexaVoiceServiceClient
from alexa_client import AlexaClient
import pyaudio


Expand All @@ -62,7 +62,7 @@ stream = p.open(
stream_callback=callback,
)

alexa_client = AlexaVoiceServiceClient(
alexa_client = AlexaClient(
client_id='my-client-id',
secret='my-secret',
refresh_token='my-refresh-token',
Expand All @@ -83,7 +83,7 @@ finally:
p.terminate()
```

### Voice Request Lifecycle
### Multi-step requests

An Alexa command may relate to a previous command e.g,

Expand All @@ -97,7 +97,7 @@ An Alexa command may relate to a previous command e.g,
This can be achieved by passing the same dialog request ID to multiple `send_audio_file` calls:

```py
from avs_client.avs_client import helpers
from alexa_client.alexa_client import helpers

dialog_request_id = helpers.generate_unique_id()
directives_one = alexa_client.send_audio_file(audio_one, dialog_request_id=dialog_request_id)
Expand All @@ -109,8 +109,8 @@ directives_three = alexa_client.send_audio_file(audio_three, dialog_request_id=d
Run the streaming microphone audio demo to use this feature:

```sh
pip install avs_client[demo]
python -m avs_client.demo.streaming_microphone \
pip install alexa_client[demo]
python -m alexa_client.demo.streaming_microphone \
--client-id="{enter-client-id-here}" \
--client-secret="{enter-client-secret-here"} \
--refresh-token="{enter-refresh-token-here}"
Expand Down Expand Up @@ -144,7 +144,7 @@ Note what you entered for Product ID under Product Information, as this will be
Then run:

```sh
python -m avs_client.refreshtoken.serve \
python -m alexa_client.refreshtoken.serve \
--device-type-id="{enter-device-type-id-here}" \
--client-id="{enter-client-id-here}" \
--client-secret="{enter-client-secret-here}"
Expand Down
5 changes: 5 additions & 0 deletions alexa_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from alexa_client.alexa_client.client import AlexaClient

__all__ = [
'AlexaClient'
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import requests

from avs_client.avs_client import helpers
from avs_client.refreshtoken.helpers import AmazonOauth2RequestManager
from alexa_client.alexa_client import helpers
from alexa_client.refreshtoken.helpers import AmazonOauth2RequestManager


class AlexaVoiceServiceTokenAuthenticator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import warnings

from avs_client.avs_client import (
from alexa_client.alexa_client import (
authentication, connection, device, helpers, ping
)


class AlexaVoiceServiceClient:
class AlexaClient:
authentication_manager_class = (
authentication.AlexaVoiceServiceTokenAuthenticator
)
Expand Down Expand Up @@ -65,3 +65,12 @@ def ping(self):
return self.connection_manager.ping(
authentication_headers=headers,
)


class AlexaVoiceServiceClient(AlexaClient):
def __init__(self, *args, **kwargs):
warnings.warn(
'Deprecated. Use AlexaClient. Removing in v2.0.0.',
DeprecationWarning
)
super().__init__(*args, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from requests.exceptions import HTTPError
from hyper import HTTP20Connection

from avs_client.avs_client import helpers
from alexa_client.alexa_client import helpers


class ConnectionManager:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from pydub.playback import play
import pyaudio

from avs_client import AlexaVoiceServiceClient
from alexa_client import AlexaClient


def main(client_id, secret, refresh_token):
alexa_client = AlexaVoiceServiceClient(
alexa_client = AlexaClient(
client_id=client_id,
secret=secret,
refresh_token=refresh_token,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from urllib.parse import parse_qsl, urlparse

import requests
from avs_client.refreshtoken import helpers
from alexa_client.refreshtoken import helpers


class AmazonAlexaServiceLoginHandler(BaseHTTPRequestHandler):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# solve import error when calling this script from project root.
sys.path.append(os.getcwd())

from avs_client.refreshtoken import arg_parser, http_server, handlers # NOQA
from alexa_client.refreshtoken import arg_parser, http_server, handlers # NOQA


def serve_forever(address, port, client_id, client_secret, device_type_id):
Expand Down
5 changes: 0 additions & 5 deletions avs_client/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(
name='avs_client',
name='alexa_client',
version='1.3.0',
packages=find_packages(exclude=["tests.*", "tests"]),
url='https://github.com/richtier/alexa-voice-service-client',
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def fill(self):

class TestConnectionMixin:
"""
Mixin for use with avs_client.client.AlexaVoiceServiceClient that
Mixin for use with alexa_client.client.AlexaClient that
creates a test double that mocks out non-deterministic methods and external
services, and adds helper functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from requests.exceptions import HTTPError

from avs_client.avs_client.authentication import (
from alexa_client.alexa_client.authentication import (
AlexaVoiceServiceTokenAuthenticator
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

import pytest

from avs_client.avs_client.client import AlexaVoiceServiceClient
from alexa_client.alexa_client.client import AlexaClient


@pytest.fixture
def client():
class TestAlexaVoiceServiceClient(AlexaVoiceServiceClient):
class TestAlexaClient(AlexaClient):
authentication_manager_class = mock.Mock()
device_manager_class = mock.Mock()
connection_manager_class = mock.Mock()
ping_manager_class = mock.Mock()

client = TestAlexaVoiceServiceClient(
client = TestAlexaClient(
client_id='test_client_id',
secret='test_secret',
refresh_token='test_refresh_token',
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_client_send_audio_file(client):
assert client.ping_manager.update_ping_deadline.call_count == 1


@mock.patch('avs_client.avs_client.client.warnings.warn')
@mock.patch('alexa_client.alexa_client.client.warnings.warn')
def test_conditional_ping(mock_warn, client):

client.conditional_ping()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import pytest
from requests.exceptions import HTTPError

from avs_client.avs_client import connection
from tests.avs_client.helpers import parse_multipart, TestConnectionMixin
from tests.avs_client import fixtures
from alexa_client.alexa_client import connection
from tests.alexa_client.helpers import parse_multipart, TestConnectionMixin
from tests.alexa_client import fixtures


class TestConnectionManager(TestConnectionMixin, connection.ConnectionManager):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest
from requests_toolbelt import MultipartEncoder

from avs_client.avs_client import helpers
from tests.avs_client import fixtures
from alexa_client.alexa_client import helpers
from tests.alexa_client import fixtures


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from avs_client.avs_client import ping
from alexa_client.alexa_client import ping
from resettabletimer import FakeTimer


Expand Down
2 changes: 1 addition & 1 deletion tests/refreshtoken/test_arg_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from avs_client.refreshtoken import arg_parser
from alexa_client.refreshtoken import arg_parser


def test_parser_defaults():
Expand Down
2 changes: 1 addition & 1 deletion tests/refreshtoken/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
import requests

from avs_client.refreshtoken import handlers, helpers, http_server
from alexa_client.refreshtoken import handlers, helpers, http_server


@pytest.fixture(scope='session')
Expand Down
2 changes: 1 addition & 1 deletion tests/refreshtoken/test_http_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest.mock import call, Mock, patch

from avs_client.refreshtoken import http_server, handlers
from alexa_client.refreshtoken import http_server, handlers


@patch.object(handlers.AmazonAlexaServiceLoginHandler, '__init__',
Expand Down

0 comments on commit 61b7276

Please sign in to comment.