naeural-client 2.7.25__py3-none-any.whl → 2.7.27__py3-none-any.whl

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.
naeural_client/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "2.7.25"
1
+ __VER__ = "2.7.27"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -1098,28 +1098,32 @@ class BaseLogger(object):
1098
1098
  def reload_config(self):
1099
1099
  self._configure_data_and_dirs(self.config_file, self.config_file_encoding)
1100
1100
  return
1101
-
1102
- def _maybe_migrate_folder(self):
1103
- user_folder = self.get_user_folder()
1104
- if user_folder.is_dir():
1105
- self.P(f"{str(user_folder)} already exists. Skipping migration.")
1101
+
1102
+ @staticmethod
1103
+ def maybe_migrate_user_folder(verbose=False):
1104
+ current_user_folder = BaseLogger.get_user_folder()
1105
+ if current_user_folder.is_dir():
1106
+ if verbose:
1107
+ BaseLogger.print_color(f"{str(current_user_folder)} already exists. Skipping migration.")
1106
1108
  return
1107
- user_base_folder = self.get_user_folder(as_str=True, include_sdk_home=True)
1108
- self.P(f'{str(user_folder)} does not exist. Checking for previous app homes if necessary...')
1109
- if user_base_folder in self._base_folder:
1110
- BaseLogger.print_color("Using default user folder. Checking for previous app homes...", color='d')
1111
- for old_sdk in SDK_HOME_PREV:
1112
- new_path = self.get_user_folder(as_str=False, include_sdk_home=True)
1113
- old_path = self.get_user_folder(as_str=False, include_sdk_home=False) / old_sdk
1114
- self.P(f'Checking for previous app home: {old_path}')
1115
- if old_path.is_dir():
1116
- BaseLogger.print_color(f"Found previous app home '{old_path}'. Renaming to '{SDK_HOME}'...", color='d')
1117
- old_path.rename(new_path)
1118
- break
1119
- #endfor
1120
- #endif
1109
+ if verbose:
1110
+ BaseLogger.print_color(f'User folder {str(current_user_folder)} does not exist. Checking for previous versions...')
1111
+ for old_sdk_home in SDK_HOME_PREV:
1112
+ old_user_folder = current_user_folder.parent / old_sdk_home
1113
+ if old_user_folder.is_dir():
1114
+ if verbose:
1115
+ BaseLogger.print_color(f"Found previous user folder '{old_user_folder}'. Renaming to '{current_user_folder}'...")
1116
+ old_user_folder.rename(current_user_folder)
1117
+ return
1118
+ if verbose:
1119
+ BaseLogger.print_color("No previous user folders found.")
1121
1120
  return
1122
1121
 
1122
+ def _maybe_migrate_folder(self):
1123
+ user_base_folder = BaseLogger.get_user_folder(as_str=True, include_sdk_home=True)
1124
+ if user_base_folder in self._base_folder:
1125
+ BaseLogger.maybe_migrate_user_folder(verbose=True)
1126
+ return
1123
1127
 
1124
1128
  def _configure_data_and_dirs(self, config_file, config_file_encoding=None):
1125
1129
  self._maybe_migrate_folder()
@@ -1644,8 +1648,7 @@ class BaseLogger(object):
1644
1648
  return result
1645
1649
 
1646
1650
 
1647
- @staticmethod
1648
- def utc_to_local(remote_datetime, remote_utc, fmt='%Y-%m-%d %H:%M:%S', as_string=False):
1651
+ def utc_to_local(self, remote_datetime, remote_utc, fmt='%Y-%m-%d %H:%M:%S', as_string=False):
1649
1652
  """
1650
1653
  Given a "remote" datetime (in datetime or str format) and a string or int denoting an offset
1651
1654
  will return local datetime as a datetime object.
@@ -1664,13 +1667,21 @@ class BaseLogger(object):
1664
1667
  """
1665
1668
  if remote_utc is None:
1666
1669
  remote_utc = 'UTC+3'
1667
- if isinstance(remote_utc, str):
1668
- remote_utc = tz.gettz(remote_utc)
1669
- elif isinstance(remote_utc, int):
1670
- utc_offset = remote_utc
1671
- remote_utc = tz.tzoffset(None, timedelta(hours=utc_offset))
1672
- elif not isinstance(remote_utc, tzinfo):
1673
- raise ValueError("Unknown remote_utc type: {}".format(type(remote_utc)))
1670
+ try:
1671
+ if isinstance(remote_utc, str):
1672
+ remote_utc = tz.gettz(remote_utc)
1673
+ elif isinstance(remote_utc, int):
1674
+ utc_offset = remote_utc
1675
+ remote_utc = tz.tzoffset(None, timedelta(hours=utc_offset))
1676
+ elif not isinstance(remote_utc, tzinfo):
1677
+ raise ValueError("Unknown remote_utc type: {}".format(type(remote_utc)))
1678
+ except Exception as exc:
1679
+ # if it breaks use local time
1680
+ remote_utc = tz.tzlocal()
1681
+ self.P("Error in remote_datetime: {} requested remote_utc: {}, Error: {}. Using local timezone {} for given date.".format(
1682
+ remote_datetime, remote_utc, exc, remote_utc), color='r'
1683
+ )
1684
+
1674
1685
 
1675
1686
  if isinstance(remote_datetime, str):
1676
1687
  remote_datetime = dt.strptime(remote_datetime, fmt)
@@ -327,7 +327,10 @@ def maybe_init_config():
327
327
  """
328
328
  config_file = get_user_config_file()
329
329
  if not config_file.exists():
330
- log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
331
- reset_config(keep_existing=True)
332
- return False
330
+ BaseLogger.maybe_migrate_user_folder(verbose=True)
331
+ if not config_file.exists():
332
+ log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
333
+ reset_config(keep_existing=True)
334
+ return False
335
+ # config_file still does not exist even after attempting the migration.
333
336
  return load_user_defined_config()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.7.25
3
+ Version: 2.7.27
4
4
  Summary: `naeural_client` is the Python SDK required for client app development for the Naeural Edge Protocol Edge Protocol framework
5
5
  Project-URL: Homepage, https://github.com/NaeuralEdgeProtocol/naeural_client
6
6
  Project-URL: Bug Tracker, https://github.com/NaeuralEdgeProtocol/naeural_client/issues
@@ -1,5 +1,5 @@
1
1
  naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=hFnAs1TM_Kwj7JxuCpMk1xnESln3MBoRLAaOeR42P3g,331
2
+ naeural_client/_ver.py,sha256=xPABtqoee7FOJbdkfLEdq81iAPs9A1AH0mTWt03WkkA,331
3
3
  naeural_client/base_decentra_object.py,sha256=C4iwZTkhKNBS4VHlJs5DfElRYLo4Q9l1V1DNVSk1fyQ,4412
4
4
  naeural_client/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
5
5
  naeural_client/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
@@ -60,7 +60,7 @@ naeural_client/io_formatter/default/a_dummy.py,sha256=qr9eUizQ-NN5jdXVzkaZKMaf9K
60
60
  naeural_client/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz5lgrQWo7td5Ri1A,3052
61
61
  naeural_client/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
62
62
  naeural_client/logging/__init__.py,sha256=b79X45VC6c37u32flKB2GAK9f-RR0ocwP0JDCy0t7QQ,33
63
- naeural_client/logging/base_logger.py,sha256=cfSWHoZkDS0XSaNMF-ldNjAHZ0OkW8_B_oSwPQomoTM,69208
63
+ naeural_client/logging/base_logger.py,sha256=c-ZSMHc_eO84MKrLOJcClxvhQydFD8W0LoWe5_hu2ag,69611
64
64
  naeural_client/logging/small_logger.py,sha256=m12hCb_H4XifJYYfgCAOUDkcXm-h4pSODnFf277OFVI,2937
65
65
  naeural_client/logging/logger_mixins/__init__.py,sha256=yQO7umlRvz63FeWpi-F9GRmC_MOHcNW6R6pwvZZBy3A,600
66
66
  naeural_client/logging/logger_mixins/class_instance_mixin.py,sha256=xUXE2VZgmrlrSrvw0f6GF1jlTnVLeVkIiG0bhlBfq3o,2741
@@ -82,11 +82,11 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
82
82
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
83
83
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
84
84
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
85
- naeural_client/utils/config.py,sha256=wVY_IdLJ6D-eJYnfsOGUa4eJApxDX2oAqK0FhjPI1DE,10187
85
+ naeural_client/utils/config.py,sha256=IG7-rRYBWCqCiI2kDesFmY8gld0Ku9xWgzNPE1rwVcA,10352
86
86
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
87
87
  naeural_client/utils/oracle_sync/oracle_tester.py,sha256=GmZwu2JM9_UB2K-4rKB3o0RgWLqM-7Im6HwBnQLXmHI,25312
88
- naeural_client-2.7.25.dist-info/METADATA,sha256=Px5ucQyshk9HmWNfeIQDmNzH9-OeCPdDvjHsPO1R7X8,12354
89
- naeural_client-2.7.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
90
- naeural_client-2.7.25.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
91
- naeural_client-2.7.25.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
92
- naeural_client-2.7.25.dist-info/RECORD,,
88
+ naeural_client-2.7.27.dist-info/METADATA,sha256=ljUYQkJp_UZZ1YFBTa40yuFvo-DgIAvTQUQJsVnmg50,12354
89
+ naeural_client-2.7.27.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
90
+ naeural_client-2.7.27.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
91
+ naeural_client-2.7.27.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
92
+ naeural_client-2.7.27.dist-info/RECORD,,