dmart 1.4.40.post25__py3-none-any.whl → 1.4.40.post27__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
@@ -9,13 +9,21 @@ import shutil
9
9
  import ssl
10
10
  import subprocess
11
11
  import sys
12
+ import os
13
+ sys.path.append(os.path.dirname(__file__))
14
+
12
15
  import time
13
16
  import warnings
14
17
  import webbrowser
15
18
  import re
19
+ # from multiprocessing import freeze_support
16
20
  from pathlib import Path
17
- from multiprocessing import freeze_support
18
21
 
22
+ from hypercorn.config import Config
23
+ from hypercorn.run import run
24
+ from utils.settings import settings
25
+
26
+ # freeze_support()
19
27
 
20
28
  commands = """
21
29
  serve
@@ -40,13 +48,13 @@ commands = """
40
48
  sentinel = object()
41
49
 
42
50
 
43
- def hypercorn_main(args_list: list[str]) -> int:
51
+ def hypercorn_main() -> int:
44
52
  parser = argparse.ArgumentParser()
45
53
  parser.add_argument(
46
54
  "application",
47
55
  help="The application to dispatch to as path.to.module:instance.path",
48
56
  nargs="?",
49
- default="dmart.main:app"
57
+ default="main:app"
50
58
  )
51
59
  parser.add_argument("--access-log", help="Deprecated, see access-logfile", default=sentinel)
52
60
  parser.add_argument(
@@ -246,41 +254,8 @@ def hypercorn_main(args_list: list[str]) -> int:
246
254
  default=sentinel,
247
255
  type=int,
248
256
  )
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)
258
-
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"]
257
+ args = parser.parse_args(sys.argv[1:])
268
258
 
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
259
  if args.config == "hypercorn_config.toml" and not os.path.exists(args.config):
285
260
  config = Config()
286
261
  config.backlog = 2000
@@ -434,47 +409,23 @@ def print_formatted(data):
434
409
 
435
410
 
436
411
  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:
412
+ sys.argv = sys.argv[1:]
413
+ if len(sys.argv) == 0:
458
414
  print("You must provide a command to run:")
459
415
  print(commands)
460
416
  sys.exit(1)
461
417
 
462
- command = sys.argv[1]
463
- args_list = sys.argv[2:]
464
-
465
- match command:
418
+ match sys.argv[0]:
466
419
  case "hyper":
467
- from multiprocessing import freeze_support
468
- freeze_support()
469
- hypercorn_main(args_list)
420
+ hypercorn_main()
470
421
  case "cli":
471
422
  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)
423
+ if "--config" in sys.argv:
424
+ idx = sys.argv.index("--config")
425
+ if idx + 1 < len(sys.argv):
426
+ config_file = sys.argv[idx + 1]
427
+ sys.argv.pop(idx + 1)
428
+ sys.argv.pop(idx)
478
429
 
479
430
  if not config_file:
480
431
  if os.path.exists("cli.ini"):
@@ -532,7 +483,10 @@ def main():
532
483
 
533
484
  last_import_error = None
534
485
  try:
535
- from dmart import cli # type: ignore
486
+ dmart_dir = Path(__file__).resolve().parent
487
+ if str(dmart_dir) not in sys.path:
488
+ sys.path.append(str(dmart_dir))
489
+ import cli # type: ignore
536
490
  cli.main()
537
491
  return
538
492
  except ImportError as e:
@@ -566,19 +520,17 @@ def main():
566
520
  print("Error: cli.py not found.")
567
521
  sys.exit(1)
568
522
  case "serve":
569
- from dmart.utils.settings import settings
570
- from dmart.main import main as server
571
523
  open_cxb = False
572
- if "--open-cxb" in args_list:
524
+ if "--open-cxb" in sys.argv:
573
525
  open_cxb = True
574
- args_list.remove("--open-cxb")
526
+ sys.argv.remove("--open-cxb")
575
527
 
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)
528
+ if "--cxb-config" in sys.argv:
529
+ idx = sys.argv.index("--cxb-config")
530
+ if idx + 1 < len(sys.argv):
531
+ os.environ["DMART_CXB_CONFIG"] = sys.argv[idx + 1]
532
+ sys.argv.pop(idx + 1)
533
+ sys.argv.pop(idx)
582
534
 
583
535
  if open_cxb:
584
536
  host = settings.listening_host
@@ -592,9 +544,10 @@ def main():
592
544
  import threading
593
545
  threading.Thread(target=open_browser, daemon=True).start()
594
546
 
547
+ from main import main as server
595
548
  asyncio.run(server())
596
549
  case "health-check":
597
- from dmart.data_adapters.file.health_check import main as health_check
550
+ from data_adapters.file.health_check import main as health_check
598
551
  parser = argparse.ArgumentParser(
599
552
  description="This created for doing health check functionality",
600
553
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -608,7 +561,7 @@ def main():
608
561
  asyncio.run(health_check(args.type, args.space, args.schemas))
609
562
  print(f'total time: {"{:.2f}".format(time.time() - before_time)} sec')
610
563
  case "create-index":
611
- from dmart.data_adapters.file.create_index import main as create_index
564
+ from data_adapters.file.create_index import main as create_index
612
565
  parser = argparse.ArgumentParser(
613
566
  description="Recreate Redis indices based on the available schema definitions",
614
567
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -628,7 +581,7 @@ def main():
628
581
 
629
582
  asyncio.run(create_index(args.space, args.schemas, args.subpaths, args.flushall))
630
583
  case "export":
631
- from dmart.utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
584
+ from utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
632
585
  parser = argparse.ArgumentParser()
633
586
  parser.add_argument(
634
587
  "--config", required=True, help="Json config relative path from the script"
@@ -681,12 +634,11 @@ def main():
681
634
  f"Output path: {os.path.abspath(os.path.join(output_path, OUTPUT_FOLDER_NAME))}"
682
635
  )
683
636
  case "settings":
684
- from dmart.utils.settings import settings
685
637
  print_formatted(settings.model_dump_json())
686
638
  case "set_password":
687
- from dmart import set_admin_passwd # noqa: F401
639
+ import set_admin_passwd # noqa: F401
688
640
  case "archive":
689
- from dmart.data_adapters.file.archive import archive
641
+ from data_adapters.file.archive import archive
690
642
  parser = argparse.ArgumentParser(
691
643
  description="Script for archiving records from different spaces and subpaths."
692
644
  )
@@ -713,10 +665,10 @@ def main():
713
665
  asyncio.run(archive(space, subpath, schema, olderthan))
714
666
  print("Done.")
715
667
  case "json_to_db":
716
- from dmart.data_adapters.sql.json_to_db_migration import main as json_to_db_migration
668
+ from data_adapters.sql.json_to_db_migration import main as json_to_db_migration
717
669
  asyncio.run(json_to_db_migration())
718
670
  case "db_to_json":
719
- from dmart.data_adapters.sql.db_to_json_migration import main as db_to_json_migration
671
+ from data_adapters.sql.db_to_json_migration import main as db_to_json_migration
720
672
  db_to_json_migration()
721
673
  case "help":
722
674
  print("Available commands:")
@@ -787,7 +739,6 @@ def main():
787
739
  import configparser
788
740
  import tempfile
789
741
 
790
- from dmart.utils.settings import settings
791
742
  dmart_root = Path(__file__).resolve().parent
792
743
  alembic_ini_path = dmart_root / "alembic.ini"
793
744
 
@@ -805,7 +756,7 @@ def main():
805
756
 
806
757
  config.set('alembic', 'sqlalchemy.url', db_url)
807
758
  config.set('alembic', 'script_location', str(dmart_root / "alembic"))
808
- config.set('alembic', 'prepend_sys_path', os.path.dirname(dmart_root))
759
+ config.set('alembic', 'prepend_sys_path', str(dmart_root))
809
760
 
810
761
  temp_config_path = ""
811
762
  try:
@@ -813,7 +764,7 @@ def main():
813
764
  config.write(temp_config_file)
814
765
  temp_config_path = temp_config_file.name
815
766
 
816
- alembic_cli_args = args_list
767
+ alembic_cli_args = sys.argv[1:]
817
768
  if not alembic_cli_args:
818
769
  alembic_cli_args = ["upgrade", "head"]
819
770
 
@@ -868,5 +819,4 @@ def main():
868
819
  sys.exit(e.returncode)
869
820
 
870
821
  if __name__ == "__main__":
871
- freeze_support()
872
822
  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.post27
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=Api8q2Tt3KhazVL71_11UBoVYZaNkSW5tzznQm8X1Tc,32115
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.post27.dist-info/METADATA,sha256=olOU6OyyGuf-Ug2L5M2VdhHiOIxwadYT-L6anchX3Ag,839
487
+ dmart-1.4.40.post27.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
488
+ dmart-1.4.40.post27.dist-info/entry_points.txt,sha256=N832M4wG8d2GDw1xztKRVM3TnxpY2QDzvdFE8XaWaG8,43
489
+ dmart-1.4.40.post27.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
490
+ dmart-1.4.40.post27.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dmart = dmart.dmart:main
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- dmart = dmart:main