cgse-tools 2025.0.8.dev2__py3-none-any.whl → 2025.0.8.dev3__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,12 +1,15 @@
1
1
  import re
2
2
  import subprocess
3
3
  import sys
4
+ import textwrap
4
5
  from pathlib import Path
5
6
  from typing import Annotated
6
7
 
7
8
  import rich
8
9
  import typer
9
10
 
11
+ from egse.system import format_datetime
12
+
10
13
  app = typer.Typer()
11
14
 
12
15
 
@@ -20,6 +23,82 @@ def top():
20
23
  print("This fancy top is not yet implemented.")
21
24
 
22
25
 
26
+ @app.command()
27
+ def init(project: str = ""):
28
+ """Initialize your project."""
29
+ from rich.prompt import Prompt, Confirm
30
+
31
+ project = project.upper()
32
+ site_id = None
33
+
34
+ rich.print("[light_steel_blue]Please note default values are given between \[brackets].[/]")
35
+
36
+ answer = Prompt.ask(f"What is the name of the project [{project}] ?")
37
+ if answer:
38
+ project = answer.upper()
39
+ while not site_id:
40
+ answer = Prompt.ask("What is the site identifier ?")
41
+ if answer:
42
+ site_id = answer.upper()
43
+ else:
44
+ answer = Confirm.ask("Abort?")
45
+ if answer:
46
+ return
47
+
48
+ data_storage_location = f"~/data/{project}/{site_id}/"
49
+ answer = Prompt.ask(f"Where can the project data be stored [{data_storage_location}] ?")
50
+ if answer:
51
+ data_storage_location = answer
52
+
53
+ conf_data_location = f"~/data/{project}/{site_id}/conf/"
54
+ answer = Prompt.ask(f"Where will the configuration data be located [{conf_data_location}] ?")
55
+ if answer:
56
+ conf_data_location = answer
57
+
58
+ log_file_location = f"~/data/{project}/{site_id}/log/"
59
+ answer = Prompt.ask(f"Where will the logging messages be stored [{log_file_location}] ?")
60
+ if answer:
61
+ log_file_location = answer
62
+
63
+ local_settings_path = f"~/data/{project}/{site_id}/local_settings.yaml"
64
+ answer = Prompt.ask(f"Where shall I create a local settings YAML file [{local_settings_path}] ?")
65
+ if answer:
66
+ local_settings_path = answer
67
+
68
+ Path(data_storage_location).expanduser().mkdir(exist_ok=True, parents=True)
69
+ (Path(data_storage_location).expanduser() / "daily").mkdir(exist_ok=True, parents=True)
70
+ (Path(data_storage_location).expanduser() / "obs").mkdir(exist_ok=True, parents=True)
71
+ Path(conf_data_location).expanduser().mkdir(exist_ok=True, parents=True)
72
+ Path(log_file_location).expanduser().mkdir(exist_ok=True, parents=True)
73
+
74
+ with open(Path(local_settings_path).expanduser(), 'w') as fd:
75
+ fd.write(
76
+ textwrap.dedent(
77
+ f"""\
78
+ SITE:
79
+ ID: {site_id}
80
+ """
81
+ )
82
+ )
83
+
84
+ answer = Confirm.ask("Shall I add the environment to your ~/bash_profile ?")
85
+ if answer:
86
+ with open(Path("~/.bash_profile").expanduser(), 'a') as fd:
87
+ fd.write(
88
+ textwrap.dedent(
89
+ f"""
90
+ # Environment for project {project} added by `cgse init` at {format_datetime()}
91
+ export PROJECT={project}
92
+ export SITE_ID={site_id}
93
+ export {project}_DATA_STORAGE_LOCATION={data_storage_location}
94
+ export {project}_CONF_DATA_LOCATION={conf_data_location}
95
+ export {project}_LOG_FILE_LOCATION={log_file_location}
96
+ export {project}_LOCAL_SETTINGS={local_settings_path}
97
+ """
98
+ )
99
+ )
100
+
101
+
23
102
  show = typer.Typer(help="Show information about settings, environment, setup, ...", no_args_is_help=True)
24
103
 
25
104
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cgse-tools
3
- Version: 2025.0.8.dev2
3
+ Version: 2025.0.8.dev3
4
4
  Summary: Tools for CGSE
5
5
  Author: IVS KU Leuven
6
6
  Maintainer-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
@@ -0,0 +1,8 @@
1
+ cgse_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cgse_tools/cgse_commands.py,sha256=Rz2J8LUV_SOXDzAaD2cyLsYELL9NI8TpyTP_uakeUtg,6095
3
+ cgse_tools/cgse_services.py,sha256=ZERds5uCHuR5_R4YpBkc2yUTGImtVdKlItherlfL5IM,661
4
+ egse/tools/status.py,sha256=2PFjU760X-E2aeLI5sWOZJ_rqHWCG6YwjmqreYpJ6_c,2188
5
+ cgse_tools-2025.0.8.dev3.dist-info/METADATA,sha256=l9Xf3xEMjeFI4k8g6ehNTSFtfWLIGW0cESRA-5vUuw8,613
6
+ cgse_tools-2025.0.8.dev3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ cgse_tools-2025.0.8.dev3.dist-info/entry_points.txt,sha256=asDXVFTyqyl1w9ypPj7KqktTlRCk_wAFekHAl2eL3H4,327
8
+ cgse_tools-2025.0.8.dev3.dist-info/RECORD,,
@@ -4,6 +4,7 @@ cgse-status = egse.tools.status:main
4
4
  [cgse.command.plugins]
5
5
  check = cgse_tools.cgse_commands:check[group]
6
6
  dev-x = cgse_tools.cgse_services:dev_x[group]
7
+ init = cgse_tools.cgse_commands:init
7
8
  show = cgse_tools.cgse_commands:show[group]
8
9
  top = cgse_tools.cgse_commands:top
9
10
 
@@ -1,8 +0,0 @@
1
- cgse_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cgse_tools/cgse_commands.py,sha256=Vh9veF8rh3hCzv6try_T7Jzv-u_z4-8qGJ3w81ZQ3NM,3093
3
- cgse_tools/cgse_services.py,sha256=ZERds5uCHuR5_R4YpBkc2yUTGImtVdKlItherlfL5IM,661
4
- egse/tools/status.py,sha256=2PFjU760X-E2aeLI5sWOZJ_rqHWCG6YwjmqreYpJ6_c,2188
5
- cgse_tools-2025.0.8.dev2.dist-info/METADATA,sha256=BOt9sEs2HhDn6dVjFGNsbfEzMknD-8kC1RIYbPW7AIc,613
6
- cgse_tools-2025.0.8.dev2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- cgse_tools-2025.0.8.dev2.dist-info/entry_points.txt,sha256=JY7rD8p4H2_MS_4Al0KNsdB5s9uCEawa8NE4pMKlcfc,290
8
- cgse_tools-2025.0.8.dev2.dist-info/RECORD,,