dmart 1.4.19__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.19
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=xaWzoI7xbSizlBD5Cu27FxeERJ7O69I-HZGGBQ5ucfA,24352
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.19.dist-info/METADATA,sha256=fvC35gtYzj_QldMMoGBbBnWYuKZo_hrY87dBTygXgzE,2149
276
- dmart-1.4.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
277
- dmart-1.4.19.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
278
- dmart-1.4.19.dist-info/top_level.txt,sha256=S-gfX1pLerapNXiHZ8lvPYoV7sgwSX2_NCZ6xfzDUHM,267
279
- dmart-1.4.19.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
@@ -19,7 +19,9 @@ from hypercorn.config import Config
19
19
  from hypercorn.run import run
20
20
 
21
21
  try:
22
+ # Try to import alembic
22
23
  import alembic
24
+
23
25
  # Check if we are importing the local alembic directory which is likely a leftover
24
26
  if hasattr(alembic, '__path__'):
25
27
  local_alembic_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'alembic'))
@@ -31,7 +33,6 @@ try:
31
33
  try:
32
34
  shutil.rmtree(p)
33
35
  # Force reload
34
- import sys
35
36
  if 'alembic' in sys.modules:
36
37
  del sys.modules['alembic']
37
38
  import alembic
@@ -411,27 +412,43 @@ def hypercorn_main() -> int:
411
412
 
412
413
 
413
414
  def main():
414
- sys.argv = sys.argv[1:]
415
- 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:
416
433
  print("You must provide a command to run:")
417
434
  print(commands)
418
435
  sys.exit(1)
419
436
 
420
- match sys.argv[0]:
437
+ match args[0]:
421
438
  case "hyper":
422
439
  hypercorn_main()
423
440
  case "server" | "serve":
424
441
  open_cxb = False
425
- if "--open-cxb" in sys.argv:
442
+ if "--open-cxb" in args:
426
443
  open_cxb = True
427
- sys.argv.remove("--open-cxb")
444
+ args.remove("--open-cxb")
428
445
 
429
- if "--cxb-config" in sys.argv:
430
- idx = sys.argv.index("--cxb-config")
431
- if idx + 1 < len(sys.argv):
432
- os.environ["DMART_CXB_CONFIG"] = sys.argv[idx + 1]
433
- sys.argv.pop(idx + 1)
434
- 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)
435
452
 
436
453
  if open_cxb:
437
454
  url = f"http://{settings.listening_host}:{settings.listening_port}/cxb/"
@@ -442,6 +459,11 @@ def main():
442
459
  import threading
443
460
  threading.Thread(target=open_browser, daemon=True).start()
444
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
445
467
  asyncio.run(server())
446
468
  case "health-check":
447
469
  parser = argparse.ArgumentParser(
@@ -452,9 +474,10 @@ def main():
452
474
  parser.add_argument("-s", "--space", help="hit the target space or pass (all) to make the full health check")
453
475
  parser.add_argument("-m", "--schemas", nargs="*", help="hit the target schema inside the space")
454
476
 
455
- 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:])
456
479
  before_time = time.time()
457
- asyncio.run(health_check(args.type, args.space, args.schemas))
480
+ asyncio.run(health_check(args_parsed.type, args_parsed.space, args_parsed.schemas))
458
481
  print(f'total time: {"{:.2f}".format(time.time() - before_time)} sec')
459
482
  case "create-index":
460
483
  parser = argparse.ArgumentParser(
@@ -472,9 +495,9 @@ def main():
472
495
  "--flushall", action='store_true', help="FLUSHALL data on Redis"
473
496
  )
474
497
 
475
- args = parser.parse_args()
498
+ args_parsed = parser.parse_args(args[1:])
476
499
 
477
- 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))
478
501
  case "export":
479
502
  parser = argparse.ArgumentParser()
480
503
  parser.add_argument(
@@ -491,24 +514,24 @@ def main():
491
514
  "--since",
492
515
  help="Export entries created/updated since the provided timestamp",
493
516
  )
494
- args = parser.parse_args()
517
+ args_parsed = parser.parse_args(args[1:])
495
518
  since = None
496
519
  output_path = ""
497
- if args.output:
498
- output_path = args.output
520
+ if args_parsed.output:
521
+ output_path = args_parsed.output
499
522
 
500
- if args.since:
501
- since = int(round(float(args.since) * 1000))
523
+ if args_parsed.since:
524
+ since = int(round(float(args_parsed.since) * 1000))
502
525
 
503
- if not os.path.isdir(args.spaces):
504
- 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.")
505
528
 
506
529
  out_path = os.path.join(output_path, OUTPUT_FOLDER_NAME)
507
530
  if os.path.isdir(out_path):
508
531
  shutil.rmtree(out_path)
509
532
 
510
533
  tasks = []
511
- with open(args.config, "r") as f:
534
+ with open(args_parsed.config, "r") as f:
512
535
  config_objs = json.load(f)
513
536
 
514
537
  for config_obj in config_objs:
@@ -520,7 +543,7 @@ def main():
520
543
  config_obj.get("schema_shortname", ""),
521
544
  config_obj.get("included_meta_fields", {}),
522
545
  config_obj.get("excluded_payload_fields", {}),
523
- args.spaces, output_path, since))
546
+ args_parsed.spaces, output_path, since))
524
547
 
525
548
  asyncio.run(exporter(tasks))
526
549
 
@@ -549,11 +572,11 @@ def main():
549
572
  help="The number of day, older than which, the entries will be archived (based on updated_at)",
550
573
  )
551
574
 
552
- args = parser.parse_args()
553
- space = args.space
554
- subpath = args.subpath
555
- olderthan = args.olderthan
556
- 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"
557
580
 
558
581
  asyncio.run(archive(space, subpath, schema, olderthan))
559
582
  print("Done.")
@@ -584,6 +607,8 @@ def main():
584
607
  print("Error: 'alembic' library not found. Please install it with 'pip install alembic'.")
585
608
  if ALEMBIC_ERROR:
586
609
  print(f"Details: {ALEMBIC_ERROR}")
610
+ print(f"Python executable: {sys.executable}")
611
+ print(f"sys.path: {sys.path}")
587
612
  sys.exit(1)
588
613
 
589
614
  alembic_cfg = AlembicConfig(str(original_ini_path))
File without changes