dmart 1.4.40.post25__py3-none-any.whl → 1.4.40.post26__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.
dmart/__init__.py CHANGED
@@ -1 +1 @@
1
- from .dmart import main
1
+ from .manage import main
dmart/dmart.py CHANGED
@@ -13,9 +13,14 @@ import time
13
13
  import warnings
14
14
  import webbrowser
15
15
  import re
16
+ # from multiprocessing import freeze_support
16
17
  from pathlib import Path
17
- from multiprocessing import freeze_support
18
18
 
19
+ from hypercorn.config import Config
20
+ from hypercorn.run import run
21
+ from utils.settings import settings
22
+
23
+ # freeze_support()
19
24
 
20
25
  commands = """
21
26
  serve
@@ -40,13 +45,13 @@ commands = """
40
45
  sentinel = object()
41
46
 
42
47
 
43
- def hypercorn_main(args_list: list[str]) -> int:
48
+ def hypercorn_main() -> int:
44
49
  parser = argparse.ArgumentParser()
45
50
  parser.add_argument(
46
51
  "application",
47
52
  help="The application to dispatch to as path.to.module:instance.path",
48
53
  nargs="?",
49
- default="dmart.main:app"
54
+ default="main:app"
50
55
  )
51
56
  parser.add_argument("--access-log", help="Deprecated, see access-logfile", default=sentinel)
52
57
  parser.add_argument(
@@ -246,41 +251,8 @@ def hypercorn_main(args_list: list[str]) -> int:
246
251
  default=sentinel,
247
252
  type=int,
248
253
  )
249
- args = parser.parse_args(args_list)
250
-
251
- # Allow child processes to find the application
252
- dmart_dir = os.path.dirname(os.path.abspath(__file__))
253
- dmart_pkg_parent = os.path.dirname(dmart_dir)
254
-
255
- # Ensure dmart_pkg_parent is in sys.path
256
- if dmart_pkg_parent not in sys.path:
257
- sys.path.insert(0, dmart_pkg_parent)
254
+ args = parser.parse_args(sys.argv[1:])
258
255
 
259
- # Ensure dmart_dir itself is NOT in sys.path to avoid module/package conflict
260
- if dmart_dir in sys.path:
261
- sys.path.remove(dmart_dir)
262
-
263
- # If 'dmart' was imported as a module (due to shadowing), remove it
264
- if "dmart" in sys.modules:
265
- dmart_mod = sys.modules["dmart"]
266
- if not hasattr(dmart_mod, "__path__"):
267
- del sys.modules["dmart"]
268
-
269
- # Handle the case where we are running from source and 'dmart' package is not available
270
- # but the current directory contains 'main.py'
271
- try:
272
- from dmart import main as _unused
273
- except ImportError:
274
- if os.path.exists(os.path.join(dmart_dir, "main.py")):
275
- if dmart_dir not in sys.path:
276
- sys.path.insert(0, dmart_dir)
277
- if args.application == "dmart.main:app":
278
- args.application = "main:app"
279
-
280
- from hypercorn.config import Config
281
- from hypercorn.run import run
282
- from dmart.utils.settings import settings
283
-
284
256
  if args.config == "hypercorn_config.toml" and not os.path.exists(args.config):
285
257
  config = Config()
286
258
  config.backlog = 2000
@@ -434,47 +406,23 @@ def print_formatted(data):
434
406
 
435
407
 
436
408
  def main():
437
- # Allow processes to find the dmart package
438
- dmart_dir = os.path.dirname(os.path.abspath(__file__))
439
- dmart_pkg_parent = os.path.dirname(dmart_dir)
440
-
441
- if dmart_pkg_parent not in sys.path:
442
- sys.path.insert(0, dmart_pkg_parent)
443
-
444
- if dmart_dir in sys.path:
445
- sys.path.remove(dmart_dir)
446
-
447
- if "" in sys.path:
448
- sys.path.remove("")
449
-
450
- # If 'dmart' was imported as a module (due to shadowing), remove it
451
- # so it can be correctly imported as a package from the fixed sys.path
452
- if "dmart" in sys.modules:
453
- dmart_mod = sys.modules["dmart"]
454
- if not hasattr(dmart_mod, "__path__"):
455
- del sys.modules["dmart"]
456
-
457
- if len(sys.argv) < 2:
409
+ sys.argv = sys.argv[1:]
410
+ if len(sys.argv) == 0:
458
411
  print("You must provide a command to run:")
459
412
  print(commands)
460
413
  sys.exit(1)
461
414
 
462
- command = sys.argv[1]
463
- args_list = sys.argv[2:]
464
-
465
- match command:
415
+ match sys.argv[0]:
466
416
  case "hyper":
467
- from multiprocessing import freeze_support
468
- freeze_support()
469
- hypercorn_main(args_list)
417
+ hypercorn_main()
470
418
  case "cli":
471
419
  config_file = None
472
- if "--config" in args_list:
473
- idx = args_list.index("--config")
474
- if idx + 1 < len(args_list):
475
- config_file = args_list[idx + 1]
476
- args_list.pop(idx + 1)
477
- args_list.pop(idx)
420
+ if "--config" in sys.argv:
421
+ idx = sys.argv.index("--config")
422
+ if idx + 1 < len(sys.argv):
423
+ config_file = sys.argv[idx + 1]
424
+ sys.argv.pop(idx + 1)
425
+ sys.argv.pop(idx)
478
426
 
479
427
  if not config_file:
480
428
  if os.path.exists("cli.ini"):
@@ -532,7 +480,10 @@ def main():
532
480
 
533
481
  last_import_error = None
534
482
  try:
535
- from dmart import cli # type: ignore
483
+ dmart_dir = Path(__file__).resolve().parent
484
+ if str(dmart_dir) not in sys.path:
485
+ sys.path.append(str(dmart_dir))
486
+ import cli # type: ignore
536
487
  cli.main()
537
488
  return
538
489
  except ImportError as e:
@@ -566,19 +517,17 @@ def main():
566
517
  print("Error: cli.py not found.")
567
518
  sys.exit(1)
568
519
  case "serve":
569
- from dmart.utils.settings import settings
570
- from dmart.main import main as server
571
520
  open_cxb = False
572
- if "--open-cxb" in args_list:
521
+ if "--open-cxb" in sys.argv:
573
522
  open_cxb = True
574
- args_list.remove("--open-cxb")
523
+ sys.argv.remove("--open-cxb")
575
524
 
576
- if "--cxb-config" in args_list:
577
- idx = args_list.index("--cxb-config")
578
- if idx + 1 < len(args_list):
579
- os.environ["DMART_CXB_CONFIG"] = args_list[idx + 1]
580
- args_list.pop(idx + 1)
581
- args_list.pop(idx)
525
+ if "--cxb-config" in sys.argv:
526
+ idx = sys.argv.index("--cxb-config")
527
+ if idx + 1 < len(sys.argv):
528
+ os.environ["DMART_CXB_CONFIG"] = sys.argv[idx + 1]
529
+ sys.argv.pop(idx + 1)
530
+ sys.argv.pop(idx)
582
531
 
583
532
  if open_cxb:
584
533
  host = settings.listening_host
@@ -592,9 +541,10 @@ def main():
592
541
  import threading
593
542
  threading.Thread(target=open_browser, daemon=True).start()
594
543
 
544
+ from main import main as server
595
545
  asyncio.run(server())
596
546
  case "health-check":
597
- from dmart.data_adapters.file.health_check import main as health_check
547
+ from data_adapters.file.health_check import main as health_check
598
548
  parser = argparse.ArgumentParser(
599
549
  description="This created for doing health check functionality",
600
550
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -608,7 +558,7 @@ def main():
608
558
  asyncio.run(health_check(args.type, args.space, args.schemas))
609
559
  print(f'total time: {"{:.2f}".format(time.time() - before_time)} sec')
610
560
  case "create-index":
611
- from dmart.data_adapters.file.create_index import main as create_index
561
+ from data_adapters.file.create_index import main as create_index
612
562
  parser = argparse.ArgumentParser(
613
563
  description="Recreate Redis indices based on the available schema definitions",
614
564
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -628,7 +578,7 @@ def main():
628
578
 
629
579
  asyncio.run(create_index(args.space, args.schemas, args.subpaths, args.flushall))
630
580
  case "export":
631
- from dmart.utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
581
+ from utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
632
582
  parser = argparse.ArgumentParser()
633
583
  parser.add_argument(
634
584
  "--config", required=True, help="Json config relative path from the script"
@@ -681,12 +631,11 @@ def main():
681
631
  f"Output path: {os.path.abspath(os.path.join(output_path, OUTPUT_FOLDER_NAME))}"
682
632
  )
683
633
  case "settings":
684
- from dmart.utils.settings import settings
685
634
  print_formatted(settings.model_dump_json())
686
635
  case "set_password":
687
- from dmart import set_admin_passwd # noqa: F401
636
+ import set_admin_passwd # noqa: F401
688
637
  case "archive":
689
- from dmart.data_adapters.file.archive import archive
638
+ from data_adapters.file.archive import archive
690
639
  parser = argparse.ArgumentParser(
691
640
  description="Script for archiving records from different spaces and subpaths."
692
641
  )
@@ -713,10 +662,10 @@ def main():
713
662
  asyncio.run(archive(space, subpath, schema, olderthan))
714
663
  print("Done.")
715
664
  case "json_to_db":
716
- from dmart.data_adapters.sql.json_to_db_migration import main as json_to_db_migration
665
+ from data_adapters.sql.json_to_db_migration import main as json_to_db_migration
717
666
  asyncio.run(json_to_db_migration())
718
667
  case "db_to_json":
719
- from dmart.data_adapters.sql.db_to_json_migration import main as db_to_json_migration
668
+ from data_adapters.sql.db_to_json_migration import main as db_to_json_migration
720
669
  db_to_json_migration()
721
670
  case "help":
722
671
  print("Available commands:")
@@ -787,7 +736,6 @@ def main():
787
736
  import configparser
788
737
  import tempfile
789
738
 
790
- from dmart.utils.settings import settings
791
739
  dmart_root = Path(__file__).resolve().parent
792
740
  alembic_ini_path = dmart_root / "alembic.ini"
793
741
 
@@ -805,7 +753,7 @@ def main():
805
753
 
806
754
  config.set('alembic', 'sqlalchemy.url', db_url)
807
755
  config.set('alembic', 'script_location', str(dmart_root / "alembic"))
808
- config.set('alembic', 'prepend_sys_path', os.path.dirname(dmart_root))
756
+ config.set('alembic', 'prepend_sys_path', str(dmart_root))
809
757
 
810
758
  temp_config_path = ""
811
759
  try:
@@ -813,7 +761,7 @@ def main():
813
761
  config.write(temp_config_file)
814
762
  temp_config_path = temp_config_file.name
815
763
 
816
- alembic_cli_args = args_list
764
+ alembic_cli_args = sys.argv[1:]
817
765
  if not alembic_cli_args:
818
766
  alembic_cli_args = ["upgrade", "head"]
819
767
 
@@ -868,5 +816,4 @@ def main():
868
816
  sys.exit(e.returncode)
869
817
 
870
818
  if __name__ == "__main__":
871
- freeze_support()
872
819
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dmart
3
- Version: 1.4.40.post25
3
+ Version: 1.4.40.post26
4
4
  Requires-Python: >=3.11
5
5
  Requires-Dist: fastapi
6
6
  Requires-Dist: pydantic
@@ -1,4 +1,4 @@
1
- dmart/__init__.py,sha256=XLCEy3hrSIEPcq-9ChqtUx5-_jLFAvsbY4AJXGD-KyE,24
1
+ dmart/__init__.py,sha256=cpaLjFNvudcPHfaUJHWQCWThrQeZTttlzC2YU3gCAQ4,25
2
2
  dmart/alembic.ini,sha256=wQweByyHQm-EI8BQkE0SHNRjULJ6Xn5jqgvv88IT5Sg,3738
3
3
  dmart/bundler.py,sha256=so8ZJResb1PcOH5vboa_mpFAdYr_T8u8DbbFXd570Lg,1704
4
4
  dmart/cli.py,sha256=TkZVc0bDT32nXJxNd_ZVqwKaq6pbMUOXxYRXfEaKYSI,41611
@@ -8,7 +8,7 @@ dmart/conftest.py,sha256=0ry_zeCmdBNLbm5q115b-pkOrUFYxdsOUXbIMkr7E5Y,362
8
8
  dmart/curl.pypi.sh,sha256=KQ-kgV3_d5mwqoLd4XOwz5s2wRQ7LDVX3z-kvjvp9hA,15631
9
9
  dmart/curl.sh,sha256=lmHSFVr5ft-lc5Aq9LfvKyWfntrfYbnirhzx1EGjp_A,15743
10
10
  dmart/data_generator.py,sha256=CnE-VHEeX7-lAXtqCgbRqR9WHjTuOgeiZcviYrHAmho,2287
11
- dmart/dmart.py,sha256=5ACm3MWKltX-dP4cVz8jp6UpLVfcVGGOHtCcUdVLeZA,34135
11
+ dmart/dmart.py,sha256=SeFQl1TOOZuhJOhvEg0Hzgk5k93VGdpS3v_0JOAIg7g,32061
12
12
  dmart/get_settings.py,sha256=Sbe2WCoiK398E7HY4SNLfDN_GmE8knR4M-YJWF31jcg,153
13
13
  dmart/hypercorn_config.toml,sha256=-eryppEG8HBOM_KbFc4dTQePnpyfoW9ZG5aUATU_6yM,50
14
14
  dmart/info.json,sha256=WlfNSLMtm-sATS1PPvWR_HnLUj1XYxzHK4lKZZAPBQg,123
@@ -483,8 +483,8 @@ dmart/utils/ticket_sys_utils.py,sha256=9QAlW2iiy8KyxQRBDj_WmzS5kKb0aYJmGwd4qzmGV
483
483
  dmart/utils/web_notifier.py,sha256=QM87VVid2grC5lK3NdS1yzz0z1wXljr4GChJOeK86W4,843
484
484
  dmart/utils/templates/activation.html.j2,sha256=XAMKCdoqONoc4ZQucD0yV-Pg5DlHHASZrTVItNS-iBE,640
485
485
  dmart/utils/templates/reminder.html.j2,sha256=aoS8bTs56q4hjAZKsb0jV9c-PIURBELuBOpT_qPZNVU,639
486
- dmart-1.4.40.post25.dist-info/METADATA,sha256=gBzkUyi1bPDcdZImq7jmPL9ZYQdnmUBcS6B62id6r7s,839
487
- dmart-1.4.40.post25.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
488
- dmart-1.4.40.post25.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
489
- dmart-1.4.40.post25.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
490
- dmart-1.4.40.post25.dist-info/RECORD,,
486
+ dmart-1.4.40.post26.dist-info/METADATA,sha256=4-f6W27ax_gsqyCdQWVqWFkdnWAH2MwQVZhiaBdUy5o,839
487
+ dmart-1.4.40.post26.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
488
+ dmart-1.4.40.post26.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
489
+ dmart-1.4.40.post26.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
490
+ dmart-1.4.40.post26.dist-info/RECORD,,