gshock-api 2.0.6__tar.gz → 2.0.8__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 (48) hide show
  1. {gshock_api-2.0.6/src/gshock_api.egg-info → gshock_api-2.0.8}/PKG-INFO +1 -1
  2. {gshock_api-2.0.6 → gshock_api-2.0.8}/pyproject.toml +1 -1
  3. {gshock_api-2.0.6 → gshock_api-2.0.8}/setup.py +1 -1
  4. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/cancelable_result.py +2 -2
  5. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/connection.py +10 -5
  6. gshock_api-2.0.8/src/gshock_api/exceptions.py +13 -0
  7. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/gshock_api.py +0 -2
  8. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/time_io.py +8 -4
  9. {gshock_api-2.0.6 → gshock_api-2.0.8/src/gshock_api.egg-info}/PKG-INFO +1 -1
  10. gshock_api-2.0.6/src/gshock_api/exceptions.py +0 -9
  11. {gshock_api-2.0.6 → gshock_api-2.0.8}/LICENSE.txt +0 -0
  12. {gshock_api-2.0.6 → gshock_api-2.0.8}/README.rst +0 -0
  13. {gshock_api-2.0.6 → gshock_api-2.0.8}/setup.cfg +0 -0
  14. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/__init__.py +0 -0
  15. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/alarms.py +0 -0
  16. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/app_notification.py +0 -0
  17. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/casio_constants.py +0 -0
  18. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/configurator.py +0 -0
  19. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/event.py +0 -0
  20. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/__init__.py +0 -0
  21. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/alarms_io.py +0 -0
  22. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/app_info_io.py +0 -0
  23. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/app_notification_io.py +0 -0
  24. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/button_pressed_io.py +0 -0
  25. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/dst_for_world_cities_io.py +0 -0
  26. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/dst_watch_state_io.py +0 -0
  27. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/error_io.py +0 -0
  28. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/events_io.py +0 -0
  29. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/settings_io.py +0 -0
  30. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/time_adjustement_io.py +0 -0
  31. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/timer_io.py +0 -0
  32. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/unknown_io.py +0 -0
  33. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/watch_condition_io.py +0 -0
  34. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/watch_name_io.py +0 -0
  35. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/iolib/world_cities_io.py +0 -0
  36. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/logger.py +0 -0
  37. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/mailsener.py +0 -0
  38. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/message_dispatcher.py +0 -0
  39. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/scanner.py +0 -0
  40. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/settings.py +0 -0
  41. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/utils.py +0 -0
  42. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api/watch_info.py +0 -0
  43. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api.egg-info/SOURCES.txt +0 -0
  44. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api.egg-info/dependency_links.txt +0 -0
  45. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api.egg-info/not-zip-safe +0 -0
  46. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api.egg-info/requires.txt +0 -0
  47. {gshock_api-2.0.6 → gshock_api-2.0.8}/src/gshock_api.egg-info/top_level.txt +0 -0
  48. {gshock_api-2.0.6 → gshock_api-2.0.8}/tests/test_code.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gshock_api
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Pythgon API for GShock Watches using BLE
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: Ivo Zivkov
@@ -5,7 +5,7 @@ requires = ["setuptools>=61.0"]
5
5
 
6
6
  [project]
7
7
  name = "gshock_api" # Change to your project name
8
- version = "2.0.6"
8
+ version = "2.0.8"
9
9
  description = "Pythgon API for GShock Watches using BLE"
10
10
  readme = "README.rst"
11
11
  authors = [{ name = "Ivo Zivkov", email = "izivkov@gmail.com" }]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='gshock_api',
5
- version='2.0.6',
5
+ version='2.0.8',
6
6
  package_dir={'': 'src'},
7
7
  packages=find_packages(where='src'),
8
8
  install_requires=[
@@ -3,7 +3,7 @@ from typing import Any
3
3
  from gshock_api.exceptions import GShockConnectionError
4
4
 
5
5
  class CancelableResult:
6
- def __init__(self, timeout: float = 3.0):
6
+ def __init__(self, timeout: float = 10.0):
7
7
  self._timeout = timeout
8
8
  self._future: asyncio.Future[Any] = asyncio.Future()
9
9
 
@@ -14,7 +14,7 @@ class CancelableResult:
14
14
  except asyncio.TimeoutError as e:
15
15
  if not self._future.done():
16
16
  self._future.set_result('') # or raise an exception instead
17
- raise GShockConnectionError(f"Timeout occured wait for response from the watch: {e}") from e
17
+ raise GShockConnectionError(f"Timeout occured waiting for response from the watch: {e}") from e
18
18
 
19
19
  def set_result(self, result: Any) -> None:
20
20
  if not self._future.done():
@@ -1,5 +1,7 @@
1
- import asyncio
1
+ import asyncio, time
2
+ from tracemalloc import start
2
3
  from bleak import BleakClient
4
+ from bleak.exc import BleakDBusError
3
5
  from bleak.backends.characteristic import BleakGATTCharacteristic
4
6
  from gshock_api.casio_constants import CasioConstants
5
7
  from gshock_api import message_dispatcher
@@ -8,7 +10,7 @@ from gshock_api.logger import logger
8
10
  from gshock_api.watch_info import watch_info
9
11
  from bleak.backends.device import BLEDevice
10
12
  from gshock_api.scanner import scanner
11
- from gshock_api.exceptions import GShockConnectionError
13
+ from gshock_api.exceptions import GShockIgnorableException, GShockConnectionError
12
14
 
13
15
  class Connection:
14
16
  def __init__(self, address = None):
@@ -71,7 +73,7 @@ class Connection:
71
73
  )
72
74
  if (handle == 13):
73
75
  logger.info(
74
- "Your watch does not suppot notifications..."
76
+ "Your watch does not support notifications..."
75
77
  )
76
78
  return
77
79
 
@@ -80,8 +82,11 @@ class Connection:
80
82
  )
81
83
 
82
84
  except Exception as e:
83
- logger.info("write failed with exception: {}".format(e))
84
- raise GShockConnectionError(f"Unable to connect to G-Shock device: {e}") from e
85
+ e.args = (type(e).__name__,)
86
+ if isinstance(e, (BleakDBusError, EOFError)):
87
+ raise GShockIgnorableException(e)
88
+ else:
89
+ raise GShockConnectionError(f"Unable to send time to watch: {e}")
85
90
 
86
91
  async def request(self, request):
87
92
  await self.write(0xC, request)
@@ -0,0 +1,13 @@
1
+ # gshock_api/exceptions.py
2
+
3
+ class GShockError(Exception):
4
+ """Base exception for all G-Shock errors."""
5
+ pass
6
+
7
+ class GShockConnectionError(GShockError):
8
+ """Raised when BLE connection to G-Shock device fails."""
9
+ pass
10
+
11
+ class GShockIgnorableException(GShockError):
12
+ """Raised when BLE connection to G-Shock device fails."""
13
+ pass
@@ -205,8 +205,6 @@ class GshockAPI:
205
205
  if current_time == None:
206
206
  current_time = time.time()
207
207
 
208
- self.logger.info(f"=======> passed: ${current_time}, ${time.time()}")
209
-
210
208
  await self.initialize_for_setting_time()
211
209
  await self._set_time(current_time)
212
210
  current_time = None
@@ -3,17 +3,16 @@ import datetime
3
3
  import json
4
4
  import time
5
5
  from typing import Any
6
- from gshock_api.cancelable_result import CancelableResult
7
6
  from gshock_api.logger import logger
8
7
 
9
8
  from gshock_api.utils import to_compact_string, to_hex_string
10
9
  from gshock_api.casio_constants import CasioConstants
10
+ from gshock_api.exceptions import GShockIgnorableException
11
11
 
12
12
  CHARACTERISTICS = CasioConstants.CHARACTERISTICS
13
13
 
14
14
 
15
15
  class TimeIO:
16
- result: CancelableResult = None
17
16
  connection = None
18
17
 
19
18
  @staticmethod
@@ -37,8 +36,13 @@ class TimeIO:
37
36
  time_command = to_hex_string(
38
37
  bytearray([CHARACTERISTICS["CASIO_CURRENT_TIME"]]) + time_data
39
38
  )
40
- await TimeIO.connection.write(0xE, to_compact_string(time_command))
41
-
39
+ try:
40
+ await TimeIO.connection.write(0xE, to_compact_string(time_command))
41
+ except (GShockIgnorableException) as e:
42
+ # Ignore this exception if the LOWER-RIGHT button is pressed.
43
+ # In this case, the connection will be closed before the call completes with a response, and we get an EOFError.
44
+ # The call actually works, though.
45
+ logger.info(f"Ignoring {e}")
42
46
 
43
47
  class TimeEncoder:
44
48
  def prepare_current_time(date: datetime.datetime):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gshock_api
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Pythgon API for GShock Watches using BLE
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: Ivo Zivkov
@@ -1,9 +0,0 @@
1
- # gshock_api/exceptions.py
2
-
3
- class GShockError(Exception):
4
- """Base exception for all G-Shock errors."""
5
- pass
6
-
7
- class GShockConnectionError(GShockError):
8
- """Raised when BLE connection to G-Shock device fails."""
9
- pass
File without changes
File without changes
File without changes