flyshell 1.3.5__cp313-cp313-win_amd64.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.
- flyshell/__init__.py +22 -0
- flyshell/_native_disk.cp313-win_amd64.pyd +0 -0
- flyshell/abstract/__init__.py +0 -0
- flyshell/abstract/base_cmd.py +29 -0
- flyshell/abstract/base_plugin.py +89 -0
- flyshell/abstract/parent_cmd.py +70 -0
- flyshell/accounts/__init__.py +0 -0
- flyshell/accounts/auth.py +120 -0
- flyshell/builtin/__init__.py +0 -0
- flyshell/builtin/diskops.py +555 -0
- flyshell/builtin/fs.py +209 -0
- flyshell/builtin/pkg.py +60 -0
- flyshell/builtin/system.py +124 -0
- flyshell/builtin/utils.py +137 -0
- flyshell/constants.py +84 -0
- flyshell/core/__init__.py +0 -0
- flyshell/core/console.py +60 -0
- flyshell/core/data.py +264 -0
- flyshell/core/directory.py +308 -0
- flyshell/main.py +127 -0
- flyshell/startup/__init__.py +0 -0
- flyshell/startup/deps.py +24 -0
- flyshell/startup/env.py +194 -0
- flyshell/startup/loader.py +177 -0
- flyshell-1.3.5.dist-info/METADATA +209 -0
- flyshell-1.3.5.dist-info/RECORD +30 -0
- flyshell-1.3.5.dist-info/WHEEL +5 -0
- flyshell-1.3.5.dist-info/entry_points.txt +2 -0
- flyshell-1.3.5.dist-info/licenses/LICENSE +21 -0
- flyshell-1.3.5.dist-info/top_level.txt +1 -0
flyshell/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# src/flyshell/__init__.py
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from flyshell.abstract.base_plugin import BasePlugin
|
|
5
|
+
|
|
6
|
+
__all__ = ["BasePlugin"]
|
|
7
|
+
except ImportError:
|
|
8
|
+
BasePlugin = None
|
|
9
|
+
__all__ = []
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from . import _native_disk
|
|
15
|
+
except ImportError:
|
|
16
|
+
_native_disk = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def check_native() -> bool:
|
|
20
|
+
if _native_disk is not None:
|
|
21
|
+
return _native_disk.ping() == 42
|
|
22
|
+
return False
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# src/flyshell/abstract/base_cmd.py
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional, Tuple
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseCmd:
|
|
7
|
+
name: str = ""
|
|
8
|
+
description: str = ""
|
|
9
|
+
min_args: int = 0
|
|
10
|
+
options: Optional[str] = None
|
|
11
|
+
aliases: List[str] = []
|
|
12
|
+
|
|
13
|
+
def execute(self, args: List[str]) -> Tuple[int, str]:
|
|
14
|
+
raise NotImplementedError(
|
|
15
|
+
f"Command '{self.__class__.__name__}' has not implemented the execute method"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def help(self, prefix: str = ""):
|
|
19
|
+
full_name = f"{prefix} {self.name}".strip() if prefix else self.name
|
|
20
|
+
print(f"\nCommand: {full_name}")
|
|
21
|
+
if prefix:
|
|
22
|
+
print(f"Parent: Part of the '{prefix}' family of commands")
|
|
23
|
+
if self.aliases:
|
|
24
|
+
print(f"Aliases: {', '.join(self.aliases)}")
|
|
25
|
+
print(f"Description: {self.description}")
|
|
26
|
+
print(f"Required Arguments: {self.min_args}")
|
|
27
|
+
if self.options:
|
|
28
|
+
print(f"Accepted Arguments: {self.options}")
|
|
29
|
+
print()
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# src/flyshell/abstract/base_plugin.py
|
|
2
|
+
|
|
3
|
+
from flyshell.core import data
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BasePlugin:
|
|
9
|
+
name: str = "Unnamed Plugin"
|
|
10
|
+
description: str = "No description provided."
|
|
11
|
+
version: str = "1.0.0"
|
|
12
|
+
author: str = "Unknown"
|
|
13
|
+
identifier: str = ""
|
|
14
|
+
usage: str = ""
|
|
15
|
+
extended_help: str = ""
|
|
16
|
+
api_keys: list = []
|
|
17
|
+
third_pty_libs: list = []
|
|
18
|
+
|
|
19
|
+
def __init__(self, context: dict):
|
|
20
|
+
self.context = context
|
|
21
|
+
self.plugin_name = context.get("plugin_name", self.name)
|
|
22
|
+
self.storage = context.get("storage", {})
|
|
23
|
+
self.api_keys_data = context.get("api_keys", {})
|
|
24
|
+
self.env_file_path = context.get("env_path", None)
|
|
25
|
+
self.on_load()
|
|
26
|
+
|
|
27
|
+
def get_api_key(self, key_name: str, default=None):
|
|
28
|
+
return self.api_keys_data.get(key_name, default)
|
|
29
|
+
|
|
30
|
+
def on_load(self):
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
def on_unload(self):
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
def execute(self, args: list):
|
|
37
|
+
raise NotImplementedError("Plugins must implement the execute method")
|
|
38
|
+
|
|
39
|
+
def help(self):
|
|
40
|
+
lines = [
|
|
41
|
+
f"\nPlugin: {self.name} (v{self.version})",
|
|
42
|
+
f"Description: {self.description}",
|
|
43
|
+
f"Author: {self.author}",
|
|
44
|
+
]
|
|
45
|
+
if self.usage:
|
|
46
|
+
lines.append(f"Usage: {self.usage}")
|
|
47
|
+
if self.extended_help:
|
|
48
|
+
lines.append("\nDetails:")
|
|
49
|
+
lines.append(self.extended_help)
|
|
50
|
+
if self.api_keys:
|
|
51
|
+
lines.append("\nThis plugin requires one or more API keys.")
|
|
52
|
+
if self.third_pty_libs:
|
|
53
|
+
lines.append("\nThis plugin requires third party dependencies.")
|
|
54
|
+
print("\n".join(lines))
|
|
55
|
+
|
|
56
|
+
def show_docs(self) -> bool:
|
|
57
|
+
plugin_path = self.context.get("file_path")
|
|
58
|
+
if plugin_path:
|
|
59
|
+
p = Path(plugin_path)
|
|
60
|
+
doc_file = (p.parent / "README.md") if p.is_file() else (p / "README.md")
|
|
61
|
+
if doc_file.exists():
|
|
62
|
+
print(f"\nDocumentation: {self.name}")
|
|
63
|
+
print(doc_file.read_text(encoding="utf-8"))
|
|
64
|
+
print("-" * 40)
|
|
65
|
+
return True
|
|
66
|
+
if self.__doc__:
|
|
67
|
+
print(f"\nDocumentation: {self.name}")
|
|
68
|
+
print(self.__doc__.strip())
|
|
69
|
+
print("-" * 40)
|
|
70
|
+
return True
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
def get_data(self, key: str, default=None):
|
|
74
|
+
return self.storage.get(key, default)
|
|
75
|
+
|
|
76
|
+
def set_data(self, key: str, value):
|
|
77
|
+
self.storage[key] = value
|
|
78
|
+
self.save_storage()
|
|
79
|
+
|
|
80
|
+
def load_storage(self) -> dict:
|
|
81
|
+
fresh_data = data.get_all_plugin_data(self.plugin_name)
|
|
82
|
+
self.storage = fresh_data
|
|
83
|
+
self.context["storage"] = fresh_data
|
|
84
|
+
return self.storage
|
|
85
|
+
|
|
86
|
+
def save_storage(self):
|
|
87
|
+
for k, v in self.storage.items():
|
|
88
|
+
data.set_plugin_data(self.plugin_name, k, v)
|
|
89
|
+
self.context["storage"] = self.storage
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# src/flyshell/abstract/parent_cmd.py
|
|
2
|
+
|
|
3
|
+
from flyshell.abstract.base_cmd import BaseCmd
|
|
4
|
+
|
|
5
|
+
from typing import Dict, List, Tuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ParentCmd(BaseCmd):
|
|
9
|
+
min_args: int = 1
|
|
10
|
+
subcommands: Dict[str, BaseCmd] = {}
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
super().__init__() if hasattr(super(), "__init__") else None
|
|
14
|
+
self._sub_registry: Dict[str, BaseCmd] = {}
|
|
15
|
+
self._build_registry()
|
|
16
|
+
|
|
17
|
+
def _build_registry(self):
|
|
18
|
+
for cmd_obj in self.get_subcommands():
|
|
19
|
+
self._sub_registry[cmd_obj.name] = cmd_obj
|
|
20
|
+
for alias in getattr(cmd_obj, "aliases", []):
|
|
21
|
+
self._sub_registry[alias] = cmd_obj
|
|
22
|
+
|
|
23
|
+
def get_subcommands(self) -> List[BaseCmd]:
|
|
24
|
+
return []
|
|
25
|
+
|
|
26
|
+
def help(self):
|
|
27
|
+
print(f"\nCommand Family: {self.name}")
|
|
28
|
+
print(f"Description: {self.description}")
|
|
29
|
+
print(f"\nSubcommands of '{self.name}':")
|
|
30
|
+
seen = set()
|
|
31
|
+
for sub in self._sub_registry.values():
|
|
32
|
+
if sub in seen:
|
|
33
|
+
continue
|
|
34
|
+
seen.add(sub)
|
|
35
|
+
label = (
|
|
36
|
+
f"{sub.name} (alias: {', '.join(sub.aliases)})"
|
|
37
|
+
if sub.aliases
|
|
38
|
+
else sub.name
|
|
39
|
+
)
|
|
40
|
+
opt = f" [args: {sub.options}]" if sub.options else ""
|
|
41
|
+
print(f"{label} - {sub.description}{opt}")
|
|
42
|
+
print(
|
|
43
|
+
f"\nFor subcommand assistance use '{self.name} <subcmd> -h' or '--help'\n"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def execute(self, args: List[str]) -> Tuple[int, str]:
|
|
47
|
+
if not args or args[0] in ("-h", "--help"):
|
|
48
|
+
self.help()
|
|
49
|
+
return (0, "")
|
|
50
|
+
sub_name = args[0].lower()
|
|
51
|
+
sub_args = args[1:]
|
|
52
|
+
if sub_name not in self._sub_registry:
|
|
53
|
+
err = (
|
|
54
|
+
f"\nCommand Error: Unknown subcommand '{sub_name}' for '{self.name}'.\n"
|
|
55
|
+
f"Use '{self.name} -h' or '--help' to see all valid subcommands.\n"
|
|
56
|
+
)
|
|
57
|
+
return (1, err)
|
|
58
|
+
target = self._sub_registry[sub_name]
|
|
59
|
+
if "-h" in sub_args or "--help" in sub_args:
|
|
60
|
+
target.help(prefix=self.name)
|
|
61
|
+
return (0, "")
|
|
62
|
+
if len(sub_args) < target.min_args:
|
|
63
|
+
err_lines = [
|
|
64
|
+
f"\nCommand Error: '{self.name} {target.name}' requires at least {target.min_args} argument(s)."
|
|
65
|
+
]
|
|
66
|
+
if target.options:
|
|
67
|
+
err_lines.append(f"Accepted arguments: {target.options}")
|
|
68
|
+
err_lines.append("")
|
|
69
|
+
return (1, "\n".join(err_lines))
|
|
70
|
+
return target.execute(sub_args)
|
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# src/flyshell/accounts/auth.py
|
|
2
|
+
|
|
3
|
+
from flyshell.abstract.base_cmd import BaseCmd
|
|
4
|
+
from flyshell.core import data
|
|
5
|
+
|
|
6
|
+
import getpass
|
|
7
|
+
import hashlib
|
|
8
|
+
import re
|
|
9
|
+
import secrets
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def hash_password(password, salt=None):
|
|
13
|
+
if salt is None:
|
|
14
|
+
salt = secrets.token_bytes(16)
|
|
15
|
+
elif isinstance(salt, str):
|
|
16
|
+
salt = bytes.fromhex(salt)
|
|
17
|
+
pwd_hash = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"), salt, 600000)
|
|
18
|
+
return pwd_hash.hex(), salt.hex()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def verify_password(stored_hash: str, stored_salt: str, password: str) -> bool:
|
|
22
|
+
if not stored_hash or not stored_salt or not password:
|
|
23
|
+
return False
|
|
24
|
+
try:
|
|
25
|
+
salt_bytes = bytes.fromhex(stored_salt)
|
|
26
|
+
attempt_hash, _ = hash_password(password, salt_bytes)
|
|
27
|
+
return secrets.compare_digest(attempt_hash, stored_hash)
|
|
28
|
+
except (ValueError, TypeError):
|
|
29
|
+
return False
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def setup_acc() -> bool:
|
|
33
|
+
print("\nWelcome to Flyshell, New User!")
|
|
34
|
+
print("Please follow the prompts to create your Flyshell profile.")
|
|
35
|
+
while True:
|
|
36
|
+
username = input("Create Username: ").strip()
|
|
37
|
+
if not username:
|
|
38
|
+
print("\nAccount Error: Username cannot be empty.\n")
|
|
39
|
+
else:
|
|
40
|
+
print(f"\nUsername set as '{username}'\n")
|
|
41
|
+
break
|
|
42
|
+
i = 5
|
|
43
|
+
print("Your password MUST:")
|
|
44
|
+
print("- Contain at least 10 total characters")
|
|
45
|
+
print("- Contain 1 or more upper case letters")
|
|
46
|
+
print("- Contain 1 or more lower case letters")
|
|
47
|
+
print("- Contain 1 or more numbers")
|
|
48
|
+
print("- Contain 1 or more special characters\n")
|
|
49
|
+
while i > 0:
|
|
50
|
+
password = getpass.getpass("Create Password: ")
|
|
51
|
+
confirm = getpass.getpass("Confirm Password: ")
|
|
52
|
+
if password != confirm:
|
|
53
|
+
print("\nAccount Error: Passwords do not match.")
|
|
54
|
+
i -= 1
|
|
55
|
+
if i == 0:
|
|
56
|
+
print("Too many attempts.\n")
|
|
57
|
+
return False
|
|
58
|
+
print(f"You have {i} attempts remaining.\n")
|
|
59
|
+
continue
|
|
60
|
+
has_upper = any(char.isupper() for char in password)
|
|
61
|
+
has_lower = any(char.islower() for char in password)
|
|
62
|
+
has_digit = any(char.isdigit() for char in password)
|
|
63
|
+
has_speci = bool(re.search(r"[^a-zA-Z0-9]", password))
|
|
64
|
+
if len(password) >= 10 and has_upper and has_lower and has_digit and has_speci:
|
|
65
|
+
break
|
|
66
|
+
else:
|
|
67
|
+
print("\nAccount Error: Password does not meet required conditions.\n")
|
|
68
|
+
i -= 1
|
|
69
|
+
if i == 0:
|
|
70
|
+
print("Too many attempts.\n")
|
|
71
|
+
return False
|
|
72
|
+
print(f"You have {i} attempts remaining.\n")
|
|
73
|
+
continue
|
|
74
|
+
pwd_hash, salt = hash_password(password)
|
|
75
|
+
data.set_auth(username, pwd_hash, salt)
|
|
76
|
+
print("\nSUCCESS: Account created successfully!")
|
|
77
|
+
return True
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def login_flow(is_lock=False) -> bool:
|
|
81
|
+
auth_info = data.get_auth()
|
|
82
|
+
if not auth_info or "hash" not in auth_info:
|
|
83
|
+
if not setup_acc():
|
|
84
|
+
return False
|
|
85
|
+
auth_info = data.get_auth()
|
|
86
|
+
stored_user = auth_info.get("username", "User")
|
|
87
|
+
stored_hash = auth_info.get("hash")
|
|
88
|
+
stored_salt = auth_info.get("salt")
|
|
89
|
+
if is_lock:
|
|
90
|
+
input("\nFlyshell is locked. To unlock, press ENTER.")
|
|
91
|
+
print(f"\nWelcome back, {stored_user}!")
|
|
92
|
+
else:
|
|
93
|
+
print(f"\nWelcome, {stored_user}!")
|
|
94
|
+
i = 5
|
|
95
|
+
while i > 0:
|
|
96
|
+
entered_pwd = getpass.getpass("Enter Password: ")
|
|
97
|
+
if verify_password(stored_hash, stored_salt, entered_pwd):
|
|
98
|
+
if is_lock:
|
|
99
|
+
print()
|
|
100
|
+
return True
|
|
101
|
+
i -= 1
|
|
102
|
+
print("\nAccount Error: Password does not match.")
|
|
103
|
+
if i == 0:
|
|
104
|
+
print("Too many attempts.")
|
|
105
|
+
return False
|
|
106
|
+
print(f"You have {i} attempts remaining.\n")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Lock(BaseCmd):
|
|
110
|
+
name = "lock"
|
|
111
|
+
description = "Lock the Flyshell system"
|
|
112
|
+
min_args = 0
|
|
113
|
+
options = None
|
|
114
|
+
aliases = []
|
|
115
|
+
|
|
116
|
+
def execute(self, args):
|
|
117
|
+
if login_flow(is_lock=True):
|
|
118
|
+
return (0, "")
|
|
119
|
+
else:
|
|
120
|
+
return (-1, "\nShutting down...\n")
|
|
File without changes
|