osbot-utils 1.22.0__py3-none-any.whl → 1.23.0__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.
@@ -13,6 +13,8 @@ class SSH(Type_Safe): # todo: add ip_address to global vars here, and when
13
13
  self.ssh_execute().setup()
14
14
  return self
15
15
 
16
+ def exec(self,command):
17
+ return self.ssh_execute().execute_command(command)
16
18
  @cache_on_self
17
19
  def scp(self):
18
20
  kwargs = self.ssh_execute().__locals__() # get the current ssh config details
osbot_utils/utils/Env.py CHANGED
@@ -63,30 +63,32 @@ def env_unload_from_file(path):
63
63
  if key in os.environ: # Remove the environment variable if it exists
64
64
  del os.environ[key]
65
65
 
66
+ def find_dotenv_file(start_path=None, env_file_to_find='.env'):
67
+ directories = all_parent_folders(path=start_path, include_path=True) # Define the possible directories to search for the .env file (which is this and all parent folders)
68
+ for directory in directories: # Iterate through the directories and load the .env file if found
69
+ env_path = os.path.join(directory,env_file_to_find) # Define the path to the .env file
70
+ if os.path.exists(env_path): # If we found one
71
+ return env_path # return the path to the .env file
72
+
66
73
  def in_github_action():
67
74
  return os.getenv('GITHUB_ACTIONS') == 'true'
68
75
 
69
76
  def in_python_debugger():
70
77
  if sys.gettrace() is not None: # Check for a trace function
71
78
  return True
72
-
73
79
  pycharm_hosted = os.getenv('PYCHARM_HOSTED') == '1' # Check for PyCharm specific environment variables and other potential indicators
74
80
  pydevd_load_values_async = os.getenv('PYDEVD_LOAD_VALUES_ASYNC') is not None
75
81
  if pycharm_hosted and pydevd_load_values_async:
76
82
  return True
77
-
78
83
  return False
79
84
 
80
85
  def load_dotenv(dotenv_path=None, override=False):
81
- if dotenv_path: # If a specific dotenv path is provided, load from it
86
+ if dotenv_path: # If a specific dotenv path is provided, load from it
82
87
  env_load_from_file(dotenv_path, override)
83
88
  else:
84
- directories = all_parent_folders(include_path=True) # Define the possible directories to search for the .env file (which is this and all parent folders)
85
- for directory in directories: # Iterate through the directories and load the .env file if found
86
- env_path = os.path.join(directory, '.env') # Define the path to the .env file
87
- if os.path.exists(env_path): # If we found one
88
- env_load_from_file(env_path, override) # Process it
89
- break # Stop after loading the first .env file # Stop after loading the first .env file
89
+ env_file = find_dotenv_file()
90
+ if env_file:
91
+ env_load_from_file(env_file, override) # Process it
90
92
 
91
93
 
92
94
  def not_in_github_action():
@@ -315,8 +315,10 @@ class Files:
315
315
  return abspath(join(parent_path,sub_path))
316
316
 
317
317
  @staticmethod
318
- def parent_folder(path):
318
+ def parent_folder(path, use_full_path=False):
319
319
  if path:
320
+ if use_full_path:
321
+ path = file_full_path(path)
320
322
  return os.path.dirname(path)
321
323
 
322
324
  @staticmethod
@@ -429,6 +431,8 @@ class Files:
429
431
  return path
430
432
 
431
433
  # todo: refactor the methods above into static methods (as bellow)
434
+ def absolute_path(path):
435
+ return abspath(path)
432
436
 
433
437
  def all_parent_folders(path=None, include_path=False):
434
438
  if path is None:
@@ -498,6 +502,7 @@ file_create_gz = Files.write_gz
498
502
  file_exists = Files.exists
499
503
  file_extension = Files.file_extension
500
504
  file_extension_fix = Files.file_extension_fix
505
+ file_full_path = absolute_path
501
506
  file_lines = Files.lines
502
507
  file_lines_gz = Files.lines_gz
503
508
  file_md5 = Files.contents_md5
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v1.22.0
1
+ v1.23.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osbot_utils
3
- Version: 1.22.0
3
+ Version: 1.23.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  Home-page: https://github.com/owasp-sbot/OSBot-Utils
6
6
  License: MIT
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
22
22
 
23
23
  Powerful Python util methods and classes that simplify common apis and tasks.
24
24
 
25
- ![Current Release](https://img.shields.io/badge/release-v1.22.0-blue)
25
+ ![Current Release](https://img.shields.io/badge/release-v1.23.0-blue)
26
26
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
27
27
 
28
28
 
@@ -217,7 +217,7 @@ osbot_utils/helpers/sqlite/tables/Sqlite__Table__Files.py,sha256=ZlhTqroHd9T8vqN
217
217
  osbot_utils/helpers/sqlite/tables/Sqlite__Table__Nodes.py,sha256=GT8h3wD4hGvEtqQuBs0sBbcu2ydktRHTi95PEL2ffHQ,1721
218
218
  osbot_utils/helpers/sqlite/tables/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
219
219
  osbot_utils/helpers/ssh/SCP.py,sha256=9PgJbyWKfxJj00Ijaj7o6ffxPXuNoureb6JlHMPbHww,3330
220
- osbot_utils/helpers/ssh/SSH.py,sha256=YC3mwLjHxiCrt4t2s15xvAdFcz4yfQVMwqE8mByKmVU,1458
220
+ osbot_utils/helpers/ssh/SSH.py,sha256=jyRZIL8rif1Fn76i0ZJWSkY0VyQuB1J2LAWIvu4jKpU,1545
221
221
  osbot_utils/helpers/ssh/SSH__Cache__Requests.py,sha256=Dqh4biVcuaXbQVvn3Tx-kSGBGHiF-2wVsgu96EhD6gU,3359
222
222
  osbot_utils/helpers/ssh/SSH__Execute.py,sha256=D5tQGbSPaNsrMvhTVT0sZIHpqF1rIYXYiaWzGExcwm4,6849
223
223
  osbot_utils/helpers/ssh/SSH__Health_Check.py,sha256=WDmBD6ejNcBeicXfjpsiNzH-WR3Jejx0re3WfwjSWyQ,2083
@@ -262,9 +262,9 @@ osbot_utils/utils/Assert.py,sha256=u9XLgYn91QvNWZGyPi29SjPJSXRHlm9andIn3NJEVog,1
262
262
  osbot_utils/utils/Call_Stack.py,sha256=MAq_0vMxnbeLfCe9qQz7GwJYaOuXpt3qtQwN6wiXsU0,6595
263
263
  osbot_utils/utils/Csv.py,sha256=oHLVpjRJqrLMz9lubMCNEoThXWju5rNTprcwHc1zq2c,1012
264
264
  osbot_utils/utils/Dev.py,sha256=HibpQutYy_iG8gGV8g1GztxNN4l29E4Bi7UZaVL6-L8,1203
265
- osbot_utils/utils/Env.py,sha256=_7SV5Jor7-GoMggYcwZflTO5D3eQKPvh73FXzC_fyGc,4858
265
+ osbot_utils/utils/Env.py,sha256=pVKv_vJn0CU0DW6rj5hv5cfI2vupQZFptloSiaGjd8Y,4903
266
266
  osbot_utils/utils/Exceptions.py,sha256=KyOUHkXQ_6jDTq04Xm261dbEZuRidtsM4dgzNwSG8-8,389
267
- osbot_utils/utils/Files.py,sha256=HRMdDq1ZctDfCkIfuZGgQ3fG6O03qJEFEIkb8HTYzfU,19407
267
+ osbot_utils/utils/Files.py,sha256=q4_JeNWZygM8T0_frpTGvZjtISC1ZyJTOr3bD9pCKUE,19599
268
268
  osbot_utils/utils/Functions.py,sha256=0E6alPJ0fJpBiJgFOWooCOi265wSRyxxXAJ5CELBnso,3498
269
269
  osbot_utils/utils/Http.py,sha256=Z8V149M2HDrKBoXkDD5EXgqTGx6vQoUqXugXK__wcuw,4572
270
270
  osbot_utils/utils/Int.py,sha256=PmlUdU4lSwf4gJdmTVdqclulkEp7KPCVUDO6AcISMF4,116
@@ -282,8 +282,8 @@ osbot_utils/utils/Toml.py,sha256=-bg9srF7ef31UCNFa0aL3CDeDKp14XeUVwRMQzMb_dI,107
282
282
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
283
283
  osbot_utils/utils/Zip.py,sha256=YFahdBguVK71mLdYy4m7mqVAQ5al-60QnTmYK-txCfY,6784
284
284
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
285
- osbot_utils/version,sha256=z7NTPYmQ0L2Y8UsRZopbRpNKn5uryAcux3sKpD_TKh0,8
286
- osbot_utils-1.22.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
287
- osbot_utils-1.22.0.dist-info/METADATA,sha256=iNHC9Qu30A7DwLcvMTVwBkWT_EHdzVUYP4XXooShCKI,1266
288
- osbot_utils-1.22.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
289
- osbot_utils-1.22.0.dist-info/RECORD,,
285
+ osbot_utils/version,sha256=53VeZ9pdur3uOW0jZ0xgOrWe1NDomr_JWgbBLtChg_g,8
286
+ osbot_utils-1.23.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
287
+ osbot_utils-1.23.0.dist-info/METADATA,sha256=6nl1O4DPerXYoazuL2vLDMJx4FjQNzvFPxKuLuSvImE,1266
288
+ osbot_utils-1.23.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
289
+ osbot_utils-1.23.0.dist-info/RECORD,,