dmart 1.4.20__py3-none-any.whl → 1.4.21__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dmart
3
- Version: 1.4.20
3
+ Version: 1.4.21
4
4
  Requires-Python: >=3.11
5
5
  Requires-Dist: fastapi
6
6
  Requires-Dist: pydantic
@@ -1,6 +1,6 @@
1
1
  bundler.py,sha256=MDTUTVS0WL7gb-i1rDcS4i37KTqaW88TluL4L3rwjRw,1817
2
2
  data_generator.py,sha256=CnE-VHEeX7-lAXtqCgbRqR9WHjTuOgeiZcviYrHAmho,2287
3
- dmart.py,sha256=mG4TCkITYoUajlHsPJ_BZUBMu2G8gxvB7bidYfKoSHA,24498
3
+ dmart.py,sha256=p5fLlsAoCtT9-2J34y8BE6vhkC5gHdXL9mc6nkAZGFQ,26230
4
4
  get_settings.py,sha256=Sbe2WCoiK398E7HY4SNLfDN_GmE8knR4M-YJWF31jcg,153
5
5
  info.json,sha256=hXQWl19lfMkEj_zXdehGeKjiKGNJ7emY4S7d4pIqJ1E,123
6
6
  main.py,sha256=KZGhIL6AnEm5ZAPy4IvhBDpzSTjuodilV7NafNOyhzM,19676
@@ -272,8 +272,8 @@ utils/ticket_sys_utils.py,sha256=9QAlW2iiy8KyxQRBDj_WmzS5kKb0aYJmGwd4qzmGVqo,700
272
272
  utils/web_notifier.py,sha256=QM87VVid2grC5lK3NdS1yzz0z1wXljr4GChJOeK86W4,843
273
273
  utils/templates/activation.html.j2,sha256=XAMKCdoqONoc4ZQucD0yV-Pg5DlHHASZrTVItNS-iBE,640
274
274
  utils/templates/reminder.html.j2,sha256=aoS8bTs56q4hjAZKsb0jV9c-PIURBELuBOpT_qPZNVU,639
275
- dmart-1.4.20.dist-info/METADATA,sha256=MTGSY6tBlgUmFtLj4RP40CIZbMsFGbMGG2Jo41hv_hY,2149
276
- dmart-1.4.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
277
- dmart-1.4.20.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
278
- dmart-1.4.20.dist-info/top_level.txt,sha256=S-gfX1pLerapNXiHZ8lvPYoV7sgwSX2_NCZ6xfzDUHM,267
279
- dmart-1.4.20.dist-info/RECORD,,
275
+ dmart-1.4.21.dist-info/METADATA,sha256=tHgxO-v_yePlbzxXCXfIjDv8ubvItn2SkEBpgAPachk,2149
276
+ dmart-1.4.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
277
+ dmart-1.4.21.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
278
+ dmart-1.4.21.dist-info/top_level.txt,sha256=S-gfX1pLerapNXiHZ8lvPYoV7sgwSX2_NCZ6xfzDUHM,267
279
+ dmart-1.4.21.dist-info/RECORD,,
dmart.py CHANGED
@@ -412,27 +412,43 @@ def hypercorn_main() -> int:
412
412
 
413
413
 
414
414
  def main():
415
- sys.argv = sys.argv[1:]
416
- if len(sys.argv) == 0:
415
+ # Use sys.argv directly instead of modifying it in place which might be confusing
416
+ # But to fix the UnboundLocalError, we just need to refer to the global sys module
417
+ # The error happens because we're assigning to sys.argv, making python think sys is local
418
+ # but we haven't imported it in this scope (it's imported at module level)
419
+ # However, in Python, module-level imports are available in functions.
420
+ # The issue is likely that we are assigning to sys.argv, which makes Python treat 'sys' as a local variable
421
+ # But wait, sys is imported at the top.
422
+ # Actually, the error "UnboundLocalError: cannot access local variable 'sys' where it is not associated with a value"
423
+ # suggests that there might be a local variable named 'sys' somewhere or something weird is happening.
424
+ # Ah, I see what happened. I added "import sys" inside the try/except block in the migrate case!
425
+ # That local import shadows the global import for the whole function scope in Python 3.x due to how scoping works.
426
+
427
+ # Let's fix this by removing the local import of sys in the migrate case since it's already imported globally.
428
+
429
+ global sys
430
+
431
+ args = sys.argv[1:]
432
+ if len(args) == 0:
417
433
  print("You must provide a command to run:")
418
434
  print(commands)
419
435
  sys.exit(1)
420
436
 
421
- match sys.argv[0]:
437
+ match args[0]:
422
438
  case "hyper":
423
439
  hypercorn_main()
424
440
  case "server" | "serve":
425
441
  open_cxb = False
426
- if "--open-cxb" in sys.argv:
442
+ if "--open-cxb" in args:
427
443
  open_cxb = True
428
- sys.argv.remove("--open-cxb")
444
+ args.remove("--open-cxb")
429
445
 
430
- if "--cxb-config" in sys.argv:
431
- idx = sys.argv.index("--cxb-config")
432
- if idx + 1 < len(sys.argv):
433
- os.environ["DMART_CXB_CONFIG"] = sys.argv[idx + 1]
434
- sys.argv.pop(idx + 1)
435
- sys.argv.pop(idx)
446
+ if "--cxb-config" in args:
447
+ idx = args.index("--cxb-config")
448
+ if idx + 1 < len(args):
449
+ os.environ["DMART_CXB_CONFIG"] = args[idx + 1]
450
+ args.pop(idx + 1)
451
+ args.pop(idx)
436
452
 
437
453
  if open_cxb:
438
454
  url = f"http://{settings.listening_host}:{settings.listening_port}/cxb/"
@@ -443,6 +459,11 @@ def main():
443
459
  import threading
444
460
  threading.Thread(target=open_browser, daemon=True).start()
445
461
 
462
+ # We need to update sys.argv for hypercorn/fastapi if they use it,
463
+ # but here we are calling asyncio.run(server()) which uses settings.
464
+ # hypercorn_main uses sys.argv, but we call it explicitly above.
465
+ # Let's just set sys.argv to the modified args just in case.
466
+ sys.argv = [sys.argv[0]] + args
446
467
  asyncio.run(server())
447
468
  case "health-check":
448
469
  parser = argparse.ArgumentParser(
@@ -453,9 +474,10 @@ def main():
453
474
  parser.add_argument("-s", "--space", help="hit the target space or pass (all) to make the full health check")
454
475
  parser.add_argument("-m", "--schemas", nargs="*", help="hit the target schema inside the space")
455
476
 
456
- args = parser.parse_args()
477
+ # parse_args defaults to sys.argv[1:], so we need to pass the relevant args
478
+ args_parsed = parser.parse_args(args[1:])
457
479
  before_time = time.time()
458
- asyncio.run(health_check(args.type, args.space, args.schemas))
480
+ asyncio.run(health_check(args_parsed.type, args_parsed.space, args_parsed.schemas))
459
481
  print(f'total time: {"{:.2f}".format(time.time() - before_time)} sec')
460
482
  case "create-index":
461
483
  parser = argparse.ArgumentParser(
@@ -473,9 +495,9 @@ def main():
473
495
  "--flushall", action='store_true', help="FLUSHALL data on Redis"
474
496
  )
475
497
 
476
- args = parser.parse_args()
498
+ args_parsed = parser.parse_args(args[1:])
477
499
 
478
- asyncio.run(create_index(args.space, args.schemas, args.subpaths, args.flushall))
500
+ asyncio.run(create_index(args_parsed.space, args_parsed.schemas, args_parsed.subpaths, args_parsed.flushall))
479
501
  case "export":
480
502
  parser = argparse.ArgumentParser()
481
503
  parser.add_argument(
@@ -492,24 +514,24 @@ def main():
492
514
  "--since",
493
515
  help="Export entries created/updated since the provided timestamp",
494
516
  )
495
- args = parser.parse_args()
517
+ args_parsed = parser.parse_args(args[1:])
496
518
  since = None
497
519
  output_path = ""
498
- if args.output:
499
- output_path = args.output
520
+ if args_parsed.output:
521
+ output_path = args_parsed.output
500
522
 
501
- if args.since:
502
- since = int(round(float(args.since) * 1000))
523
+ if args_parsed.since:
524
+ since = int(round(float(args_parsed.since) * 1000))
503
525
 
504
- if not os.path.isdir(args.spaces):
505
- exit_with_error(f"The spaces folder {args.spaces} is not found.")
526
+ if not os.path.isdir(args_parsed.spaces):
527
+ exit_with_error(f"The spaces folder {args_parsed.spaces} is not found.")
506
528
 
507
529
  out_path = os.path.join(output_path, OUTPUT_FOLDER_NAME)
508
530
  if os.path.isdir(out_path):
509
531
  shutil.rmtree(out_path)
510
532
 
511
533
  tasks = []
512
- with open(args.config, "r") as f:
534
+ with open(args_parsed.config, "r") as f:
513
535
  config_objs = json.load(f)
514
536
 
515
537
  for config_obj in config_objs:
@@ -521,7 +543,7 @@ def main():
521
543
  config_obj.get("schema_shortname", ""),
522
544
  config_obj.get("included_meta_fields", {}),
523
545
  config_obj.get("excluded_payload_fields", {}),
524
- args.spaces, output_path, since))
546
+ args_parsed.spaces, output_path, since))
525
547
 
526
548
  asyncio.run(exporter(tasks))
527
549
 
@@ -550,11 +572,11 @@ def main():
550
572
  help="The number of day, older than which, the entries will be archived (based on updated_at)",
551
573
  )
552
574
 
553
- args = parser.parse_args()
554
- space = args.space
555
- subpath = args.subpath
556
- olderthan = args.olderthan
557
- schema = args.schema or "meta"
575
+ args_parsed = parser.parse_args(args[1:])
576
+ space = args_parsed.space
577
+ subpath = args_parsed.subpath
578
+ olderthan = args_parsed.olderthan
579
+ schema = args_parsed.schema or "meta"
558
580
 
559
581
  asyncio.run(archive(space, subpath, schema, olderthan))
560
582
  print("Done.")
@@ -585,7 +607,6 @@ def main():
585
607
  print("Error: 'alembic' library not found. Please install it with 'pip install alembic'.")
586
608
  if ALEMBIC_ERROR:
587
609
  print(f"Details: {ALEMBIC_ERROR}")
588
- import sys
589
610
  print(f"Python executable: {sys.executable}")
590
611
  print(f"sys.path: {sys.path}")
591
612
  sys.exit(1)
File without changes