kaqing 2.0.211__py3-none-any.whl → 2.0.213__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 kaqing might be problematic. Click here for more details.
- adam/commands/fs/__init__.py +0 -0
- adam/commands/fs/cat.py +36 -0
- adam/commands/fs/cat_local.py +42 -0
- adam/commands/fs/cd.py +41 -0
- adam/commands/fs/download_file.py +47 -0
- adam/commands/fs/find_files.py +51 -0
- adam/commands/fs/find_processes.py +76 -0
- adam/commands/fs/head.py +36 -0
- adam/commands/fs/ls.py +41 -0
- adam/commands/fs/ls_local.py +40 -0
- adam/commands/fs/rm.py +18 -0
- adam/commands/fs/rm_downloads.py +39 -0
- adam/commands/fs/rm_logs.py +38 -0
- adam/commands/fs/shell.py +41 -0
- adam/repl_commands.py +3 -1
- adam/version.py +1 -1
- {kaqing-2.0.211.dist-info → kaqing-2.0.213.dist-info}/METADATA +1 -1
- {kaqing-2.0.211.dist-info → kaqing-2.0.213.dist-info}/RECORD +21 -7
- {kaqing-2.0.211.dist-info → kaqing-2.0.213.dist-info}/WHEEL +0 -0
- {kaqing-2.0.211.dist-info → kaqing-2.0.213.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.211.dist-info → kaqing-2.0.213.dist-info}/top_level.txt +0 -0
|
File without changes
|
adam/commands/fs/cat.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from adam.commands import validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.repl_state import ReplState, RequiredState
|
|
5
|
+
|
|
6
|
+
class Cat(Command):
|
|
7
|
+
COMMAND = 'cat'
|
|
8
|
+
|
|
9
|
+
# the singleton pattern
|
|
10
|
+
def __new__(cls, *args, **kwargs):
|
|
11
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Cat, cls).__new__(cls)
|
|
12
|
+
|
|
13
|
+
return cls.instance
|
|
14
|
+
|
|
15
|
+
def __init__(self, successor: Command=None):
|
|
16
|
+
super().__init__(successor)
|
|
17
|
+
|
|
18
|
+
def command(self):
|
|
19
|
+
return Cat.COMMAND
|
|
20
|
+
|
|
21
|
+
def required(self):
|
|
22
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
23
|
+
|
|
24
|
+
def run(self, cmd: str, state: ReplState):
|
|
25
|
+
if not(args := self.args(cmd)):
|
|
26
|
+
return super().run(cmd, state)
|
|
27
|
+
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
with validate_args(args, state, name='file'):
|
|
30
|
+
return Devices.of(state).bash(state, state, cmd.split(' '))
|
|
31
|
+
|
|
32
|
+
def completion(self, state: ReplState):
|
|
33
|
+
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
34
|
+
|
|
35
|
+
def help(self, _: ReplState):
|
|
36
|
+
return f'{Cat.COMMAND} file [&]\t run cat command on the pod'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands import validate_args
|
|
4
|
+
from adam.commands.command import Command
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
from adam.utils_local import find_local_files
|
|
8
|
+
|
|
9
|
+
class CatLocal(Command):
|
|
10
|
+
COMMAND = ':cat'
|
|
11
|
+
|
|
12
|
+
# the singleton pattern
|
|
13
|
+
def __new__(cls, *args, **kwargs):
|
|
14
|
+
if not hasattr(cls, 'instance'): cls.instance = super(CatLocal, cls).__new__(cls)
|
|
15
|
+
|
|
16
|
+
return cls.instance
|
|
17
|
+
|
|
18
|
+
def __init__(self, successor: Command=None):
|
|
19
|
+
super().__init__(successor)
|
|
20
|
+
|
|
21
|
+
def command(self):
|
|
22
|
+
return CatLocal.COMMAND
|
|
23
|
+
|
|
24
|
+
def required(self):
|
|
25
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
26
|
+
|
|
27
|
+
def run(self, cmd: str, state: ReplState):
|
|
28
|
+
if not(args := self.args(cmd)):
|
|
29
|
+
return super().run(cmd, state)
|
|
30
|
+
|
|
31
|
+
with self.validate(args, state) as (args, state):
|
|
32
|
+
with validate_args(args, state, name='file') as args:
|
|
33
|
+
os.system(f'cat {args}')
|
|
34
|
+
log2()
|
|
35
|
+
|
|
36
|
+
return state
|
|
37
|
+
|
|
38
|
+
def completion(self, state: ReplState):
|
|
39
|
+
return super().completion(state, lambda: {n: None for n in find_local_files(file_type='f', max_depth=1)}, auto='jit')
|
|
40
|
+
|
|
41
|
+
def help(self, _: ReplState):
|
|
42
|
+
return f'{CatLocal.COMMAND} file\t run cat command on local system'
|
adam/commands/fs/cd.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from adam.commands import validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.device import Device
|
|
4
|
+
from adam.commands.devices.devices import Devices
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
|
|
7
|
+
class Cd(Command):
|
|
8
|
+
COMMAND = 'cd'
|
|
9
|
+
|
|
10
|
+
# the singleton pattern
|
|
11
|
+
def __new__(cls, *args, **kwargs):
|
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Cd, cls).__new__(cls)
|
|
13
|
+
|
|
14
|
+
return cls.instance
|
|
15
|
+
|
|
16
|
+
def __init__(self, successor: Command=None):
|
|
17
|
+
super().__init__(successor)
|
|
18
|
+
|
|
19
|
+
def command(self):
|
|
20
|
+
return Cd.COMMAND
|
|
21
|
+
|
|
22
|
+
def required(self):
|
|
23
|
+
return ReplState.NON_L
|
|
24
|
+
|
|
25
|
+
def run(self, cmd: str, state: ReplState):
|
|
26
|
+
if not(args := self.args(cmd)):
|
|
27
|
+
return super().run(cmd, state)
|
|
28
|
+
|
|
29
|
+
with self.validate(args, state, apply=False) as (args, state):
|
|
30
|
+
with validate_args(args, state, name='directory') as arg_str:
|
|
31
|
+
device: Device = Devices.of(state)
|
|
32
|
+
for dir in arg_str.split('/'):
|
|
33
|
+
device.cd(dir, state)
|
|
34
|
+
|
|
35
|
+
return state
|
|
36
|
+
|
|
37
|
+
def completion(self, state: ReplState):
|
|
38
|
+
return Devices.of(state).cd_completion(Cd.COMMAND, state, default = {})
|
|
39
|
+
|
|
40
|
+
def help(self, _: ReplState):
|
|
41
|
+
return f'{Cd.COMMAND} <path> | .. \t move around on the operational device hierarchy'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands import validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.utils_k8s.pod_exec_result import PodExecResult
|
|
6
|
+
from adam.repl_state import ReplState, RequiredState
|
|
7
|
+
from adam.utils import log2
|
|
8
|
+
from adam.utils_k8s.pods import Pods
|
|
9
|
+
|
|
10
|
+
class DownloadFile(Command):
|
|
11
|
+
COMMAND = 'download file'
|
|
12
|
+
|
|
13
|
+
# the singleton pattern
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(cls, 'instance'): cls.instance = super(DownloadFile, cls).__new__(cls)
|
|
16
|
+
|
|
17
|
+
return cls.instance
|
|
18
|
+
|
|
19
|
+
def __init__(self, successor: Command=None):
|
|
20
|
+
super().__init__(successor)
|
|
21
|
+
|
|
22
|
+
def command(self):
|
|
23
|
+
return DownloadFile.COMMAND
|
|
24
|
+
|
|
25
|
+
def required(self):
|
|
26
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
27
|
+
|
|
28
|
+
def run(self, cmd: str, state: ReplState):
|
|
29
|
+
if not(args := self.args(cmd)):
|
|
30
|
+
return super().run(cmd, state)
|
|
31
|
+
|
|
32
|
+
with self.validate(args, state) as (args, state):
|
|
33
|
+
with validate_args(args, state, name='file'):
|
|
34
|
+
to_file = Pods.download_file(Devices.of(state).pod(state),
|
|
35
|
+
Devices.of(state).default_container(state),
|
|
36
|
+
state.namespace,
|
|
37
|
+
args[0],
|
|
38
|
+
args[1] if len(args) > 1 else None)
|
|
39
|
+
log2(f'Downloaded to {to_file}.')
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
45
|
+
|
|
46
|
+
def help(self, _: ReplState):
|
|
47
|
+
return f'{DownloadFile.COMMAND} from-file [to-file]\t download file from pod'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.repl_state import ReplState
|
|
5
|
+
from adam.utils import log2
|
|
6
|
+
from adam.utils_local import local_qing_dir
|
|
7
|
+
|
|
8
|
+
class FindLocalFiles(Command):
|
|
9
|
+
COMMAND = ':find file'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(FindLocalFiles, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return FindLocalFiles.COMMAND
|
|
22
|
+
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
24
|
+
if not(args := self.args(cmd)):
|
|
25
|
+
return super().run(cmd, state)
|
|
26
|
+
|
|
27
|
+
with self.validate(args, state) as (args, state):
|
|
28
|
+
cmd = 'find'
|
|
29
|
+
|
|
30
|
+
if not args:
|
|
31
|
+
cmd = f'find {local_qing_dir()}'
|
|
32
|
+
elif len(args) == 1:
|
|
33
|
+
cmd = f"find {local_qing_dir()} -name '{args[0]}'"
|
|
34
|
+
else:
|
|
35
|
+
new_args = [f"'{arg}'" if '*' in arg else arg for arg in args]
|
|
36
|
+
cmd = 'find ' + ' '.join(new_args)
|
|
37
|
+
|
|
38
|
+
log2(cmd)
|
|
39
|
+
os.system(cmd)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, {
|
|
45
|
+
'*.csv': None,
|
|
46
|
+
'*.db': None,
|
|
47
|
+
'*': None
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
def help(self, _: ReplState):
|
|
51
|
+
return f'{FindLocalFiles.COMMAND} [linux-find-arguments]\t find files from local machine'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from adam.commands import extract_options, validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.commands.export.utils_export import state_with_pod
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2, tabulize
|
|
7
|
+
|
|
8
|
+
class FindProcesses(Command):
|
|
9
|
+
COMMAND = 'find processes'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(FindProcesses, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return FindProcesses.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
with extract_options(args, '-kill') as (args, kill):
|
|
32
|
+
with validate_args(args, state, name='words to look for'):
|
|
33
|
+
arg = ' | '.join([f'grep {a}' for a in args])
|
|
34
|
+
awk = "awk '{ print $1, $2, $8, $NF }'"
|
|
35
|
+
rs = Devices.of(state).bash(state, state, f"ps -ef | grep -v grep | {arg} | {awk}".split(' '))
|
|
36
|
+
|
|
37
|
+
lines: list[list[str]] = []
|
|
38
|
+
for r in rs:
|
|
39
|
+
for l in r.stdout.split('\n'):
|
|
40
|
+
l = l.strip(' \t\r\n')
|
|
41
|
+
if not l:
|
|
42
|
+
continue
|
|
43
|
+
|
|
44
|
+
tokens = [r.pod] + l.split(' ')
|
|
45
|
+
lines.append(tokens)
|
|
46
|
+
|
|
47
|
+
pids = []
|
|
48
|
+
for l in lines:
|
|
49
|
+
pids.append(f'{l[2]}@{l[0]}')
|
|
50
|
+
|
|
51
|
+
tabulize(lines, lambda l: '\t'.join(l), header = 'POD\tUSER\tPID\tCMD\tLAST_ARG', separator='\t')
|
|
52
|
+
log2()
|
|
53
|
+
log2(f'PIDS with {",".join(args)}: {",".join(pids)}')
|
|
54
|
+
|
|
55
|
+
if kill:
|
|
56
|
+
log2()
|
|
57
|
+
for pidp in pids:
|
|
58
|
+
pid_n_pod = pidp.split('@')
|
|
59
|
+
pid = pid_n_pod[0]
|
|
60
|
+
if len(pid_n_pod) < 2:
|
|
61
|
+
continue
|
|
62
|
+
|
|
63
|
+
pod = pid_n_pod[1]
|
|
64
|
+
|
|
65
|
+
log2(f'@{pod} bash kill -9 {pid}')
|
|
66
|
+
|
|
67
|
+
with state_with_pod(state, pod) as state1:
|
|
68
|
+
Devices.of(state).bash(state, state1, ['kill', '-9', pid])
|
|
69
|
+
|
|
70
|
+
return rs
|
|
71
|
+
|
|
72
|
+
def completion(self, state: ReplState):
|
|
73
|
+
return super().completion(state)
|
|
74
|
+
|
|
75
|
+
def help(self, _: ReplState):
|
|
76
|
+
return f'{FindProcesses.COMMAND} word... [-kill]\t find processes with words'
|
adam/commands/fs/head.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from adam.commands import validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.repl_state import ReplState, RequiredState
|
|
5
|
+
|
|
6
|
+
class Head(Command):
|
|
7
|
+
COMMAND = 'head'
|
|
8
|
+
|
|
9
|
+
# the singleton pattern
|
|
10
|
+
def __new__(cls, *args, **kwargs):
|
|
11
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Head, cls).__new__(cls)
|
|
12
|
+
|
|
13
|
+
return cls.instance
|
|
14
|
+
|
|
15
|
+
def __init__(self, successor: Command=None):
|
|
16
|
+
super().__init__(successor)
|
|
17
|
+
|
|
18
|
+
def command(self):
|
|
19
|
+
return Head.COMMAND
|
|
20
|
+
|
|
21
|
+
def required(self):
|
|
22
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
23
|
+
|
|
24
|
+
def run(self, cmd: str, state: ReplState):
|
|
25
|
+
if not(args := self.args(cmd)):
|
|
26
|
+
return super().run(cmd, state)
|
|
27
|
+
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
with validate_args(args, state, name='file'):
|
|
30
|
+
return Devices.of(state).bash(state, state, cmd.split(' '))
|
|
31
|
+
|
|
32
|
+
def completion(self, state: ReplState):
|
|
33
|
+
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
34
|
+
|
|
35
|
+
def help(self, _: ReplState):
|
|
36
|
+
return f'{Head.COMMAND} file [&]\t run head command on the pod'
|
adam/commands/fs/ls.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.commands.devices.devices import Devices
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
|
|
7
|
+
class Ls(Command):
|
|
8
|
+
COMMAND = 'ls'
|
|
9
|
+
|
|
10
|
+
# the singleton pattern
|
|
11
|
+
def __new__(cls, *args, **kwargs):
|
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Ls, cls).__new__(cls)
|
|
13
|
+
|
|
14
|
+
return cls.instance
|
|
15
|
+
|
|
16
|
+
def __init__(self, successor: Command=None):
|
|
17
|
+
super().__init__(successor)
|
|
18
|
+
|
|
19
|
+
def command(self):
|
|
20
|
+
return Ls.COMMAND
|
|
21
|
+
|
|
22
|
+
def run(self, cmd: str, state: ReplState):
|
|
23
|
+
if not(args := self.args(cmd)):
|
|
24
|
+
return super().run(cmd, state)
|
|
25
|
+
|
|
26
|
+
with self.validate(args, state) as (args, state):
|
|
27
|
+
if len(args) > 0:
|
|
28
|
+
arg = args[0]
|
|
29
|
+
if arg in ['p:', 'c:'] and arg != f'{state.device}:':
|
|
30
|
+
state = copy.copy(state)
|
|
31
|
+
state.device = arg.replace(':', '')
|
|
32
|
+
|
|
33
|
+
Devices.of(state).ls(cmd, state)
|
|
34
|
+
|
|
35
|
+
return state
|
|
36
|
+
|
|
37
|
+
def completion(self, state: ReplState):
|
|
38
|
+
return super().completion(state, {'&': None}, pods=Devices.of(state).pods(state, '-'))
|
|
39
|
+
|
|
40
|
+
def help(self, _: ReplState):
|
|
41
|
+
return f'{Ls.COMMAND} [device:]\t list apps, envs, clusters, nodes, pg hosts/databases or export databases'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.repl_state import ReplState
|
|
5
|
+
from adam.utils import log2
|
|
6
|
+
from adam.utils_local import local_qing_dir
|
|
7
|
+
|
|
8
|
+
class LsLocal(Command):
|
|
9
|
+
COMMAND = ':ls'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(LsLocal, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return LsLocal.COMMAND
|
|
22
|
+
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
24
|
+
if not(args := self.args(cmd)):
|
|
25
|
+
return super().run(cmd, state)
|
|
26
|
+
|
|
27
|
+
with self.validate(args, state) as (args, state):
|
|
28
|
+
if args:
|
|
29
|
+
os.system(f'ls {args}')
|
|
30
|
+
else:
|
|
31
|
+
os.system(f'ls {local_qing_dir()}')
|
|
32
|
+
log2()
|
|
33
|
+
|
|
34
|
+
return state
|
|
35
|
+
|
|
36
|
+
def completion(self, state: ReplState):
|
|
37
|
+
return super().completion(state)
|
|
38
|
+
|
|
39
|
+
def help(self, _: ReplState):
|
|
40
|
+
return f'{LsLocal.COMMAND} [dir]\t list files on local system'
|
adam/commands/fs/rm.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from adam.commands.fs.rm_downloads import RmDownloads
|
|
2
|
+
from adam.commands.fs.rm_logs import RmLogs
|
|
3
|
+
from adam.commands.intermediate_command import IntermediateCommand
|
|
4
|
+
|
|
5
|
+
class RmLocal(IntermediateCommand):
|
|
6
|
+
COMMAND = ':rm'
|
|
7
|
+
|
|
8
|
+
# the singleton pattern
|
|
9
|
+
def __new__(cls, *args, **kwargs):
|
|
10
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RmLocal, cls).__new__(cls)
|
|
11
|
+
|
|
12
|
+
return cls.instance
|
|
13
|
+
|
|
14
|
+
def command(self):
|
|
15
|
+
return RmLocal.COMMAND
|
|
16
|
+
|
|
17
|
+
def cmd_list(self):
|
|
18
|
+
return [RmDownloads(), RmLogs()]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.repl_state import ReplState
|
|
5
|
+
from adam.utils import log2
|
|
6
|
+
from adam.utils_local import local_downloads_dir
|
|
7
|
+
|
|
8
|
+
class RmDownloads(Command):
|
|
9
|
+
COMMAND = ':rm downloads'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RmDownloads, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return RmDownloads.COMMAND
|
|
22
|
+
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
24
|
+
if not(args := self.args(cmd)):
|
|
25
|
+
return super().run(cmd, state)
|
|
26
|
+
|
|
27
|
+
with self.validate(args, state) as (args, state):
|
|
28
|
+
cmd = f'rm -rf {local_downloads_dir()}/*'
|
|
29
|
+
log2(cmd)
|
|
30
|
+
os.system(cmd)
|
|
31
|
+
log2()
|
|
32
|
+
|
|
33
|
+
return state
|
|
34
|
+
|
|
35
|
+
def completion(self, state: ReplState):
|
|
36
|
+
return super().completion(state)
|
|
37
|
+
|
|
38
|
+
def help(self, _: ReplState):
|
|
39
|
+
return f'{RmDownloads.COMMAND}\t remove all downloads files under {local_downloads_dir()}'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.repl_state import ReplState
|
|
5
|
+
from adam.utils import log2, log_dir
|
|
6
|
+
|
|
7
|
+
class RmLogs(Command):
|
|
8
|
+
COMMAND = ':rm logs'
|
|
9
|
+
|
|
10
|
+
# the singleton pattern
|
|
11
|
+
def __new__(cls, *args, **kwargs):
|
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RmLogs, cls).__new__(cls)
|
|
13
|
+
|
|
14
|
+
return cls.instance
|
|
15
|
+
|
|
16
|
+
def __init__(self, successor: Command=None):
|
|
17
|
+
super().__init__(successor)
|
|
18
|
+
|
|
19
|
+
def command(self):
|
|
20
|
+
return RmLogs.COMMAND
|
|
21
|
+
|
|
22
|
+
def run(self, cmd: str, state: ReplState):
|
|
23
|
+
if not(args := self.args(cmd)):
|
|
24
|
+
return super().run(cmd, state)
|
|
25
|
+
|
|
26
|
+
with self.validate(args, state) as (args, state):
|
|
27
|
+
cmd = f'rm -rf {log_dir()}/*'
|
|
28
|
+
log2(cmd)
|
|
29
|
+
os.system(cmd)
|
|
30
|
+
log2()
|
|
31
|
+
|
|
32
|
+
return state
|
|
33
|
+
|
|
34
|
+
def completion(self, state: ReplState):
|
|
35
|
+
return super().completion(state)
|
|
36
|
+
|
|
37
|
+
def help(self, _: ReplState):
|
|
38
|
+
return f'{RmLogs.COMMAND}\t remove all qing log files under {log_dir()}'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from adam.commands import validate_args
|
|
4
|
+
from adam.commands.command import Command
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class Shell(Command):
|
|
9
|
+
COMMAND = ':sh'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Shell, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return Shell.COMMAND
|
|
22
|
+
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
24
|
+
if not(args := self.args(cmd)):
|
|
25
|
+
return super().run(cmd, state)
|
|
26
|
+
|
|
27
|
+
with self.validate(args, state) as (args, _):
|
|
28
|
+
with validate_args(args, state, at_least=0) as args_str:
|
|
29
|
+
if args_str:
|
|
30
|
+
os.system(args_str)
|
|
31
|
+
log2()
|
|
32
|
+
else:
|
|
33
|
+
os.system('QING_DROPPED=true bash')
|
|
34
|
+
|
|
35
|
+
return state
|
|
36
|
+
|
|
37
|
+
def completion(self, state: ReplState):
|
|
38
|
+
return super().completion(state)
|
|
39
|
+
|
|
40
|
+
def help(self, _: ReplState):
|
|
41
|
+
return f'{Shell.COMMAND}\t drop down to shell'
|
adam/repl_commands.py
CHANGED
|
@@ -45,6 +45,8 @@ from adam.commands.fs.find_files import FindLocalFiles
|
|
|
45
45
|
from adam.commands.fs.find_processes import FindProcesses
|
|
46
46
|
from adam.commands.fs.head import Head
|
|
47
47
|
from adam.commands.fs.ls_local import LsLocal
|
|
48
|
+
from adam.commands.fs.rm import RmLocal
|
|
49
|
+
from adam.commands.fs.rm_logs import RmLogs
|
|
48
50
|
from adam.commands.kubectl import Kubectl
|
|
49
51
|
from adam.commands.restart_cluster import RestartCluster
|
|
50
52
|
from adam.commands.restart_node import RestartNode
|
|
@@ -107,7 +109,7 @@ class ReplCommands:
|
|
|
107
109
|
def navigation() -> list[Command]:
|
|
108
110
|
return [Ls(), LsLocal(), PreviewTable(), DeviceApp(), DevicePostgres(), DeviceCass(), DeviceAuditLog(), DeviceExport(),
|
|
109
111
|
Cd(), Cat(), CatLocal(), Head(), DownloadFile(), FindLocalFiles(), FindProcesses(), Pwd(), ClipboardCopy(),
|
|
110
|
-
GetParam(), SetParam(), ShowParams(), ShowKubectlCommands(), ShowLogin(), ShowAdam(), ShowHost()]
|
|
112
|
+
GetParam(), SetParam(), ShowParams(), ShowKubectlCommands(), ShowLogin(), ShowAdam(), ShowHost()] + RmLocal().cmd_list()
|
|
111
113
|
|
|
112
114
|
def cassandra_ops() -> list[Command]:
|
|
113
115
|
return [Cqlsh(), DownloadCassandraLog(), ShowCassandraStatus(), ShowCassandraVersion(), ShowCassandraRepairs(), ShowStorage(), ShowProcesses(),
|
adam/version.py
CHANGED
|
@@ -9,7 +9,7 @@ adam/embedded_apps.py,sha256=lKPx63mKzJbNmwz0rgL4gF76M9fDGxraYTtNAIGnZ_s,419
|
|
|
9
9
|
adam/embedded_params.py,sha256=LDI2ph8YRoB-t_rSR9B3JqsnXsk_AvNyT6CgFAly4is,6505
|
|
10
10
|
adam/log.py,sha256=vcJ1Q8LLnt3NSXqpVcKjAI2OZE6KaD3PEi1kfu_D8qs,1156
|
|
11
11
|
adam/repl.py,sha256=V5q0AfFnFKPyOZNPdy9WZGJCH6_jyOTCxa3WS9jU9Ro,7623
|
|
12
|
-
adam/repl_commands.py,sha256=
|
|
12
|
+
adam/repl_commands.py,sha256=VyeqLr2lTwtgc0sBgEMRKUQgmqVcyb3FNoSz4qb77cg,7512
|
|
13
13
|
adam/repl_session.py,sha256=BWjPJq3lHrK6I5wxMqgKyv9_k98yEScn1-WHqsEk0k8,823
|
|
14
14
|
adam/repl_state.py,sha256=jdW56D2gjIEM40ttYtsr2MyIC8oW4KpxuhfQLUgTWZA,16168
|
|
15
15
|
adam/utils.py,sha256=AV32tqeGjDrk29oJqDTwY80WI9hgkQYUIJYitCbpvdw,26440
|
|
@@ -19,7 +19,7 @@ adam/utils_issues.py,sha256=nWhzUXmD2IfbT8MzjdyvuvpKrtUoieF74O2joaWFpUU,1438
|
|
|
19
19
|
adam/utils_local.py,sha256=Q4jqAenWQYvL6VLb0BlAJ4Z4VoWQIZBrrfyEDCS9qAw,2308
|
|
20
20
|
adam/utils_net.py,sha256=byEtNVr8iG9UaD7dM77dN2WEBClB7YNKult7LKFTCOc,428
|
|
21
21
|
adam/utils_sqlite.py,sha256=NexOm1Fxq99dLvBn7XhxCh1SinwBtVUzadbyS7lorkU,4233
|
|
22
|
-
adam/version.py,sha256=
|
|
22
|
+
adam/version.py,sha256=wI4AqD_6M7TmYRXPM9JZKFB0q3f5AvvnlIBpd-OjXJM,140
|
|
23
23
|
adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
24
|
adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
|
|
25
25
|
adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
|
|
@@ -155,6 +155,20 @@ adam/commands/export/show_export_databases.py,sha256=zSjZ8tuMXj1dZ6iIXwFVqVk7hok
|
|
|
155
155
|
adam/commands/export/show_export_session.py,sha256=hrUJFIaycnCpcv5wZ8bxCbYtzvdRm-JIswm_gvjzk4g,1291
|
|
156
156
|
adam/commands/export/show_export_sessions.py,sha256=s5m9oGlrJe3NWE-TQZszis0WGbKBs4T6C_NeihfYdxs,1130
|
|
157
157
|
adam/commands/export/utils_export.py,sha256=_j9cW_NAkTAC2kIAa3g9aFKkaunYHVivYIVyDrgTLA4,12968
|
|
158
|
+
adam/commands/fs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
159
|
+
adam/commands/fs/cat.py,sha256=_h8V1g57zKCeSeE7MVuqCC3k90_q3fd19FvdvCP8Q9g,1278
|
|
160
|
+
adam/commands/fs/cat_local.py,sha256=sTzt80NWELfgMtyDj3UQeQ1kx-Jr8xylnTTfUxOCOzA,1334
|
|
161
|
+
adam/commands/fs/cd.py,sha256=bvFgqzd0b4BROExcCaN_y-_tnyUUDEuoQk3dXest9l0,1330
|
|
162
|
+
adam/commands/fs/download_file.py,sha256=SmR6lq309dg6TOQUt0CqtC32T0RYEhSTut8qjV_KnOg,1849
|
|
163
|
+
adam/commands/fs/find_files.py,sha256=KvY2CREhhf6xr1KshG7dXBpKEi2mqWy8Gwpyc8YsfGA,1483
|
|
164
|
+
adam/commands/fs/find_processes.py,sha256=Ta1l5zddaazoWjaKZb8LRa4sfemr8HbOAdlLXNWBGrM,2908
|
|
165
|
+
adam/commands/fs/head.py,sha256=NeR1xRpmbyUQI5IgRE-zdWyyjs9C-C8E-g0WNulZ2Ck,1284
|
|
166
|
+
adam/commands/fs/ls.py,sha256=vUQrOaptKcC9HHzQaL_82h9bWoUxwGu0YSg8YKOwrBI,1282
|
|
167
|
+
adam/commands/fs/ls_local.py,sha256=FIajyaR-rcrDnMEk7COcO7KI8PAfkTXDI7nS7vBPTB8,1092
|
|
168
|
+
adam/commands/fs/rm.py,sha256=LxeSD6pTgU4090buVeVTKWJ0G3T9-0a_oar4MLEfrzk,528
|
|
169
|
+
adam/commands/fs/rm_downloads.py,sha256=4zvyKUDtcHTj5UzP7R047jzGm9RclZO8mE7w9c9Y26A,1119
|
|
170
|
+
adam/commands/fs/rm_logs.py,sha256=oHxV-g6qgna5LEVeeGlOwxN7A3cgxv8BpS7ASL5kCBY,1029
|
|
171
|
+
adam/commands/fs/shell.py,sha256=UQs4TEIDiZOjJrVsZJ_O9DDtn_k3K7-ifg1ZBsJFnsU,1155
|
|
158
172
|
adam/commands/medusa/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
159
173
|
adam/commands/medusa/medusa.py,sha256=Ey2kJpoKqPFP6m623B3ciMoLur5SVcHEBYsvW7G7aAY,958
|
|
160
174
|
adam/commands/medusa/medusa_backup.py,sha256=n-caJjd3WObm2tplVKUG-GahWoOwDS2pk_MZKQl0S7Q,1812
|
|
@@ -248,8 +262,8 @@ adam/utils_repl/state_machine.py,sha256=kO4_oSi_M53f3QQjINzzb2VFptjbnqX3KRC0G8Lq
|
|
|
248
262
|
teddy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
249
263
|
teddy/lark_parser.py,sha256=1ZasiCM94C0nOA4HFJX7uMj0h2TReCMqLd1Wx9C50uA,14701
|
|
250
264
|
teddy/lark_parser2.py,sha256=tXM6D8BimgG4FK5ANYS2K8MoATdcYed5QOKXivbPQHw,21499
|
|
251
|
-
kaqing-2.0.
|
|
252
|
-
kaqing-2.0.
|
|
253
|
-
kaqing-2.0.
|
|
254
|
-
kaqing-2.0.
|
|
255
|
-
kaqing-2.0.
|
|
265
|
+
kaqing-2.0.213.dist-info/METADATA,sha256=Jsuyj2bMnVhgMfFfzxa6xvBrGZ2qFUI1g4PY0syyGCI,133
|
|
266
|
+
kaqing-2.0.213.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
267
|
+
kaqing-2.0.213.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
|
|
268
|
+
kaqing-2.0.213.dist-info/top_level.txt,sha256=spQlE6mz0lPv3DfQLw8FenXyU0O-P8pi_FUCjdI2H9s,11
|
|
269
|
+
kaqing-2.0.213.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|