flyshell 1.5.10__tar.gz → 1.6.1__tar.gz
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.
- {flyshell-1.5.10/src/flyshell.egg-info → flyshell-1.6.1}/PKG-INFO +3 -3
- {flyshell-1.5.10 → flyshell-1.6.1}/README.md +2 -2
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/abstract/base_cmd.py +2 -2
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/abstract/base_plugin.py +10 -10
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/abstract/parent_cmd.py +4 -4
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/accounts/auth.py +3 -3
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/builtin/fs.py +9 -9
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/builtin/system.py +4 -4
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/builtin/utils.py +6 -6
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/constants.py +3 -5
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/core/console.py +2 -2
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/core/data.py +36 -19
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/core/directory.py +3 -3
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/main.py +1 -1
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/native/diskops_handler.py +9 -9
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/startup/deps.py +2 -2
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/startup/env.py +3 -3
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/startup/loader.py +6 -4
- {flyshell-1.5.10 → flyshell-1.6.1/src/flyshell.egg-info}/PKG-INFO +3 -3
- flyshell-1.6.1/tests/test_data.py +95 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_deps.py +22 -22
- flyshell-1.6.1/tests/test_directory.py +106 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_diskops_ext.py +219 -85
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_diskops_lgc.py +135 -51
- flyshell-1.6.1/tests/test_env.py +255 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_fs.py +12 -9
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_loader.py +41 -11
- flyshell-1.6.1/tests/test_pkg.py +33 -0
- flyshell-1.6.1/tests/test_utils.py +57 -0
- flyshell-1.5.10/tests/test_data.py +0 -76
- flyshell-1.5.10/tests/test_directory.py +0 -75
- flyshell-1.5.10/tests/test_env.py +0 -202
- flyshell-1.5.10/tests/test_pkg.py +0 -50
- flyshell-1.5.10/tests/test_utils.py +0 -87
- {flyshell-1.5.10 → flyshell-1.6.1}/LICENSE +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/MANIFEST.in +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/diskops.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/cp.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/dir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/mkdir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/mv.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/rename.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/rm.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/rmdir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/shared/dir_types.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/shared/dir_types.h +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/shared/win32_utf.h +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/cp.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/dir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/mkdir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/mv.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/rename.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/rm.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/rmdir.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/pyproject.toml +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/setup.cfg +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/setup.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/native/legacy/diskops.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell/startup/seasonal.py +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell.egg-info/SOURCES.txt +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.5.10 → flyshell-1.6.1}/tests/test_auth.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flyshell
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
4
4
|
Summary: A modular, zero-dependency command-line environment in Python.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -23,7 +23,7 @@ Dynamic: license-file
|
|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
> Documentation last updated: v1.
|
|
26
|
+
> Documentation last updated: v1.6.0
|
|
27
27
|
|
|
28
28
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
29
29
|
|
|
@@ -38,7 +38,7 @@ No extra packages required, just install and enjoy!
|
|
|
38
38
|
3. **Secure Authentication**: Flyshell uses salted PBKDF2 HMAC (SHA-256, 600,000 iterations) with constant-time equality comparisons to prevent timing attacks on password information.
|
|
39
39
|
4. **Cross-Platform Support**: Flyshell is fully supported by Windows (NT), macOS (Darwin) and Linux installations with native OS management and POSIX-aware parsing. Note that Flyshell is **not** supported by any other systems.
|
|
40
40
|
5. **State and History Persistence**: Flyshell has a fully encapsulated SQL storage system using SQLite3 providing session metrics and ISO 8601 UTC audit logging.
|
|
41
|
-
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI
|
|
41
|
+
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI Tools is required as macOS builds install from source.
|
|
42
42
|
|
|
43
43
|
## System Requirements
|
|
44
44
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
> Documentation last updated: v1.
|
|
9
|
+
> Documentation last updated: v1.6.0
|
|
10
10
|
|
|
11
11
|
A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ No extra packages required, just install and enjoy!
|
|
|
21
21
|
3. **Secure Authentication**: Flyshell uses salted PBKDF2 HMAC (SHA-256, 600,000 iterations) with constant-time equality comparisons to prevent timing attacks on password information.
|
|
22
22
|
4. **Cross-Platform Support**: Flyshell is fully supported by Windows (NT), macOS (Darwin) and Linux installations with native OS management and POSIX-aware parsing. Note that Flyshell is **not** supported by any other systems.
|
|
23
23
|
5. **State and History Persistence**: Flyshell has a fully encapsulated SQL storage system using SQLite3 providing session metrics and ISO 8601 UTC audit logging.
|
|
24
|
-
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI
|
|
24
|
+
6. **Automatic C-Extension Compilation**: If installed via `pip` on Windows or Linux, Flyshell is shipped with pre-compiled wheels. For macOS users, Xcode CLI Tools is required as macOS builds install from source.
|
|
25
25
|
|
|
26
26
|
## System Requirements
|
|
27
27
|
|
|
@@ -10,7 +10,7 @@ class BaseCmd:
|
|
|
10
10
|
options: Optional[str] = None
|
|
11
11
|
aliases: Optional[List[str]] = None
|
|
12
12
|
|
|
13
|
-
def __init__(self):
|
|
13
|
+
def __init__(self) -> None:
|
|
14
14
|
if self.aliases is None:
|
|
15
15
|
self.aliases = []
|
|
16
16
|
else:
|
|
@@ -21,7 +21,7 @@ class BaseCmd:
|
|
|
21
21
|
f"Command '{self.__class__.__name__}' has not implemented the execute method"
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
def help(self, prefix: str = ""):
|
|
24
|
+
def help(self, prefix: str = "") -> None:
|
|
25
25
|
full_name = f"{prefix} {self.name}".strip() if prefix else self.name
|
|
26
26
|
print(f"\nCommand: {full_name}")
|
|
27
27
|
if prefix:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from flyshell.core import data
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
6
|
+
from typing import Any, Optional
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class BasePlugin:
|
|
@@ -17,7 +17,7 @@ class BasePlugin:
|
|
|
17
17
|
api_keys: Optional[list] = None
|
|
18
18
|
third_pty_libs: Optional[list] = None
|
|
19
19
|
|
|
20
|
-
def __init__(self, context: dict):
|
|
20
|
+
def __init__(self, context: dict) -> None:
|
|
21
21
|
self.api_keys = list(self.api_keys) if self.api_keys else []
|
|
22
22
|
self.third_pty_libs = list(self.third_pty_libs) if self.third_pty_libs else []
|
|
23
23
|
self.context = context
|
|
@@ -27,7 +27,7 @@ class BasePlugin:
|
|
|
27
27
|
self.env_file_path = context.get("env_path", None)
|
|
28
28
|
self.on_load()
|
|
29
29
|
|
|
30
|
-
def get_api_key(self, key_name: str, default=None):
|
|
30
|
+
def get_api_key(self, key_name: str, default: Any = None) -> Any:
|
|
31
31
|
if key_name in self.api_keys_data:
|
|
32
32
|
return self.api_keys_data[key_name]
|
|
33
33
|
target = key_name.lower()
|
|
@@ -36,16 +36,16 @@ class BasePlugin:
|
|
|
36
36
|
return v
|
|
37
37
|
return default
|
|
38
38
|
|
|
39
|
-
def on_load(self):
|
|
39
|
+
def on_load(self) -> None:
|
|
40
40
|
pass
|
|
41
41
|
|
|
42
|
-
def on_unload(self):
|
|
42
|
+
def on_unload(self) -> None:
|
|
43
43
|
pass
|
|
44
44
|
|
|
45
|
-
def execute(self, args: list):
|
|
45
|
+
def execute(self, args: list) -> Any:
|
|
46
46
|
raise NotImplementedError("Plugins must implement the execute method")
|
|
47
47
|
|
|
48
|
-
def help(self):
|
|
48
|
+
def help(self) -> None:
|
|
49
49
|
lines = [
|
|
50
50
|
f"\nPlugin: {self.name} (v{self.version})",
|
|
51
51
|
f"Description: {self.description}",
|
|
@@ -79,10 +79,10 @@ class BasePlugin:
|
|
|
79
79
|
return True
|
|
80
80
|
return False
|
|
81
81
|
|
|
82
|
-
def get_data(self, key: str, default=None):
|
|
82
|
+
def get_data(self, key: str, default: Any = None) -> Any:
|
|
83
83
|
return self.storage.get(key, default)
|
|
84
84
|
|
|
85
|
-
def set_data(self, key: str, value):
|
|
85
|
+
def set_data(self, key: str, value: Any) -> None:
|
|
86
86
|
self.storage[key] = value
|
|
87
87
|
self.save_storage()
|
|
88
88
|
|
|
@@ -99,7 +99,7 @@ class BasePlugin:
|
|
|
99
99
|
self.context["storage"] = fresh_data
|
|
100
100
|
return self.storage
|
|
101
101
|
|
|
102
|
-
def save_storage(self):
|
|
102
|
+
def save_storage(self) -> None:
|
|
103
103
|
existing_keys = set(data.get_all_plugin_data(self.plugin_name).keys())
|
|
104
104
|
for stale_key in existing_keys - set(self.storage.keys()):
|
|
105
105
|
data.delete_plugin_data(self.plugin_name, stale_key)
|
|
@@ -8,12 +8,12 @@ from typing import Dict, List, Tuple
|
|
|
8
8
|
class ParentCmd(BaseCmd):
|
|
9
9
|
min_args: int = 1
|
|
10
10
|
|
|
11
|
-
def __init__(self):
|
|
11
|
+
def __init__(self) -> None:
|
|
12
12
|
super().__init__()
|
|
13
13
|
self._sub_registry: Dict[str, BaseCmd] = {}
|
|
14
14
|
self._build_registry()
|
|
15
15
|
|
|
16
|
-
def _build_registry(self):
|
|
16
|
+
def _build_registry(self) -> None:
|
|
17
17
|
for cmd_obj in self.get_subcommands():
|
|
18
18
|
self._sub_registry[cmd_obj.name] = cmd_obj
|
|
19
19
|
for alias in getattr(cmd_obj, "aliases", []):
|
|
@@ -22,7 +22,7 @@ class ParentCmd(BaseCmd):
|
|
|
22
22
|
def get_subcommands(self) -> List[BaseCmd]:
|
|
23
23
|
return []
|
|
24
24
|
|
|
25
|
-
def help(self):
|
|
25
|
+
def help(self) -> None:
|
|
26
26
|
print(f"\nCommand Family: {self.name}")
|
|
27
27
|
print(f"Description: {self.description}")
|
|
28
28
|
print(f"\nSubcommands of '{self.name}':")
|
|
@@ -50,7 +50,7 @@ class ParentCmd(BaseCmd):
|
|
|
50
50
|
sub_args = args[1:]
|
|
51
51
|
if sub_name not in self._sub_registry:
|
|
52
52
|
err = (
|
|
53
|
-
f"\nCommand Error: Unknown subcommand '{sub_name}' for '{self.name}'
|
|
53
|
+
f"\nCommand Error: Unknown subcommand '{sub_name}' for '{self.name}'\n"
|
|
54
54
|
f"Use '{self.name} -h' or '--help' to see all valid subcommands.\n"
|
|
55
55
|
)
|
|
56
56
|
return (1, err)
|
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
import secrets
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def hash_password(password, salt=None):
|
|
12
|
+
def hash_password(password: str, salt: bytes | str | None = None) -> tuple[str, str]:
|
|
13
13
|
if salt is None:
|
|
14
14
|
salt = secrets.token_bytes(16)
|
|
15
15
|
elif isinstance(salt, str):
|
|
@@ -77,7 +77,7 @@ def setup_acc() -> bool:
|
|
|
77
77
|
return True
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
def login_flow(is_lock=False) -> bool:
|
|
80
|
+
def login_flow(is_lock: bool = False) -> bool:
|
|
81
81
|
auth_info = data.get_auth()
|
|
82
82
|
if not auth_info or "hash" not in auth_info:
|
|
83
83
|
if not setup_acc():
|
|
@@ -113,7 +113,7 @@ class Lock(BaseCmd):
|
|
|
113
113
|
options = None
|
|
114
114
|
aliases = []
|
|
115
115
|
|
|
116
|
-
def execute(self, args):
|
|
116
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
117
117
|
if login_flow(is_lock=True):
|
|
118
118
|
return (0, "")
|
|
119
119
|
else:
|
|
@@ -18,7 +18,7 @@ class FsDel(BaseCmd):
|
|
|
18
18
|
options = "'history', 'all', 'plugin <file>'"
|
|
19
19
|
aliases = ["purge"]
|
|
20
20
|
|
|
21
|
-
def execute(self, args):
|
|
21
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
22
22
|
if len(args) < 1:
|
|
23
23
|
return (1, "\nCommand Error: 'fs del' requires a target.\n")
|
|
24
24
|
target = args[0].lower()
|
|
@@ -57,7 +57,7 @@ class FsDel(BaseCmd):
|
|
|
57
57
|
)
|
|
58
58
|
return (
|
|
59
59
|
1,
|
|
60
|
-
f"\nPlugin Error: No data found for plugin '{plugin_name}'
|
|
60
|
+
f"\nPlugin Error: No data found for plugin '{plugin_name}'\n",
|
|
61
61
|
)
|
|
62
62
|
return (1, "\nAction cancelled.\n")
|
|
63
63
|
case "all":
|
|
@@ -84,7 +84,7 @@ class FsInfo(BaseCmd):
|
|
|
84
84
|
options = None
|
|
85
85
|
aliases = []
|
|
86
86
|
|
|
87
|
-
def execute(self, args):
|
|
87
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
88
88
|
return (
|
|
89
89
|
0,
|
|
90
90
|
(
|
|
@@ -106,7 +106,7 @@ class FsLicence(BaseCmd):
|
|
|
106
106
|
options = None
|
|
107
107
|
aliases = ["license"]
|
|
108
108
|
|
|
109
|
-
def execute(self, args):
|
|
109
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
110
110
|
return (
|
|
111
111
|
0,
|
|
112
112
|
(
|
|
@@ -127,7 +127,7 @@ class FsPlugins(BaseCmd):
|
|
|
127
127
|
options = None
|
|
128
128
|
aliases = ["plugin"]
|
|
129
129
|
|
|
130
|
-
def execute(self, args):
|
|
130
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
131
131
|
lines = ["\nInstalled Plugins:"]
|
|
132
132
|
if c.PLUGINS:
|
|
133
133
|
for name, plugin in c.PLUGINS.items():
|
|
@@ -147,7 +147,7 @@ class FsSeason(BaseCmd):
|
|
|
147
147
|
options = None
|
|
148
148
|
aliases = []
|
|
149
149
|
|
|
150
|
-
def execute(self, args):
|
|
150
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
151
151
|
season = seasonal.get_season(return_icons=False)
|
|
152
152
|
if not season:
|
|
153
153
|
return (0, "\nNo seasonal modes are active at present.\n")
|
|
@@ -162,7 +162,7 @@ class FsStatus(BaseCmd):
|
|
|
162
162
|
options = None
|
|
163
163
|
aliases = []
|
|
164
164
|
|
|
165
|
-
def execute(self, args):
|
|
165
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
166
166
|
uptime = int(time.time() - c.SESSION_START_TIME)
|
|
167
167
|
mins, secs = divmod(uptime, 60)
|
|
168
168
|
hours, mins = divmod(mins, 60)
|
|
@@ -195,7 +195,7 @@ class FsVersion(BaseCmd):
|
|
|
195
195
|
options = None
|
|
196
196
|
aliases = []
|
|
197
197
|
|
|
198
|
-
def execute(self, args):
|
|
198
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
199
199
|
return (
|
|
200
200
|
0,
|
|
201
201
|
(
|
|
@@ -212,7 +212,7 @@ class Fs(ParentCmd):
|
|
|
212
212
|
description = "Execute core Flyshell control and utility functions"
|
|
213
213
|
aliases = []
|
|
214
214
|
|
|
215
|
-
def get_subcommands(self):
|
|
215
|
+
def get_subcommands(self) -> list[BaseCmd]:
|
|
216
216
|
return [
|
|
217
217
|
FsDel(),
|
|
218
218
|
FsInfo(),
|
|
@@ -15,7 +15,7 @@ class Cd(BaseCmd):
|
|
|
15
15
|
options = "Directory name (default is Home)"
|
|
16
16
|
aliases = []
|
|
17
17
|
|
|
18
|
-
def execute(self, args):
|
|
18
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
19
19
|
target = os.path.expanduser(" ".join(args)) if args else os.path.expanduser("~")
|
|
20
20
|
try:
|
|
21
21
|
os.chdir(target)
|
|
@@ -27,7 +27,7 @@ class Cd(BaseCmd):
|
|
|
27
27
|
except OSError as e:
|
|
28
28
|
return (
|
|
29
29
|
1,
|
|
30
|
-
f"\nCommand Error: Invalid path syntax '{target}'
|
|
30
|
+
f"\nCommand Error: Invalid path syntax '{target}' ({e.strerror})\n",
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
|
|
@@ -38,7 +38,7 @@ class OpenFile(BaseCmd):
|
|
|
38
38
|
options = "File path"
|
|
39
39
|
aliases = []
|
|
40
40
|
|
|
41
|
-
def execute(self, args):
|
|
41
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
42
42
|
target = " ".join(args).strip().strip('"')
|
|
43
43
|
if not target:
|
|
44
44
|
return (0, "")
|
|
@@ -69,7 +69,7 @@ class SysExe(BaseCmd):
|
|
|
69
69
|
options = "Any host command"
|
|
70
70
|
aliases = []
|
|
71
71
|
|
|
72
|
-
def execute(self, args):
|
|
72
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
73
73
|
if not args:
|
|
74
74
|
return (1, "\nCommand Error: 'sys' requires at least 1 parameter(s).\n")
|
|
75
75
|
try:
|
|
@@ -20,7 +20,7 @@ class Clear(BaseCmd):
|
|
|
20
20
|
options = None
|
|
21
21
|
aliases = ["cls"]
|
|
22
22
|
|
|
23
|
-
def execute(self, args):
|
|
23
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
24
24
|
return (0, c.CLEAR_SCREEN)
|
|
25
25
|
|
|
26
26
|
|
|
@@ -36,7 +36,7 @@ class Echo(BaseCmd):
|
|
|
36
36
|
options = "Message"
|
|
37
37
|
aliases = []
|
|
38
38
|
|
|
39
|
-
def execute(self, args):
|
|
39
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
40
40
|
text = " ".join(args)
|
|
41
41
|
try:
|
|
42
42
|
text = _ESCAPE_SEQ_RE.sub(
|
|
@@ -55,7 +55,7 @@ class History(BaseCmd):
|
|
|
55
55
|
options = "Entry count (default is 10)"
|
|
56
56
|
aliases = []
|
|
57
57
|
|
|
58
|
-
def execute(self, args):
|
|
58
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
59
59
|
limit = 10
|
|
60
60
|
if args:
|
|
61
61
|
sub_arg = args[0].lower()
|
|
@@ -90,7 +90,7 @@ class Kill(BaseCmd):
|
|
|
90
90
|
options = None
|
|
91
91
|
aliases = []
|
|
92
92
|
|
|
93
|
-
def execute(self, args):
|
|
93
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
94
94
|
choice = input("\nAre you sure [y/n]?: ").strip().lower()
|
|
95
95
|
if choice == "y":
|
|
96
96
|
return (-1, "\nShutting down...\n")
|
|
@@ -104,7 +104,7 @@ class Reboot(BaseCmd):
|
|
|
104
104
|
options = None
|
|
105
105
|
aliases = ["restart"]
|
|
106
106
|
|
|
107
|
-
def execute(self, args):
|
|
107
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
108
108
|
print("\nRestarting Flyshell...\n")
|
|
109
109
|
is_direct_script = (
|
|
110
110
|
sys.argv[0].lower().endswith(".exe")
|
|
@@ -133,7 +133,7 @@ class Sleep(BaseCmd):
|
|
|
133
133
|
options = "Duration (secs)"
|
|
134
134
|
aliases = []
|
|
135
135
|
|
|
136
|
-
def execute(self, args):
|
|
136
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
137
137
|
if not args or not args[0].replace(".", "", 1).isdigit():
|
|
138
138
|
return (
|
|
139
139
|
1,
|
|
@@ -5,9 +5,9 @@ import os
|
|
|
5
5
|
import platform
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
BUILD =
|
|
9
|
-
VERFULL = "1.
|
|
10
|
-
VERSION = "1.
|
|
8
|
+
BUILD = 211
|
|
9
|
+
VERFULL = "1.6.1e"
|
|
10
|
+
VERSION = "1.6.1"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _resolve_app_dir() -> Path:
|
|
@@ -36,8 +36,6 @@ SESSION_CMD_COUNT = 0
|
|
|
36
36
|
|
|
37
37
|
PLUGINS = {}
|
|
38
38
|
|
|
39
|
-
BLOCKED_COMMANDS = frozenset({"format", "diskpart", "dd"})
|
|
40
|
-
DANGER_COMMANDS = frozenset({"del", "rmdir", "rd", "rm", "taskkill", "killall"})
|
|
41
39
|
SUPPORTED_OS = frozenset({"Windows", "Darwin", "Linux"})
|
|
42
40
|
SUPPORTED_PYTHON = (3, 10)
|
|
43
41
|
|
|
@@ -28,7 +28,7 @@ def check_readline() -> bool:
|
|
|
28
28
|
return False
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def load_history():
|
|
31
|
+
def load_history() -> None:
|
|
32
32
|
if not readline:
|
|
33
33
|
return
|
|
34
34
|
history_entries = data.get_history(limit=100)
|
|
@@ -37,7 +37,7 @@ def load_history():
|
|
|
37
37
|
readline.add_history(entry["command"])
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def boot():
|
|
40
|
+
def boot() -> None:
|
|
41
41
|
load_history()
|
|
42
42
|
env.create_env()
|
|
43
43
|
print(c.CLEAR_SCREEN, end="")
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
from flyshell import constants as c
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
6
7
|
import json
|
|
7
8
|
import sqlite3
|
|
8
9
|
import time
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def get_storage_size(filename=None) -> str:
|
|
12
|
+
def get_storage_size(filename: str | Path | None = None) -> str:
|
|
12
13
|
target = Path(filename) if filename is not None else c.FILE_PATH
|
|
13
14
|
if not target.exists():
|
|
14
15
|
return "File not found"
|
|
@@ -22,7 +23,7 @@ def get_storage_size(filename=None) -> str:
|
|
|
22
23
|
return f"{num_bytes:.2f} TB"
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
def _get_connection(filename=None):
|
|
26
|
+
def _get_connection(filename: str | Path | None = None) -> sqlite3.Connection:
|
|
26
27
|
target = Path(filename) if filename is not None else c.FILE_PATH
|
|
27
28
|
if str(target) != ":memory:":
|
|
28
29
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -31,7 +32,9 @@ def _get_connection(filename=None):
|
|
|
31
32
|
return conn
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
def initialise(
|
|
35
|
+
def initialise(
|
|
36
|
+
filename: str | Path | None = None, initialised: set[str] | None = None
|
|
37
|
+
) -> None:
|
|
35
38
|
target = filename if filename is not None else c.FILE_PATH
|
|
36
39
|
if initialised is None:
|
|
37
40
|
initialised = c.INITIALISED
|
|
@@ -85,7 +88,7 @@ def initialise(filename=None, initialised=None):
|
|
|
85
88
|
initialised.add(target)
|
|
86
89
|
|
|
87
90
|
|
|
88
|
-
def get_auth(filename=None) -> dict | None:
|
|
91
|
+
def get_auth(filename: str | Path | None = None) -> dict | None:
|
|
89
92
|
initialise(filename)
|
|
90
93
|
with _get_connection(filename) as conn:
|
|
91
94
|
row = conn.execute(
|
|
@@ -101,7 +104,9 @@ def get_auth(filename=None) -> dict | None:
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
|
|
104
|
-
def set_auth(
|
|
107
|
+
def set_auth(
|
|
108
|
+
username: str, pwd_hash: str, salt: str, filename: str | Path | None = None
|
|
109
|
+
) -> None:
|
|
105
110
|
initialise(filename)
|
|
106
111
|
now_utc = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
107
112
|
with _get_connection(filename) as conn:
|
|
@@ -115,7 +120,7 @@ def set_auth(username: str, pwd_hash: str, salt: str, filename=None) -> None:
|
|
|
115
120
|
)
|
|
116
121
|
|
|
117
122
|
|
|
118
|
-
def clear_auth(filename=None) -> bool:
|
|
123
|
+
def clear_auth(filename: str | Path | None = None) -> bool:
|
|
119
124
|
initialise(filename)
|
|
120
125
|
with _get_connection(filename) as conn:
|
|
121
126
|
with conn:
|
|
@@ -123,7 +128,9 @@ def clear_auth(filename=None) -> bool:
|
|
|
123
128
|
return cursor.rowcount > 0
|
|
124
129
|
|
|
125
130
|
|
|
126
|
-
def append_history(
|
|
131
|
+
def append_history(
|
|
132
|
+
cmd: str, timestamp: str, filename: str | Path | None = None
|
|
133
|
+
) -> None:
|
|
127
134
|
initialise(filename)
|
|
128
135
|
with _get_connection(filename) as conn:
|
|
129
136
|
with conn:
|
|
@@ -133,7 +140,9 @@ def append_history(cmd: str, timestamp: str, filename=None) -> None:
|
|
|
133
140
|
)
|
|
134
141
|
|
|
135
142
|
|
|
136
|
-
def get_history(
|
|
143
|
+
def get_history(
|
|
144
|
+
limit: int | None = None, filename: str | Path | None = None
|
|
145
|
+
) -> list[dict]:
|
|
137
146
|
initialise(filename)
|
|
138
147
|
with _get_connection(filename) as conn:
|
|
139
148
|
if limit is not None and limit > 0:
|
|
@@ -148,7 +157,7 @@ def get_history(limit: int | None = None, filename=None) -> list[dict]:
|
|
|
148
157
|
return [{"command": r[0], "timestamp": r[1]} for r in rows]
|
|
149
158
|
|
|
150
159
|
|
|
151
|
-
def clear_history(filename=None) -> bool:
|
|
160
|
+
def clear_history(filename: str | Path | None = None) -> bool:
|
|
152
161
|
initialise(filename)
|
|
153
162
|
with _get_connection(filename) as conn:
|
|
154
163
|
with conn:
|
|
@@ -156,7 +165,9 @@ def clear_history(filename=None) -> bool:
|
|
|
156
165
|
return True
|
|
157
166
|
|
|
158
167
|
|
|
159
|
-
def get_config(
|
|
168
|
+
def get_config(
|
|
169
|
+
key: str, default: Any = None, filename: str | Path | None = None
|
|
170
|
+
) -> Any:
|
|
160
171
|
initialise(filename)
|
|
161
172
|
with _get_connection(filename) as conn:
|
|
162
173
|
row = conn.execute(
|
|
@@ -170,7 +181,7 @@ def get_config(key: str, default=None, filename=None):
|
|
|
170
181
|
return row[0]
|
|
171
182
|
|
|
172
183
|
|
|
173
|
-
def set_config(key: str, value, filename=None) -> None:
|
|
184
|
+
def set_config(key: str, value: Any, filename: str | Path | None = None) -> None:
|
|
174
185
|
initialise(filename)
|
|
175
186
|
serialized = json.dumps(value)
|
|
176
187
|
with _get_connection(filename) as conn:
|
|
@@ -184,7 +195,7 @@ def set_config(key: str, value, filename=None) -> None:
|
|
|
184
195
|
)
|
|
185
196
|
|
|
186
197
|
|
|
187
|
-
def delete_config(key: str, filename=None) -> bool:
|
|
198
|
+
def delete_config(key: str, filename: str | Path | None = None) -> bool:
|
|
188
199
|
initialise(filename)
|
|
189
200
|
with _get_connection(filename) as conn:
|
|
190
201
|
with conn:
|
|
@@ -192,7 +203,7 @@ def delete_config(key: str, filename=None) -> bool:
|
|
|
192
203
|
return cursor.rowcount > 0
|
|
193
204
|
|
|
194
205
|
|
|
195
|
-
def register_plugin(plugin_name: str, filename=None) -> None:
|
|
206
|
+
def register_plugin(plugin_name: str, filename: str | Path | None = None) -> None:
|
|
196
207
|
initialise(filename)
|
|
197
208
|
now_utc = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
198
209
|
with _get_connection(filename) as conn:
|
|
@@ -206,7 +217,9 @@ def register_plugin(plugin_name: str, filename=None) -> None:
|
|
|
206
217
|
)
|
|
207
218
|
|
|
208
219
|
|
|
209
|
-
def get_plugin_data(
|
|
220
|
+
def get_plugin_data(
|
|
221
|
+
plugin_name: str, key: str, default: Any = None, filename: str | Path | None = None
|
|
222
|
+
) -> Any:
|
|
210
223
|
initialise(filename)
|
|
211
224
|
with _get_connection(filename) as conn:
|
|
212
225
|
row = conn.execute(
|
|
@@ -223,7 +236,9 @@ def get_plugin_data(plugin_name: str, key: str, default=None, filename=None):
|
|
|
223
236
|
return row[0]
|
|
224
237
|
|
|
225
238
|
|
|
226
|
-
def set_plugin_data(
|
|
239
|
+
def set_plugin_data(
|
|
240
|
+
plugin_name: str, key: str, value: Any, filename: str | Path | None = None
|
|
241
|
+
) -> None:
|
|
227
242
|
initialise(filename)
|
|
228
243
|
register_plugin(plugin_name, filename=filename)
|
|
229
244
|
serialized = json.dumps(value)
|
|
@@ -238,7 +253,7 @@ def set_plugin_data(plugin_name: str, key: str, value, filename=None) -> None:
|
|
|
238
253
|
)
|
|
239
254
|
|
|
240
255
|
|
|
241
|
-
def get_all_plugin_data(plugin_name: str, filename=None) -> dict:
|
|
256
|
+
def get_all_plugin_data(plugin_name: str, filename: str | Path | None = None) -> dict:
|
|
242
257
|
initialise(filename)
|
|
243
258
|
with _get_connection(filename) as conn:
|
|
244
259
|
rows = conn.execute(
|
|
@@ -253,7 +268,7 @@ def get_all_plugin_data(plugin_name: str, filename=None) -> dict:
|
|
|
253
268
|
return result
|
|
254
269
|
|
|
255
270
|
|
|
256
|
-
def purge_plugin(plugin_name: str, filename=None) -> bool:
|
|
271
|
+
def purge_plugin(plugin_name: str, filename: str | Path | None = None) -> bool:
|
|
257
272
|
initialise(filename)
|
|
258
273
|
with _get_connection(filename) as conn:
|
|
259
274
|
with conn:
|
|
@@ -263,7 +278,7 @@ def purge_plugin(plugin_name: str, filename=None) -> bool:
|
|
|
263
278
|
return cursor.rowcount > 0
|
|
264
279
|
|
|
265
280
|
|
|
266
|
-
def purge_all_plugin_data(filename=None) -> bool:
|
|
281
|
+
def purge_all_plugin_data(filename: str | Path | None = None) -> bool:
|
|
267
282
|
initialise(filename)
|
|
268
283
|
with _get_connection(filename) as conn:
|
|
269
284
|
with conn:
|
|
@@ -272,7 +287,9 @@ def purge_all_plugin_data(filename=None) -> bool:
|
|
|
272
287
|
return True
|
|
273
288
|
|
|
274
289
|
|
|
275
|
-
def delete_plugin_data(
|
|
290
|
+
def delete_plugin_data(
|
|
291
|
+
plugin_name: str, key: str, filename: str | Path | None = None
|
|
292
|
+
) -> bool:
|
|
276
293
|
initialise(filename)
|
|
277
294
|
with _get_connection(filename) as conn:
|
|
278
295
|
with conn:
|
|
@@ -22,7 +22,7 @@ class Cmds(BaseCmd):
|
|
|
22
22
|
options = None
|
|
23
23
|
aliases = ["help"]
|
|
24
24
|
|
|
25
|
-
def execute(self, args):
|
|
25
|
+
def execute(self, args: list[str]) -> tuple[int, str]:
|
|
26
26
|
lines = ["\nAvailable Commands:"]
|
|
27
27
|
seen_cmds = set()
|
|
28
28
|
for cmd in COMMAND_REGISTRY.values():
|
|
@@ -87,7 +87,7 @@ for cmd_obj in INSTALLED_COMMANDS:
|
|
|
87
87
|
RESERVED_NAMES = set(COMMAND_REGISTRY.keys())
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
def log(cmd):
|
|
90
|
+
def log(cmd: str) -> None:
|
|
91
91
|
utc_now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
92
92
|
data.append_history(cmd, utc_now)
|
|
93
93
|
|
|
@@ -284,7 +284,7 @@ def _parse_commands(raw_cmd: str) -> list:
|
|
|
284
284
|
return chain
|
|
285
285
|
|
|
286
286
|
|
|
287
|
-
def execute_line(raw_cmd: str):
|
|
287
|
+
def execute_line(raw_cmd: str) -> None:
|
|
288
288
|
chain = _parse_commands(raw_cmd)
|
|
289
289
|
if not chain:
|
|
290
290
|
return
|