machineconfig 3.83__py3-none-any.whl → 3.86__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.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/cluster/sessions_managers/zellij_local.py +2 -2
- machineconfig/cluster/sessions_managers/zellij_remote.py +2 -2
- machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +2 -2
- machineconfig/jobs/python/vscode/api.py +8 -7
- machineconfig/scripts/python/ai/initai.py +1 -11
- machineconfig/scripts/python/cloud_copy.py +33 -27
- machineconfig/scripts/python/cloud_manager.py +0 -2
- machineconfig/scripts/python/cloud_mount.py +13 -10
- machineconfig/scripts/python/cloud_sync.py +30 -28
- machineconfig/scripts/python/croshell.py +46 -53
- machineconfig/scripts/python/dotfile.py +16 -16
- machineconfig/scripts/python/fire_agents.py +4 -5
- machineconfig/scripts/python/fire_jobs.py +30 -14
- machineconfig/scripts/python/fire_jobs_args_helper.py +43 -15
- machineconfig/scripts/python/fire_jobs_layout_helper.py +24 -16
- machineconfig/scripts/python/helpers/helpers4.py +0 -2
- machineconfig/scripts/python/repos.py +10 -88
- machineconfig/scripts/python/repos_helper_action.py +335 -0
- machineconfig/scripts/python/scheduler.py +0 -1
- machineconfig/scripts/python/share_terminal.py +41 -0
- machineconfig/scripts/python/start_slidev.py +15 -13
- machineconfig/scripts/python/start_terminals.py +19 -19
- machineconfig/scripts/python/t4.py +17 -0
- machineconfig/scripts/python/wifi_conn.py +16 -14
- machineconfig/scripts/python/wsl_windows_transfer.py +23 -29
- machineconfig/utils/accessories.py +45 -7
- machineconfig/utils/ai/generate_file_checklist.py +17 -17
- {machineconfig-3.83.dist-info → machineconfig-3.86.dist-info}/METADATA +1 -1
- {machineconfig-3.83.dist-info → machineconfig-3.86.dist-info}/RECORD +32 -32
- {machineconfig-3.83.dist-info → machineconfig-3.86.dist-info}/entry_points.txt +5 -5
- machineconfig/cluster/templates/cli_gooey.py +0 -115
- machineconfig/jobs/python/vscode/link_ve.py +0 -63
- machineconfig/jobs/python/vscode/select_interpreter.py +0 -87
- {machineconfig-3.83.dist-info → machineconfig-3.86.dist-info}/WHEEL +0 -0
- {machineconfig-3.83.dist-info → machineconfig-3.86.dist-info}/top_level.txt +0 -0
|
@@ -494,8 +494,8 @@ if __name__ == "__main__":
|
|
|
494
494
|
sample_layout: LayoutConfig = {
|
|
495
495
|
"layoutName": "SampleBots",
|
|
496
496
|
"layoutTabs": [
|
|
497
|
-
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 --
|
|
498
|
-
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 --
|
|
497
|
+
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 -- --create_new_bot=True"},
|
|
498
|
+
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 -- --create_new_bot=True"},
|
|
499
499
|
{"tabName": "📊Monitor", "startDir": "~", "command": "htop"},
|
|
500
500
|
{"tabName": "📝Logs", "startDir": "/var/log", "command": "tail -f /var/log/app.log"},
|
|
501
501
|
],
|
|
@@ -144,8 +144,8 @@ if __name__ == "__main__":
|
|
|
144
144
|
sample_layout: LayoutConfig = {
|
|
145
145
|
"layoutName": "RemoteBots",
|
|
146
146
|
"layoutTabs": [
|
|
147
|
-
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 --
|
|
148
|
-
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 --
|
|
147
|
+
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 -- --create_new_bot=True"},
|
|
148
|
+
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 -- --create_new_bot=True"},
|
|
149
149
|
{"tabName": "📊Monitor", "startDir": "~", "command": "htop"},
|
|
150
150
|
{"tabName": "📝Logs", "startDir": "/var/log", "command": "tail -f /var/log/app.log"},
|
|
151
151
|
],
|
|
@@ -17,8 +17,8 @@ def example_usage():
|
|
|
17
17
|
sample_layout: LayoutConfig = {
|
|
18
18
|
"layoutName": "ExampleRemoteSession",
|
|
19
19
|
"layoutTabs": [
|
|
20
|
-
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 --
|
|
21
|
-
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 --
|
|
20
|
+
{"tabName": "🤖Bot1", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go1.py bot1 -- --create_new_bot=True"},
|
|
21
|
+
{"tabName": "🤖Bot2", "startDir": "~/code/bytesense/bithence", "command": "~/scripts/fire -mO go2.py bot2 -- --create_new_bot=True"},
|
|
22
22
|
{"tabName": "📊Monitor", "startDir": "~", "command": "htop"},
|
|
23
23
|
{"tabName": "📝Logs", "startDir": "/var/log", "command": "tail -f /var/log/app.log"},
|
|
24
24
|
],
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from machineconfig.utils.accessories import randstr
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
import typer
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
def open_file_in_new_instance(file_path: str):
|
|
@@ -35,14 +37,13 @@ code --profile bitProfile --new-window {file_path}
|
|
|
35
37
|
subprocess.run([str(code_path)], shell=True, check=True)
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
def main():
|
|
39
|
-
|
|
40
|
+
def main(file_path: Annotated[str, typer.Argument(help="Path to the file to open")]) -> None:
|
|
41
|
+
open_file_in_new_instance(file_path)
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
open_file_in_new_instance(args.file_path)
|
|
43
|
+
|
|
44
|
+
def arg_parser() -> None:
|
|
45
|
+
typer.run(main)
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
if __name__ == "__main__":
|
|
48
|
-
|
|
49
|
+
arg_parser()
|
|
@@ -23,6 +23,7 @@ uv init --python 3.13
|
|
|
23
23
|
uv venv
|
|
24
24
|
uv add --upgrade-package pylint pyright mypy pyrefly ty --dev # linters and type checkers
|
|
25
25
|
uv add --upgrade-package pytest --dev
|
|
26
|
+
# uv add typer --dev
|
|
26
27
|
|
|
27
28
|
"""
|
|
28
29
|
import subprocess
|
|
@@ -49,17 +50,6 @@ uv add --upgrade-package pytest --dev
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
def main() -> None:
|
|
52
|
-
# import argparse
|
|
53
|
-
|
|
54
|
-
# parser = argparse.ArgumentParser(description="Add AI configurations to a Python project.")
|
|
55
|
-
# parser.add_argument(
|
|
56
|
-
# "--repo-root",
|
|
57
|
-
# type=str,
|
|
58
|
-
# default=".",
|
|
59
|
-
# help="Path to the root of the repository. Defaults to the current working directory.",
|
|
60
|
-
# )
|
|
61
|
-
# args = parser.parse_args()
|
|
62
|
-
# repo_root = Path(args.repo_root).resolve()
|
|
63
53
|
repo_root = Path.cwd()
|
|
64
54
|
add_ai_configs(repo_root=repo_root)
|
|
65
55
|
|
|
@@ -5,9 +5,10 @@ CC
|
|
|
5
5
|
from machineconfig.utils.path_extended import PathExtended as PathExtended
|
|
6
6
|
from tenacity import retry, stop_after_attempt, wait_chain, wait_fixed
|
|
7
7
|
import getpass
|
|
8
|
-
import argparse
|
|
9
8
|
import os
|
|
10
|
-
from typing import Optional
|
|
9
|
+
from typing import Optional, Annotated
|
|
10
|
+
|
|
11
|
+
import typer
|
|
11
12
|
|
|
12
13
|
from machineconfig.scripts.python.helpers.helpers2 import parse_cloud_source_target
|
|
13
14
|
from machineconfig.scripts.python.helpers.cloud_helpers import ArgsDefaults, Args
|
|
@@ -61,33 +62,34 @@ def get_securely_shared_file(url: Optional[str] = None, folder: Optional[str] =
|
|
|
61
62
|
tmp_folder.delete()
|
|
62
63
|
|
|
63
64
|
|
|
64
|
-
def
|
|
65
|
+
def main(
|
|
66
|
+
source: Annotated[str, typer.Argument(help="📂 file/folder path to be taken from here.")],
|
|
67
|
+
target: Annotated[str, typer.Argument(help="🎯 file/folder path to be be sent to here.")],
|
|
68
|
+
overwrite: Annotated[bool, typer.Option(help="✍️ Overwrite existing file.")] = ArgsDefaults.overwrite,
|
|
69
|
+
share: Annotated[bool, typer.Option(help="🔗 Share file / directory")] = ArgsDefaults.share,
|
|
70
|
+
rel2home: Annotated[bool, typer.Option(help="🏠 Relative to `myhome` folder")] = ArgsDefaults.rel2home,
|
|
71
|
+
root: Annotated[Optional[str], typer.Option(help="🌳 Remote root. None is the default, unless rel2home is raied, making the default `myhome`.")] = ArgsDefaults.root,
|
|
72
|
+
key: Annotated[Optional[str], typer.Option(help="🔑 Key for encryption")] = ArgsDefaults.key,
|
|
73
|
+
pwd: Annotated[Optional[str], typer.Option(help="🔒 Password for encryption")] = ArgsDefaults.pwd,
|
|
74
|
+
encrypt: Annotated[bool, typer.Option(help="🔐 Encrypt before sending.")] = ArgsDefaults.encrypt,
|
|
75
|
+
zip_: Annotated[bool, typer.Option("--zip", "-z", help="📦 unzip after receiving.")] = ArgsDefaults.zip_,
|
|
76
|
+
os_specific: Annotated[bool, typer.Option(help="💻 choose path specific for this OS.")] = ArgsDefaults.os_specific,
|
|
77
|
+
config: Annotated[Optional[str], typer.Option(help="⚙️ path to cloud.json file.")] = None,
|
|
78
|
+
) -> None:
|
|
65
79
|
console.print(Panel("☁️ Cloud Copy Utility", title="[bold blue]Cloud Copy[/bold blue]", border_style="blue", width=152))
|
|
66
80
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
parser.add_argument("--pwd", "-p", help="🔒 Password for encryption", type=str, default=ArgsDefaults.pwd)
|
|
80
|
-
parser.add_argument("--encrypt", "-e", help="🔐 Encrypt before sending.", action="store_true", default=ArgsDefaults.encrypt)
|
|
81
|
-
parser.add_argument("--zip", "-z", help="📦 unzip after receiving.", action="store_true", default=ArgsDefaults.zip_)
|
|
82
|
-
parser.add_argument("--os_specific", "-o", help="💻 choose path specific for this OS.", action="store_true", default=ArgsDefaults.os_specific)
|
|
83
|
-
|
|
84
|
-
parser.add_argument("--config", "-c", help="⚙️ path to cloud.json file.", default=None)
|
|
85
|
-
|
|
86
|
-
args = parser.parse_args()
|
|
87
|
-
args_dict = vars(args)
|
|
88
|
-
source: str = args_dict.pop("source")
|
|
89
|
-
target: str = args_dict.pop("target")
|
|
90
|
-
args_obj = Args(**args_dict)
|
|
81
|
+
args_obj = Args(
|
|
82
|
+
overwrite=overwrite,
|
|
83
|
+
share=share,
|
|
84
|
+
rel2home=rel2home,
|
|
85
|
+
root=root,
|
|
86
|
+
key=key,
|
|
87
|
+
pwd=pwd,
|
|
88
|
+
encrypt=encrypt,
|
|
89
|
+
zip=zip_,
|
|
90
|
+
os_specific=os_specific,
|
|
91
|
+
config=config,
|
|
92
|
+
)
|
|
91
93
|
|
|
92
94
|
if args_obj.config == "ss" and (source.startswith("http") or source.startswith("bit.ly")):
|
|
93
95
|
console.print(Panel("🔒 Detected secure share link", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
|
|
@@ -153,5 +155,9 @@ def arg_parser() -> None:
|
|
|
153
155
|
raise ValueError(f"Cloud `{cloud}` not found in source or target.")
|
|
154
156
|
|
|
155
157
|
|
|
158
|
+
def arg_parser() -> None:
|
|
159
|
+
typer.run(main)
|
|
160
|
+
|
|
161
|
+
|
|
156
162
|
if __name__ == "__main__":
|
|
157
163
|
arg_parser()
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
# from machineconfig.cluster.cloud_manager import CloudManager
|
|
5
5
|
# from rich.console import Console # Add import for Console
|
|
6
6
|
# from rich.panel import Panel # Add import for Panel
|
|
7
|
-
# import argparse
|
|
8
7
|
|
|
9
8
|
# console = Console()
|
|
10
9
|
|
|
@@ -21,7 +20,6 @@
|
|
|
21
20
|
# console = Console() # Add console initialization
|
|
22
21
|
# console.print(Panel("☁️ Cloud Manager", title_align="left", expand=False))
|
|
23
22
|
|
|
24
|
-
# parser = argparse.ArgumentParser()
|
|
25
23
|
# parser.add_argument("-c", "--cloud", help="Rclone Config Name", action="store", type=str, default=None)
|
|
26
24
|
# parser.add_argument("-s", "--serve", help="Start job server", action="store_true", default=False)
|
|
27
25
|
# parser.add_argument("-R", "--reset_local", help="Clear local cache", action="store_true", default=False)
|
|
@@ -5,8 +5,8 @@ from machineconfig.utils.io import read_ini
|
|
|
5
5
|
from machineconfig.utils.path_extended import PathExtended as PathExtended
|
|
6
6
|
|
|
7
7
|
import platform
|
|
8
|
-
import
|
|
9
|
-
|
|
8
|
+
from typing import Optional, Annotated
|
|
9
|
+
import typer
|
|
10
10
|
from rich.console import Console
|
|
11
11
|
from rich.panel import Panel
|
|
12
12
|
|
|
@@ -153,18 +153,21 @@ zellij action move-focus up
|
|
|
153
153
|
console.print(Panel(f"{title1}\n{title2}", title="Success", border_style="green"))
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
def main(
|
|
156
|
+
def main(
|
|
157
|
+
cloud: Annotated[Optional[str], typer.Option(help="cloud to mount")] = None,
|
|
158
|
+
destination: Annotated[Optional[str], typer.Option(help="destination to mount")] = None,
|
|
159
|
+
network: Annotated[Optional[str], typer.Option(help="mount network drive")] = None,
|
|
160
|
+
) -> None:
|
|
157
161
|
# draw main title box dynamically
|
|
158
162
|
main_title = "☁️ RCLONE CLOUD MOUNT"
|
|
159
163
|
console.print(Panel(main_title, title_align="left", border_style="blue"))
|
|
160
164
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
mount(cloud=args.cloud, network=args.network, destination=args.destination)
|
|
165
|
+
mount(cloud=cloud, network=network, destination=destination)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def arg_parser() -> None:
|
|
169
|
+
typer.run(main)
|
|
167
170
|
|
|
168
171
|
|
|
169
172
|
if __name__ == "__main__":
|
|
170
|
-
|
|
173
|
+
arg_parser()
|
|
@@ -6,41 +6,39 @@ from machineconfig.scripts.python.helpers.helpers2 import parse_cloud_source_tar
|
|
|
6
6
|
from machineconfig.scripts.python.helpers.cloud_helpers import Args
|
|
7
7
|
from machineconfig.scripts.python.cloud_mount import get_mprocs_mount_txt
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
from typing import Annotated, Optional
|
|
10
|
+
import typer
|
|
10
11
|
from rich.console import Console
|
|
11
12
|
from rich.panel import Panel
|
|
12
13
|
|
|
13
14
|
console = Console()
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def
|
|
17
|
+
def main(
|
|
18
|
+
source: Annotated[str, typer.Argument(help="source")],
|
|
19
|
+
target: Annotated[str, typer.Argument(help="target")],
|
|
20
|
+
transfers: Annotated[int, typer.Option("--transfers", "-t", help="Number of threads in syncing.")] = 10,
|
|
21
|
+
root: Annotated[str, typer.Option("--root", "-R", help="Remote root.")] = "myhome",
|
|
22
|
+
key: Annotated[Optional[str], typer.Option("--key", "-k", help="Key for encryption")] = None,
|
|
23
|
+
pwd: Annotated[Optional[str], typer.Option("--pwd", "-P", help="Password for encryption")] = None,
|
|
24
|
+
encrypt: Annotated[bool, typer.Option("--encrypt", "-e", help="Decrypt after receiving.")] = False,
|
|
25
|
+
zip_: Annotated[bool, typer.Option("--zip", "-z", help="unzip after receiving.")] = False,
|
|
26
|
+
bisync: Annotated[bool, typer.Option("--bisync", "-b", help="Bidirectional sync.")] = False,
|
|
27
|
+
delete: Annotated[bool, typer.Option("--delete", "-D", help="Delete files in remote that are not in local.")] = False,
|
|
28
|
+
verbose: Annotated[bool, typer.Option("--verbose", "-v", help="Verbosity of mprocs to show details of syncing.")] = False,
|
|
29
|
+
) -> None:
|
|
17
30
|
title = "☁️ Cloud Sync Utility"
|
|
18
31
|
console.print(Panel(title, title_align="left", border_style="blue"))
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
parser.add_argument("--delete", "-D", help="Delete files in remote that are not in local.", action="store_true") # default is False
|
|
30
|
-
parser.add_argument("--verbose", "-v", help="Verbosity of mprocs to show details of syncing.", action="store_true") # default is False
|
|
31
|
-
|
|
32
|
-
args = parser.parse_args()
|
|
33
|
-
args_dict = vars(args)
|
|
34
|
-
source: str = args_dict.pop("source")
|
|
35
|
-
target: str = args_dict.pop("target")
|
|
36
|
-
verbose: bool = args_dict.pop("verbose")
|
|
37
|
-
delete: bool = args_dict.pop("delete")
|
|
38
|
-
bisync: bool = args_dict.pop("bisync")
|
|
39
|
-
transfers: int = args_dict.pop("transfers")
|
|
40
|
-
args_obj = Args(**args_dict)
|
|
41
|
-
|
|
42
|
-
args_obj.os_specific = False
|
|
43
|
-
args_obj.rel2home = True
|
|
32
|
+
|
|
33
|
+
args_obj = Args(
|
|
34
|
+
root=root,
|
|
35
|
+
key=key,
|
|
36
|
+
pwd=pwd,
|
|
37
|
+
encrypt=encrypt,
|
|
38
|
+
zip=zip_,
|
|
39
|
+
rel2home=True,
|
|
40
|
+
os_specific=False,
|
|
41
|
+
)
|
|
44
42
|
|
|
45
43
|
cloud, source, target = parse_cloud_source_target(args=args_obj, source=source, target=target)
|
|
46
44
|
# map short flags to long flags (-u -> --upload), for easier use in the script
|
|
@@ -81,5 +79,9 @@ def args_parser():
|
|
|
81
79
|
subprocess.run(txt, shell=True, check=True)
|
|
82
80
|
|
|
83
81
|
|
|
82
|
+
def arg_parser() -> None:
|
|
83
|
+
typer.run(main)
|
|
84
|
+
|
|
85
|
+
|
|
84
86
|
if __name__ == "__main__":
|
|
85
|
-
|
|
87
|
+
arg_parser()
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
croshell
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
from typing import Annotated, Optional
|
|
8
|
+
import typer
|
|
8
9
|
from machineconfig.utils.path_extended import PathExtended as PathExtended
|
|
9
10
|
from machineconfig.utils.accessories import randstr
|
|
10
11
|
|
|
11
12
|
from machineconfig.utils.options import choose_from_options
|
|
12
13
|
from machineconfig.utils.ve import get_ve_activate_line
|
|
13
|
-
from typing import Optional
|
|
14
14
|
from rich.console import Console
|
|
15
15
|
from rich.panel import Panel
|
|
16
16
|
from rich.text import Text
|
|
@@ -79,62 +79,55 @@ __file__ = PathExtended(r'{path}')
|
|
|
79
79
|
return pycode
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
parser.add_argument("--shell", "-S", dest="shell", help="specify which shell to be used. Defaults to CMD.", default="")
|
|
99
|
-
parser.add_argument("--jupyter", "-j", dest="jupyter", help="run in jupyter interactive console", action="store_true", default=False)
|
|
100
|
-
parser.add_argument("--stViewer", "-s", dest="streamlit_viewer", help="view in streamlit app", action="store_true", default=False)
|
|
101
|
-
|
|
102
|
-
args = parser.parse_args()
|
|
103
|
-
# print(f"Crocodile.run: args of the firing command = {args.__dict__}")
|
|
104
|
-
|
|
82
|
+
def main(
|
|
83
|
+
module: Annotated[bool, typer.Option("--module", "-m", help="flag to run the file as a module as opposed to main.")] = False,
|
|
84
|
+
newWindow: Annotated[bool, typer.Option("--newWindow", "-w", help="flag for running in new window.")] = False,
|
|
85
|
+
nonInteratctive: Annotated[bool, typer.Option("--nonInteratctive", "-N", help="flag for a non-interactive session.")] = False,
|
|
86
|
+
python: Annotated[bool, typer.Option("--python", "-p", help="flag to use python over IPython.")] = False,
|
|
87
|
+
fzf: Annotated[bool, typer.Option("--fzf", "-F", help="search with fuzzy finder for python scripts and run them")] = False,
|
|
88
|
+
ve: Annotated[Optional[str], typer.Option("--ve", "-v", help="virtual enviroment to use, defaults to activated ve, if existed, else ve.")] = None,
|
|
89
|
+
profile: Annotated[Optional[str], typer.Option("--profile", "-P", help="ipython profile to use, defaults to default profile.")] = None,
|
|
90
|
+
read: Annotated[str, typer.Option("--read", "-r", help="read a binary file.")] = "",
|
|
91
|
+
file: Annotated[str, typer.Option("--file", "-f", help="python file path to interpret")] = "",
|
|
92
|
+
cmd: Annotated[str, typer.Option("--cmd", "-c", help="python command to interpret")] = "",
|
|
93
|
+
terminal: Annotated[str, typer.Option("--terminal", "-t", help="specify which terminal to be used. Default console host.")] = "",
|
|
94
|
+
shell: Annotated[str, typer.Option("--shell", "-S", help="specify which shell to be used. Defaults to CMD.")] = "",
|
|
95
|
+
jupyter: Annotated[bool, typer.Option("--jupyter", "-j", help="run in jupyter interactive console")] = False,
|
|
96
|
+
streamlit_viewer: Annotated[bool, typer.Option("--stViewer", "-s", help="view in streamlit app")] = False,
|
|
97
|
+
) -> None:
|
|
105
98
|
# ==================================================================================
|
|
106
99
|
# flags processing
|
|
107
|
-
interactivity = "" if
|
|
108
|
-
interpreter = "python" if
|
|
109
|
-
ipython_profile: Optional[str] =
|
|
110
|
-
|
|
100
|
+
interactivity = "" if nonInteratctive else "-i"
|
|
101
|
+
interpreter = "python" if python else "ipython"
|
|
102
|
+
ipython_profile: Optional[str] = profile
|
|
103
|
+
file_obj = PathExtended.cwd() # initialization value, could be modified according to args.
|
|
111
104
|
|
|
112
|
-
if
|
|
105
|
+
if cmd != "":
|
|
113
106
|
text = "🖥️ Executing command from CLI argument"
|
|
114
107
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
115
108
|
import textwrap
|
|
116
109
|
|
|
117
|
-
program = textwrap.dedent(
|
|
110
|
+
program = textwrap.dedent(cmd)
|
|
118
111
|
|
|
119
|
-
elif
|
|
112
|
+
elif fzf:
|
|
120
113
|
text = "🔍 Searching for Python files..."
|
|
121
114
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
122
115
|
options = [str(item) for item in PathExtended.cwd().search("*.py", r=True)]
|
|
123
|
-
|
|
124
|
-
assert isinstance(
|
|
125
|
-
program = PathExtended(
|
|
126
|
-
text = f"📄 Selected file: {PathExtended(
|
|
116
|
+
file_selected = choose_from_options(msg="Choose a python file to run", options=options, fzf=True, multi=False)
|
|
117
|
+
assert isinstance(file_selected, str)
|
|
118
|
+
program = PathExtended(file_selected).read_text(encoding="utf-8")
|
|
119
|
+
text = f"📄 Selected file: {PathExtended(file_selected).name}"
|
|
127
120
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
128
121
|
|
|
129
|
-
elif
|
|
130
|
-
|
|
131
|
-
program = get_read_pyfile_pycode(
|
|
132
|
-
text1 = f"📄 Loading file: {
|
|
133
|
-
text2 = f"🔄 Mode: {'Module' if
|
|
122
|
+
elif file != "":
|
|
123
|
+
file_obj = PathExtended(file.lstrip()).expanduser().absolute()
|
|
124
|
+
program = get_read_pyfile_pycode(file_obj, as_module=module, cmd=cmd)
|
|
125
|
+
text1 = f"📄 Loading file: {file_obj.name}"
|
|
126
|
+
text2 = f"🔄 Mode: {'Module' if module else 'Script'}"
|
|
134
127
|
console.print(Panel(f"{text1}\n{text2}", title="[bold blue]Info[/bold blue]"))
|
|
135
128
|
|
|
136
|
-
elif
|
|
137
|
-
if
|
|
129
|
+
elif read != "":
|
|
130
|
+
if streamlit_viewer:
|
|
138
131
|
# text = "📊 STARTING STREAMLIT VIEWER"
|
|
139
132
|
# console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
140
133
|
# from machineconfig.scripts.python.viewer import run
|
|
@@ -145,9 +138,9 @@ def build_parser():
|
|
|
145
138
|
# """
|
|
146
139
|
# PROGRAM_PATH.write_text(data=final_program, encoding="utf-8")
|
|
147
140
|
return None
|
|
148
|
-
|
|
149
|
-
program = get_read_data_pycode(str(
|
|
150
|
-
text = f"📄 Reading data from: {
|
|
141
|
+
file_obj = PathExtended(str(read).lstrip()).expanduser().absolute()
|
|
142
|
+
program = get_read_data_pycode(str(file_obj))
|
|
143
|
+
text = f"📄 Reading data from: {file_obj.name}"
|
|
151
144
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
152
145
|
|
|
153
146
|
else: # if nothing is specified, then run in interactive mode.
|
|
@@ -174,9 +167,9 @@ print(f"🐊 Crocodile Shell | Running @ {Path.cwd()}")
|
|
|
174
167
|
pyfile = PathExtended.tmp().joinpath(f"tmp_scripts/python/croshell/{randstr()}.py")
|
|
175
168
|
pyfile.parent.mkdir(parents=True, exist_ok=True)
|
|
176
169
|
|
|
177
|
-
if
|
|
170
|
+
if read != "":
|
|
178
171
|
title = "Reading Data"
|
|
179
|
-
elif
|
|
172
|
+
elif file != "":
|
|
180
173
|
title = "Running Python File"
|
|
181
174
|
else:
|
|
182
175
|
title = "Executed code"
|
|
@@ -194,7 +187,7 @@ print(f"🐊 Crocodile Shell | Running @ {Path.cwd()}")
|
|
|
194
187
|
{activate_ve_line}
|
|
195
188
|
|
|
196
189
|
"""
|
|
197
|
-
if
|
|
190
|
+
if jupyter:
|
|
198
191
|
fire_line = f"code --new-window {str(pyfile)}"
|
|
199
192
|
else:
|
|
200
193
|
fire_line = interpreter
|
|
@@ -216,10 +209,10 @@ print(f"🐊 Crocodile Shell | Running @ {Path.cwd()}")
|
|
|
216
209
|
|
|
217
210
|
subprocess.run(final_program, shell=True, check=True)
|
|
218
211
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
212
|
+
|
|
213
|
+
def arg_parser() -> None:
|
|
214
|
+
typer.run(main)
|
|
222
215
|
|
|
223
216
|
|
|
224
217
|
if __name__ == "__main__":
|
|
225
|
-
|
|
218
|
+
arg_parser()
|
|
@@ -3,21 +3,17 @@
|
|
|
3
3
|
from machineconfig.utils.path_extended import PathExtended as PathExtended
|
|
4
4
|
from machineconfig.utils.links import symlink_func
|
|
5
5
|
from machineconfig.utils.source_of_truth import LIBRARY_ROOT, REPO_ROOT
|
|
6
|
-
import
|
|
6
|
+
from typing import Annotated
|
|
7
|
+
import typer
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
def main(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
parser.add_argument("-d", "--dest", help="destination folder", default="")
|
|
17
|
-
|
|
18
|
-
args = parser.parse_args()
|
|
19
|
-
orig_path = PathExtended(args.file).expanduser().absolute()
|
|
20
|
-
if args.dest == "":
|
|
10
|
+
def main(
|
|
11
|
+
file: Annotated[str, typer.Argument(help="file/folder path.")],
|
|
12
|
+
overwrite: Annotated[bool, typer.Option("--overwrite", "-o", help="Overwrite.")] = False,
|
|
13
|
+
dest: Annotated[str, typer.Option("--dest", "-d", help="destination folder")] = "",
|
|
14
|
+
) -> None:
|
|
15
|
+
orig_path = PathExtended(file).expanduser().absolute()
|
|
16
|
+
if dest == "":
|
|
21
17
|
if "Local" in str(orig_path):
|
|
22
18
|
junction = orig_path.split(at="Local", sep=-1)[1]
|
|
23
19
|
elif "Roaming" in str(orig_path):
|
|
@@ -28,11 +24,11 @@ def main():
|
|
|
28
24
|
junction = orig_path.rel2home()
|
|
29
25
|
new_path = PathExtended(REPO_ROOT).joinpath(junction)
|
|
30
26
|
else:
|
|
31
|
-
dest_path = PathExtended(
|
|
27
|
+
dest_path = PathExtended(dest).expanduser().absolute()
|
|
32
28
|
dest_path.mkdir(parents=True, exist_ok=True)
|
|
33
29
|
new_path = dest_path.joinpath(orig_path.name)
|
|
34
30
|
|
|
35
|
-
symlink_func(this=orig_path, to_this=new_path, prioritize_to_this=
|
|
31
|
+
symlink_func(this=orig_path, to_this=new_path, prioritize_to_this=overwrite)
|
|
36
32
|
|
|
37
33
|
print("""
|
|
38
34
|
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -48,5 +44,9 @@ def main():
|
|
|
48
44
|
""")
|
|
49
45
|
|
|
50
46
|
|
|
47
|
+
def arg_parser() -> None:
|
|
48
|
+
typer.run(main)
|
|
49
|
+
|
|
50
|
+
|
|
51
51
|
if __name__ == "__main__":
|
|
52
|
-
|
|
52
|
+
arg_parser()
|
|
@@ -151,10 +151,10 @@ manager.run_monitoring_routine()
|
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
def split_too_many_tabs_to_run_in_sequential_sessions(layout_tabs: list[TabConfig], every: int):
|
|
154
|
-
from machineconfig.utils.accessories import
|
|
154
|
+
from machineconfig.utils.accessories import split_list
|
|
155
155
|
from machineconfig.cluster.sessions_managers.zellij_local_manager import ZellijLocalManager
|
|
156
156
|
|
|
157
|
-
for idx, layout_tabs_chunk in enumerate(
|
|
157
|
+
for idx, layout_tabs_chunk in enumerate(split_list(layout_tabs, every=every, to=None)):
|
|
158
158
|
a_layout_file: LayoutConfig = {"layoutName": f"split_{idx}", "layoutTabs": layout_tabs_chunk}
|
|
159
159
|
manager = ZellijLocalManager(session_layouts=[a_layout_file])
|
|
160
160
|
manager.start_all_sessions(poll_interval=2, poll_seconds=2)
|
|
@@ -163,10 +163,9 @@ def split_too_many_tabs_to_run_in_sequential_sessions(layout_tabs: list[TabConfi
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
def split_too_many_layouts_to_run_in_sequential_sessions(layouts: list[LayoutConfig], every: int):
|
|
166
|
-
from machineconfig.utils.accessories import
|
|
166
|
+
from machineconfig.utils.accessories import split_list
|
|
167
167
|
from machineconfig.cluster.sessions_managers.zellij_local_manager import ZellijLocalManager
|
|
168
|
-
|
|
169
|
-
for _idx, layout_chunk in enumerate(split(layouts, every=every)):
|
|
168
|
+
for _idx, layout_chunk in enumerate(split_list(layouts, every=every)):
|
|
170
169
|
manager = ZellijLocalManager(session_layouts=layout_chunk)
|
|
171
170
|
manager.start_all_sessions(poll_interval=2, poll_seconds=2)
|
|
172
171
|
manager.run_monitoring_routine(wait_ms=2000)
|