dekshell 0.1.99__py3-none-any.whl → 0.2.1__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.
- dekshell/core/contexts/methods.py +30 -0
- dekshell/core/contexts/properties.py +16 -0
- {dekshell-0.1.99.dist-info → dekshell-0.2.1.dist-info}/METADATA +3 -2
- {dekshell-0.1.99.dist-info → dekshell-0.2.1.dist-info}/RECORD +6 -6
- {dekshell-0.1.99.dist-info → dekshell-0.2.1.dist-info}/WHEEL +0 -0
- {dekshell-0.1.99.dist-info → dekshell-0.2.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import shutil
|
|
2
3
|
import sys
|
|
3
4
|
import tempfile
|
|
4
5
|
import getpass
|
|
@@ -14,12 +15,15 @@ from dektools.net import get_available_port
|
|
|
14
15
|
from dektools.func import FuncAnyArgs
|
|
15
16
|
from dektools.fetch import download_file
|
|
16
17
|
from dektools.download import download_from_http
|
|
18
|
+
from dektools.ps.process import process_detail, process_kill, process_list_all
|
|
17
19
|
from dektools.time import now
|
|
18
20
|
from dektools.str import shlex_split, shlex_quote
|
|
21
|
+
from dektools.shell import shell_wrapper, is_user_admin
|
|
19
22
|
from ...utils.beep import sound_notify
|
|
20
23
|
from ..markers.base.core import MarkerBase, get_inner_vars
|
|
21
24
|
from ..markers.invoke import InvokeMarker, GotoMarker
|
|
22
25
|
from ..redirect import search_bin_by_path_tree
|
|
26
|
+
from .properties import current_os
|
|
23
27
|
|
|
24
28
|
|
|
25
29
|
def _is_true(x):
|
|
@@ -102,6 +106,26 @@ def _xeval(expression, default=_xeval_default, translate=False):
|
|
|
102
106
|
return default
|
|
103
107
|
|
|
104
108
|
|
|
109
|
+
def _install(name):
|
|
110
|
+
def posix(exe):
|
|
111
|
+
s = f"{exe} install -y {name}"
|
|
112
|
+
if is_user_admin():
|
|
113
|
+
s = 'sudo ' + command
|
|
114
|
+
return s
|
|
115
|
+
|
|
116
|
+
if shutil.which('apt-get'):
|
|
117
|
+
command = posix('apt-get')
|
|
118
|
+
elif shutil.which('yum'):
|
|
119
|
+
command = posix('yum')
|
|
120
|
+
elif shutil.which('brew'):
|
|
121
|
+
command = f"brew install {name}"
|
|
122
|
+
elif shutil.which('choco'):
|
|
123
|
+
command = f"choco install -y {name}"
|
|
124
|
+
else:
|
|
125
|
+
raise FileNotFoundError(f"Can't find a valid installer to install {name}")
|
|
126
|
+
shell_wrapper(command)
|
|
127
|
+
|
|
128
|
+
|
|
105
129
|
path_common_methods = {
|
|
106
130
|
'cd': os.chdir,
|
|
107
131
|
'cwd': lambda: os.getcwd(),
|
|
@@ -121,6 +145,7 @@ default_methods = {
|
|
|
121
145
|
'o2s': obj2str,
|
|
122
146
|
'now': now,
|
|
123
147
|
'getpass': getpass.getpass,
|
|
148
|
+
'install': _install,
|
|
124
149
|
'Path': Path,
|
|
125
150
|
'path': {
|
|
126
151
|
**path_common_methods,
|
|
@@ -158,6 +183,11 @@ default_methods = {
|
|
|
158
183
|
'hash': lambda x, name='sha256', args=None: hash_file(name, x, args=args),
|
|
159
184
|
},
|
|
160
185
|
**path_common_methods,
|
|
186
|
+
'pu': {
|
|
187
|
+
'ps': process_list_all,
|
|
188
|
+
'kill': process_kill,
|
|
189
|
+
'pi': process_detail,
|
|
190
|
+
},
|
|
161
191
|
|
|
162
192
|
'compress': compress_files,
|
|
163
193
|
'decompress': decompress_files,
|
|
@@ -2,15 +2,21 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import shutil
|
|
4
4
|
import tempfile
|
|
5
|
+
import sysconfig
|
|
6
|
+
import platform
|
|
5
7
|
from pathlib import Path
|
|
6
8
|
from sysconfig import get_paths
|
|
7
9
|
from importlib import metadata
|
|
10
|
+
from extra_platforms import current_os as extra_platforms_current_os
|
|
8
11
|
from dektools.module import ModuleProxy
|
|
9
12
|
from dektools.time import DateTime
|
|
13
|
+
from dektools.file import read_text
|
|
10
14
|
from ...utils.serializer import serializer
|
|
11
15
|
from ..redirect import shell_name
|
|
12
16
|
|
|
13
17
|
current_shell = shutil.which(shell_name, path=get_paths()['scripts'])
|
|
18
|
+
current_os = extra_platforms_current_os()
|
|
19
|
+
user_is_root = "posix" in os.name and os.geteuid() == 0
|
|
14
20
|
|
|
15
21
|
|
|
16
22
|
def make_shell_properties(shell):
|
|
@@ -54,6 +60,16 @@ default_properties = {
|
|
|
54
60
|
'win': is_on_win,
|
|
55
61
|
'ps': os.pathsep,
|
|
56
62
|
},
|
|
63
|
+
'platform': {
|
|
64
|
+
'cygwin': sys.platform == 'cygwin',
|
|
65
|
+
'mingw': sysconfig.get_platform() == 'mingw',
|
|
66
|
+
'msys': sys.platform == 'msys',
|
|
67
|
+
'wsl': 'Microsoft' in read_text('/proc/version', default=''),
|
|
68
|
+
'win': platform.system() == 'Windows',
|
|
69
|
+
'mac': platform.system() == 'Darwin',
|
|
70
|
+
'linux': platform.system() == 'Linux',
|
|
71
|
+
'x': current_os,
|
|
72
|
+
},
|
|
57
73
|
'path': {
|
|
58
74
|
'root': Path(path_root),
|
|
59
75
|
'home': Path(path_home),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dekshell
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Author-Email: sanzenwin <sanzenwin@gmail.com>
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.8
|
|
7
7
|
Requires-Dist: packaging<=23.1
|
|
8
|
-
Requires-Dist:
|
|
8
|
+
Requires-Dist: extra-platforms<=3.1.0
|
|
9
|
+
Requires-Dist: dektools[date,fetch,ps,tab]<1.0.0
|
|
9
10
|
Requires-Dist: dekmedia[audio]<1.0.0
|
|
10
11
|
Description-Content-Type: text/markdown
|
|
11
12
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
dekshell-0.1.
|
|
2
|
-
dekshell-0.1.
|
|
3
|
-
dekshell-0.1.
|
|
1
|
+
dekshell-0.2.1.dist-info/METADATA,sha256=0jGedm9N3S639uZTygfJFhKUKA6Q_5LxEvPcZ5Tk8iA,565
|
|
2
|
+
dekshell-0.2.1.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
|
3
|
+
dekshell-0.2.1.dist-info/entry_points.txt,sha256=d-kbfULiUTZWIBBsrQF3J_-wESncF-4K2rwHT08grlI,75
|
|
4
4
|
dekshell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
dekshell/click/__entry__.py,sha256=CMuxUzXoEe4TcHFZwv-MNFwHnu1HSZCDpXFpqQ814uM,42
|
|
6
6
|
dekshell/click/__init__.py,sha256=rFzB_exzPQaIcbbms5PdHAU3NGdl2MBaYbq9v7g7BOI,1870
|
|
7
7
|
dekshell/core/__init__.py,sha256=Cp--1j2jpJzchXR98HiRp2QAiOHz8HXm8iy6ZChIWmc,5207
|
|
8
8
|
dekshell/core/contexts/__init__.py,sha256=ynsfv37azOKfI2UKd0iPl2M6iBW-k5cb1BqSLOWuJpI,482
|
|
9
|
-
dekshell/core/contexts/methods.py,sha256=
|
|
10
|
-
dekshell/core/contexts/properties.py,sha256=
|
|
9
|
+
dekshell/core/contexts/methods.py,sha256=x2htk99DWVj6pR1HS5KPXGIG7t60xA1MXJi8SsOyTpw,6372
|
|
10
|
+
dekshell/core/contexts/properties.py,sha256=e_QRqH7nflvCT14BD9z6_dg9KVMXkRNtVjE11wBFqFM,2204
|
|
11
11
|
dekshell/core/markers/__init__.py,sha256=bmGMbZRqsOohMKjH0AReFxZ-nIPFF6YgPJMFT6gTJEw,1725
|
|
12
12
|
dekshell/core/markers/base/__init__.py,sha256=AQYr7H0F06izu5jhu8EgLYJ2ERzJh0eS38h9gtl6OZs,13067
|
|
13
13
|
dekshell/core/markers/base/core.py,sha256=99aRcSXohpfTW5OSO1CUyvnptr21ueKjizCk-FK6rcM,10830
|
|
@@ -36,4 +36,4 @@ dekshell/utils/cmd.py,sha256=_WG7K-CO-WQkI9ERyrhI2d4yT-DX3OjjJWbNzhmsPus,1197
|
|
|
36
36
|
dekshell/utils/pkg.py,sha256=TgYqRqawoJfjkxt6UAHnp9ttmpjuHiWRFbqxADOS1VE,1337
|
|
37
37
|
dekshell/utils/serializer.py,sha256=aIdF2Wzo-qHmIshv46jn1XD0X66vQ1JFdU-g3ZFbH2w,386
|
|
38
38
|
dekshell/utils/shell.py,sha256=0NoA2-SOOMinbmZZipwzL-npBbzPOdWEfdPVYqq5G5g,92
|
|
39
|
-
dekshell-0.1.
|
|
39
|
+
dekshell-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|