addftool 0.2.11__py3-none-any.whl → 0.2.13__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.
addftool/addf_portal.py CHANGED
@@ -7,9 +7,28 @@ from addftool.sleep import add_sleep_args, sleep_main
7
7
 
8
8
  from addftool.blob import add_blob_args, blob_main
9
9
 
10
+ # Import version information
11
+ try:
12
+ from importlib.metadata import version
13
+ __version__ = version("addftool")
14
+ except ImportError:
15
+ # Fallback for older Python versions
16
+ import pkg_resources
17
+ __version__ = pkg_resources.get_distribution("addftool").version
18
+ except:
19
+ # Fallback if package is not installed
20
+ __version__ = "0.2.11" # Keep in sync with pyproject.toml
21
+
10
22
 
11
23
  def get_args():
12
24
  parser = argparse.ArgumentParser(description="Addf's tool")
25
+
26
+ # Add version argument
27
+ parser.add_argument(
28
+ '--version', '-v',
29
+ action='version',
30
+ version=f'addftool {__version__}'
31
+ )
13
32
 
14
33
  subparsers = parser.add_subparsers(dest='command', help='Sub-command help')
15
34
  add_killer_args(subparsers)
addftool/blob.py CHANGED
@@ -240,7 +240,7 @@ def parse_sas_token_from_blobfuse_config(config_file):
240
240
  with open(config_file, 'r') as f:
241
241
  try:
242
242
  config = yaml.safe_load(f)
243
- if 'sas' in config["azstorage"]:
243
+ if 'sas' in config["azstorage"] and config["azstorage"]['mode'] == 'sas':
244
244
  sas_token = config['azstorage']['sas']
245
245
  if 'account-name' in config["azstorage"]:
246
246
  account_name = config['azstorage']['account-name']
@@ -299,7 +299,7 @@ def update_blobfuse2_config(config_file, api_url, key, hour_threshold=48, view=F
299
299
  is_success = False
300
300
  try:
301
301
  sas_token, blob_url, expiry_time = parse_sas_token_from_blobfuse_config(config_file)
302
- if view:
302
+ if view and blob_url is not None:
303
303
  print(f"{blob_url} expiry time: {expiry_time}")
304
304
  return False
305
305
  if expiry_time is not None:
@@ -315,7 +315,7 @@ def update_blobfuse2_config(config_file, api_url, key, hour_threshold=48, view=F
315
315
  return is_success
316
316
 
317
317
 
318
- def refresh_all_blobfuse2_configs(api_url, key, hour_threshold=48, view=False):
318
+ def refresh_all_blobfuse2_configs(api_url, key, hour_threshold=48, view=False, selected_mount_paths=None):
319
319
  from addftool.process.utils import get_processes
320
320
  if not view:
321
321
  assert api_url is not None and key is not None, "api url and key must be provided when not in view mode"
@@ -326,7 +326,11 @@ def refresh_all_blobfuse2_configs(api_url, key, hour_threshold=48, view=False):
326
326
  if arg.startswith("--config-file="):
327
327
  config_file = arg.split("=", 1)[1]
328
328
  break
329
-
329
+ if selected_mount_paths is not None and config_file is not None:
330
+ mount_path = proc['command'][2]
331
+ # print(f"mount_path: {mount_path}, selected_mount_paths: {selected_mount_paths}")
332
+ if mount_path not in selected_mount_paths:
333
+ continue
330
334
  if config_file is not None:
331
335
  state = update_blobfuse2_config(config_file, api_url, key, hour_threshold=hour_threshold, view=view)
332
336
  if state:
@@ -334,7 +338,21 @@ def refresh_all_blobfuse2_configs(api_url, key, hour_threshold=48, view=False):
334
338
 
335
339
 
336
340
  def refresh_main(args):
337
- refresh_all_blobfuse2_configs(args.api, args.key, hour_threshold=args.hour_threshold, view=args.view)
341
+ # only update current user's blobfuse2 configs
342
+ selected_mount_paths = []
343
+ # df -h | grep blobfuse2
344
+ current_user_file_systems = os.popen("df -h | grep blobfuse2").readlines()
345
+ for line in current_user_file_systems:
346
+ parts = line.split()
347
+ if len(parts) >= 6:
348
+ mount_path = parts[5]
349
+ selected_mount_paths.append(mount_path)
350
+
351
+ print(f"selected_mount_paths for current user: {selected_mount_paths}")
352
+ refresh_all_blobfuse2_configs(
353
+ args.api, args.key, hour_threshold=args.hour_threshold,
354
+ view=args.view, selected_mount_paths=selected_mount_paths,
355
+ )
338
356
 
339
357
 
340
358
  def add_args(parser):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: addftool
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Requires-Dist: cryptography
5
5
  Requires-Dist: requests
6
6
  Requires-Dist: PyYAML
@@ -1,6 +1,6 @@
1
1
  addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- addftool/addf_portal.py,sha256=vc8opPzValNFPwJne5C5LbZvgcJ0eMBJSWDSiM23OPM,1274
3
- addftool/blob.py,sha256=IwDvXAkHurFWOGPdfn2HSeTPXAc5E7Nwc_cR68vOZXs,14133
2
+ addftool/addf_portal.py,sha256=CnOAq3JLQjK9-OyYWDYcmtLBM68L3N6WeP5NjBod4zc,1819
3
+ addftool/blob.py,sha256=prGpDy_esyBL53a5R3yVJdGiXQSPFuU4is1yM9dp2qo,15037
4
4
  addftool/broadcast_folder.py,sha256=GQBuSL8Ch537V_fSBHesWyqT3KRYry68pbYOKy2bDj4,19619
5
5
  addftool/sleep.py,sha256=kykcZR2tA0ZpRUwQf6IIUdJ4dYkolyD91FdriViq9Nc,11771
6
6
  addftool/sync.py,sha256=ZpYxbM8uiPFrV7ODmOaM7asVPCWaxBixA-arVc-1kfs,14045
@@ -13,8 +13,8 @@ addftool/deploy/vscode_server.py,sha256=tLtSvlcK2fEOaw6udWt8dNELVhwv9F59hF5DJJ-1
13
13
  addftool/process/__init__.py,sha256=Dze8OrcyjQlAbPrjE_h8bMi8W4b3OJyZOjTucPrkJvM,3721
14
14
  addftool/process/utils.py,sha256=JldxnwanLJOgxaPgmCJh7SeBRaaj5rFxWWxh1hpsvbA,2609
15
15
  addftool/ssh/__init__.py,sha256=h5_rCO0A6q2Yw9vFguQZZp_ApAJsT1dcnKnbKKZ0cDM,4409
16
- addftool-0.2.11.dist-info/METADATA,sha256=0A9h1LjUl8cX-fkqYrVcwpSrJB4J3m9IPVnEziheAwI,221
17
- addftool-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- addftool-0.2.11.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
19
- addftool-0.2.11.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
20
- addftool-0.2.11.dist-info/RECORD,,
16
+ addftool-0.2.13.dist-info/METADATA,sha256=C8_l-dQvZoQ8gkxbP86PYJsfAHzjNiMhBW5lCtq8rCI,221
17
+ addftool-0.2.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ addftool-0.2.13.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
19
+ addftool-0.2.13.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
20
+ addftool-0.2.13.dist-info/RECORD,,