afsapi 0.2.7__tar.gz → 0.2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. afsapi-0.2.9/.github/workflows/python-publish.yml +43 -0
  2. {afsapi-0.2.7 → afsapi-0.2.9}/PKG-INFO +5 -3
  3. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/__init__.py +14 -2
  4. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/api.py +32 -2
  5. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/models.py +1 -0
  6. afsapi-0.2.9/afsapi/version.py +24 -0
  7. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/PKG-INFO +5 -3
  8. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/SOURCES.txt +0 -2
  9. {afsapi-0.2.7 → afsapi-0.2.9}/async_tests.py +16 -7
  10. {afsapi-0.2.7 → afsapi-0.2.9}/pyproject.toml +3 -5
  11. {afsapi-0.2.7 → afsapi-0.2.9}/setup.cfg +2 -1
  12. afsapi-0.2.7/.github/workflows/python-publish.yml +0 -34
  13. afsapi-0.2.7/.github/workflows/python.yml +0 -53
  14. afsapi-0.2.7/.github/workflows/yaml.yml +0 -20
  15. afsapi-0.2.7/afsapi/version.py +0 -5
  16. {afsapi-0.2.7 → afsapi-0.2.9}/.gitignore +0 -0
  17. {afsapi-0.2.7 → afsapi-0.2.9}/LICENSE +0 -0
  18. {afsapi-0.2.7 → afsapi-0.2.9}/README.md +0 -0
  19. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/exceptions.py +0 -0
  20. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/throttler.py +0 -0
  21. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi/utils.py +0 -0
  22. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/dependency_links.txt +0 -0
  23. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/not-zip-safe +0 -0
  24. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/requires.txt +0 -0
  25. {afsapi-0.2.7 → afsapi-0.2.9}/afsapi.egg-info/top_level.txt +0 -0
  26. {afsapi-0.2.7 → afsapi-0.2.9}/requirements.txt +0 -0
  27. {afsapi-0.2.7 → afsapi-0.2.9}/setup.py +0 -0
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: Publish to PyPI
3
+
4
+ on:
5
+ release:
6
+ types: [published]
7
+
8
+ permissions:
9
+ attestations: write
10
+ contents: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ - uses: hynek/build-and-inspect-python-package@v2
21
+ with:
22
+ attest-build-provenance-github: "true"
23
+
24
+ pypi-publish:
25
+ name: upload release to PyPI
26
+ runs-on: ubuntu-latest
27
+ needs: build
28
+ environment: pypi
29
+ steps:
30
+ - uses: actions/download-artifact@v4
31
+ with:
32
+ name: Packages
33
+ path: dist
34
+ - name: Publish package distributions to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
36
+ - name: Create GitHub Release
37
+ uses: actions/create-release@v1
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+ with:
41
+ tag_name: ${{ github.ref }}
42
+ release_name: ${{ github.ref }}
43
+ body: Release ${{ github.ref }}
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: afsapi
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Asynchronous Implementation of the Frontier Silicon API
5
5
  Home-page: https://github.com/zhelev/python-afsapi.git
6
6
  Author: Krasimir Zhelev
@@ -19,8 +19,10 @@ Classifier: Programming Language :: Python :: 3.5
19
19
  Classifier: Programming Language :: Python :: 3.6
20
20
  Classifier: Topic :: Software Development :: Libraries
21
21
  Requires-Python: >=3.7
22
- Description-Content-Type: text/markdown; charset=UTF-8
22
+ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
+ Requires-Dist: aiohttp<4,>=3.3.2
25
+ Dynamic: license-file
24
26
 
25
27
  # python-afsapi
26
28
 
@@ -1,6 +1,13 @@
1
1
  from .api import AFSAPI # noqa
2
- from .models import * # noqa
3
- from .exceptions import * # noqa
2
+ from afsapi.exceptions import (
3
+ FSApiException,
4
+ InvalidPinException,
5
+ InvalidSessionException,
6
+ NotImplementedException,
7
+ OutOfRangeException,
8
+ ConnectionError,
9
+ )
10
+ from afsapi.models import Preset, Equaliser, PlayerMode, PlayControl, PlayState
4
11
 
5
12
  from importlib.metadata import version, PackageNotFoundError
6
13
 
@@ -16,3 +23,8 @@ except PackageNotFoundError: # pragma: no cover
16
23
  "use the PyPI ones."
17
24
  )
18
25
  __version__ = VERSION
26
+
27
+ __all__ = ['AFSAPI', 'PlayState', 'PlayControl', 'PlayerMode', 'Equaliser',
28
+ 'Preset', 'FSApiException', 'NotImplementedException',
29
+ 'ConnectionError', 'OutOfRangeException', 'InvalidPinException',
30
+ 'InvalidSessionException']
@@ -49,6 +49,11 @@ API = {
49
49
  # sys
50
50
  "power": "netRemote.sys.power",
51
51
  "mode": "netRemote.sys.mode",
52
+ "wired_mac": "netRemote.sys.net.wired.macAddress",
53
+ "wired_active": "netRemote.sys.net.wired.interfaceEnable",
54
+ "wlan_mac": "netRemote.sys.net.wlan.macAddress",
55
+ "wlan_active": "netRemote.sys.net.wlan.interfaceEnable",
56
+ "rssi": "netRemote.sys.net.wlan.rssi",
52
57
  # sys.info
53
58
  "friendly_name": "netRemote.sys.info.friendlyName",
54
59
  "radio_id": "netRemote.sys.info.radioId",
@@ -217,7 +222,7 @@ class AFSAPI:
217
222
  raise FSApiException(
218
223
  f"Unexpected result {result.status}: {await result.text()}"
219
224
  )
220
- doc = ET.fromstring(await result.text(encoding="utf-8"))
225
+ doc = ET.fromstring(await result.text(encoding="utf-8", errors="replace"))
221
226
  status = unpack_xml(doc, "status")
222
227
 
223
228
  if status == "FS_OK" or status == "FS_LIST_END":
@@ -356,6 +361,27 @@ class AFSAPI:
356
361
  """Get the friendly name of the device."""
357
362
  return await self.handle_text(API["radio_id"])
358
363
 
364
+ async def get_mac(self) -> t.Optional[str]:
365
+ """Get the MAC address of the device."""
366
+ on_wlan = await self.handle_int(API["wlan_active"])
367
+ if bool(on_wlan):
368
+ return await self.handle_text(API["wlan_mac"])
369
+ else:
370
+ return await self.handle_text(API["wired_mac"])
371
+
372
+ async def get_rssi(self) -> t.Optional[int]:
373
+ """Get the current wlan Received Signal Strength Indication in dBm"""
374
+
375
+ # RSSI is returned as a percentage by the API, scaled linearly between
376
+ # -80dBm (0%) and -20dBm (100%). 100% indicates a wired
377
+ # connection. This functions returns the dBm value of RSSI.
378
+
379
+ rssi = await self.handle_int(API["rssi"])
380
+ if rssi is not None:
381
+ return int(round(rssi * 0.6 - 80))
382
+ else:
383
+ return None
384
+
359
385
  async def get_power(self) -> t.Optional[bool]:
360
386
  """Check if the device is on."""
361
387
  power = await self.handle_int(API["power"])
@@ -491,6 +517,10 @@ class AFSAPI:
491
517
  """
492
518
  return await self.handle_set(API["control"], int(value))
493
519
 
520
+ async def stop(self) -> t.Optional[bool]:
521
+ """Stop (and Start) media."""
522
+ return await self.play_control(PlayControl.STOP)
523
+
494
524
  async def play(self) -> t.Optional[bool]:
495
525
  """Play media."""
496
526
  return await self.play_control(PlayControl.PLAY)
@@ -609,7 +639,7 @@ class AFSAPI:
609
639
  """Check when and if the device is going to sleep."""
610
640
  return await self.handle_long(API["sleep"])
611
641
 
612
- async def set_sleep(self, value: bool = False) -> t.Optional[bool]:
642
+ async def set_sleep(self, value: int = 0) -> t.Optional[bool]:
613
643
  """Set device sleep timer."""
614
644
  return await self.handle_set(API["sleep"], int(value))
615
645
 
@@ -11,6 +11,7 @@ class PlayState(IntEnum):
11
11
 
12
12
 
13
13
  class PlayControl(IntEnum):
14
+ STOP = 0
14
15
  PLAY = 1
15
16
  PAUSE = 2
16
17
  NEXT = 3
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.2.9'
22
+ __version_tuple__ = version_tuple = (0, 2, 9)
23
+
24
+ __commit_id__ = commit_id = 'g26887da2b'
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: afsapi
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Asynchronous Implementation of the Frontier Silicon API
5
5
  Home-page: https://github.com/zhelev/python-afsapi.git
6
6
  Author: Krasimir Zhelev
@@ -19,8 +19,10 @@ Classifier: Programming Language :: Python :: 3.5
19
19
  Classifier: Programming Language :: Python :: 3.6
20
20
  Classifier: Topic :: Software Development :: Libraries
21
21
  Requires-Python: >=3.7
22
- Description-Content-Type: text/markdown; charset=UTF-8
22
+ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
+ Requires-Dist: aiohttp<4,>=3.3.2
25
+ Dynamic: license-file
24
26
 
25
27
  # python-afsapi
26
28
 
@@ -7,8 +7,6 @@ requirements.txt
7
7
  setup.cfg
8
8
  setup.py
9
9
  .github/workflows/python-publish.yml
10
- .github/workflows/python.yml
11
- .github/workflows/yaml.yml
12
10
  afsapi/__init__.py
13
11
  afsapi/api.py
14
12
  afsapi/exceptions.py
@@ -10,7 +10,7 @@ PIN = 1234
10
10
  TIMEOUT = 2 # in seconds
11
11
 
12
12
 
13
- async def test_sys():
13
+ async def test_sys() -> None:
14
14
  """Test sys functions."""
15
15
  try:
16
16
  afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)
@@ -38,7 +38,7 @@ async def test_sys():
38
38
  logging.error(traceback.format_exc())
39
39
 
40
40
 
41
- async def test_volume():
41
+ async def test_volume() -> None:
42
42
  """Test volume functions."""
43
43
  try:
44
44
  afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)
@@ -70,7 +70,7 @@ async def test_volume():
70
70
  logging.error(traceback.format_exc())
71
71
 
72
72
 
73
- async def test_info():
73
+ async def test_info() -> None:
74
74
  """Test info functions."""
75
75
  try:
76
76
  afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)
@@ -83,6 +83,8 @@ async def test_info():
83
83
 
84
84
  print(f"Radio ID: {await afsapi.get_radio_id()}")
85
85
  print(f"Version: {await afsapi.get_version()}")
86
+ print(f"MAC: {await afsapi.get_mac()}")
87
+ print(f"RSSI: {await afsapi.get_rssi()} dBm")
86
88
 
87
89
  name = await afsapi.get_play_name()
88
90
  print("Name: %s" % name)
@@ -111,7 +113,7 @@ async def test_info():
111
113
  logging.error(traceback.format_exc())
112
114
 
113
115
 
114
- async def test_play():
116
+ async def test_play() -> None:
115
117
  """Test play functions."""
116
118
  try:
117
119
  afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)
@@ -119,21 +121,28 @@ async def test_play():
119
121
  status = await afsapi.get_play_status()
120
122
  print("Status: %s" % status)
121
123
 
124
+ pause = await afsapi.pause()
125
+ print("Start play succeeded? - %s" % pause)
126
+ await asyncio.sleep(2)
127
+
122
128
  start_play = await afsapi.play()
123
129
  print("Start play succeeded? - %s" % start_play)
124
- await asyncio.sleep(1)
130
+ await asyncio.sleep(2)
125
131
 
126
132
  forward = await afsapi.forward()
127
133
  print("Next succeeded? - %s" % forward)
128
- await asyncio.sleep(1)
134
+ await asyncio.sleep(2)
129
135
 
130
136
  rewind = await afsapi.rewind()
131
137
  print("Prev succeeded? - %s" % rewind)
132
138
 
139
+ stop = await afsapi.stop()
140
+ print("Stop play succeeded? - %s" % stop)
141
+ await asyncio.sleep(2)
142
+
133
143
  except Exception:
134
144
  logging.error(traceback.format_exc())
135
145
 
136
-
137
146
  loop = asyncio.new_event_loop()
138
147
 
139
148
  loop.run_until_complete(test_sys())
@@ -1,7 +1,7 @@
1
1
  [build-system]
2
2
  requires = [
3
3
  "setuptools >= 48",
4
- "setuptools_scm[toml] >= 4, <6",
4
+ "setuptools_scm[toml]",
5
5
  "setuptools_scm_git_archive",
6
6
  "wheel >= 0.29.0",
7
7
  ]
@@ -12,10 +12,8 @@ write_to = "afsapi/version.py"
12
12
 
13
13
  [tool.mypy]
14
14
  strict = true
15
- files=["afsapi"]
16
- exclude = [
17
- "afsapi/__init__.py"
18
- ]
15
+ files = ["afsapi"]
16
+ exclude = ["afsapi/__init__.py"]
19
17
 
20
18
  [pycodestyle]
21
19
  max_line_length = 120
@@ -2,7 +2,7 @@
2
2
  name = afsapi
3
3
  description = Asynchronous Implementation of the Frontier Silicon API
4
4
  long_description = file: README.md
5
- long_description_content_type = text/markdown; charset=UTF-8
5
+ long_description_content_type = text/markdown
6
6
  url = https://github.com/zhelev/python-afsapi.git
7
7
  author = Krasimir Zhelev
8
8
  author_email = krasimir.zhelev@gmail.com
@@ -32,6 +32,7 @@ install_requires =
32
32
  python_requires = >=3.7
33
33
  setup_requires =
34
34
  setuptools_scm
35
+ setuptools
35
36
 
36
37
  [bdist_wheel]
37
38
  universal = 1
@@ -1,34 +0,0 @@
1
- name: Upload Python Package
2
-
3
- on:
4
- release:
5
- types: [published]
6
-
7
- jobs:
8
- deploy:
9
- runs-on: ubuntu-latest
10
-
11
- steps:
12
- - uses: actions/checkout@v2
13
- - name: Set up Python
14
- uses: actions/setup-python@v2
15
- with:
16
- python-version: "3.10"
17
- - name: Install dependencies
18
- run: |
19
- python -m pip install --upgrade pip
20
- pip install build
21
- - name: Build package
22
- run: python -m build
23
-
24
- - uses: shogo82148/actions-upload-release-asset@v1
25
- with:
26
- upload_url: ${{ github.event.release.upload_url }}
27
- asset_path: dist/*
28
- - name: Publish package
29
- uses: >-
30
- pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
31
- if: github.repository_owner == 'wlcrs'
32
- with:
33
- user: __token__
34
- password: ${{ secrets.PYPI_API_TOKEN }}
@@ -1,53 +0,0 @@
1
- ---
2
- name: Python
3
-
4
- on: push
5
-
6
- jobs:
7
- build-n-test:
8
- name: Build and test Python code
9
- runs-on: ubuntu-20.04
10
- steps:
11
- - uses: actions/checkout@master
12
- - name: Set up Python 3.10
13
- uses: actions/setup-python@v1
14
- with:
15
- python-version: "3.10"
16
-
17
- - name: flake8 Lint
18
- uses: py-actions/flake8@v2
19
- with:
20
- max-line-length: "120"
21
- env:
22
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23
-
24
-
25
- - name: Install pypa/build
26
- run: >-
27
- python -m
28
- pip install
29
- build
30
- --user
31
- - name: Build a binary wheel and a source tarball
32
- run: >-
33
- python -m
34
- build
35
- --sdist
36
- --wheel
37
- --outdir dist/
38
- .
39
-
40
- - name: Install Requirements (for Mypy analysis)
41
- run: pip install -r requirements.txt
42
-
43
- - name: Install Mypy
44
- run: pip install mypy
45
-
46
- - name: Mypy
47
- run: mypy
48
-
49
- - name: Save packages as artifacts
50
- uses: actions/upload-artifact@v2
51
- with:
52
- name: packages
53
- path: dist/
@@ -1,20 +0,0 @@
1
- ---
2
- name: Yaml Lint
3
- on:
4
- push:
5
- paths:
6
- - '**.yml'
7
- - '**.yaml'
8
- jobs:
9
- lintAllTheThings:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v2
13
- - name: yaml-lint
14
- uses: ibiqlik/action-yamllint@v3
15
- with:
16
- config_data: |
17
- extends: default
18
- rules:
19
- truthy: disable
20
- ...
@@ -1,5 +0,0 @@
1
- # coding: utf-8
2
- # file generated by setuptools_scm
3
- # don't change, don't track in version control
4
- version = '0.2.7'
5
- version_tuple = (0, 2, 7)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes