kaqing 2.0.200__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.

Files changed (65) hide show
  1. adam/batch.py +1 -1
  2. adam/commands/app/utils_app.py +1 -1
  3. adam/commands/cql/completions_c.py +1 -1
  4. adam/commands/cql/utils_cql.py +14 -13
  5. adam/commands/devices/device.py +1 -1
  6. adam/commands/download_cassandra_log.py +2 -2
  7. adam/commands/export/export_databases.py +13 -8
  8. adam/commands/export/export_sessions.py +12 -11
  9. adam/commands/export/exporter.py +140 -53
  10. adam/commands/export/import_session.py +0 -4
  11. adam/commands/export/importer.py +11 -11
  12. adam/commands/export/importer_athena.py +15 -6
  13. adam/commands/export/importer_sqlite.py +19 -8
  14. adam/commands/export/utils_export.py +37 -15
  15. adam/commands/fs/__init__.py +0 -0
  16. adam/commands/{os/cat.py → fs/cat_local.py} +15 -9
  17. adam/commands/{os → fs}/download_file.py +1 -1
  18. adam/commands/{os → fs}/find_files.py +4 -4
  19. adam/commands/{shell.py → fs/ls_local.py} +12 -13
  20. adam/commands/fs/rm.py +18 -0
  21. adam/commands/fs/rm_downloads.py +39 -0
  22. adam/commands/fs/rm_logs.py +38 -0
  23. adam/commands/postgres/postgres_databases.py +1 -1
  24. adam/commands/postgres/postgres_ls.py +1 -1
  25. adam/commands/postgres/utils_postgres.py +2 -1
  26. adam/commands/show/show_cassandra_status.py +3 -10
  27. adam/commands/show/show_processes.py +1 -1
  28. adam/commands/show/show_storage.py +2 -1
  29. adam/embedded_params.py +1 -1
  30. adam/repl_commands.py +16 -13
  31. adam/sso/cred_cache.py +2 -5
  32. adam/utils.py +122 -71
  33. adam/utils_k8s/app_clusters.py +10 -3
  34. adam/utils_k8s/app_pods.py +9 -3
  35. adam/utils_k8s/cassandra_clusters.py +4 -4
  36. adam/utils_k8s/cassandra_nodes.py +13 -7
  37. adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +8 -2
  38. adam/utils_k8s/pods.py +34 -29
  39. adam/utils_local.py +78 -2
  40. adam/utils_repl/repl_completer.py +6 -2
  41. adam/utils_sqlite.py +3 -8
  42. adam/version.py +1 -1
  43. {kaqing-2.0.200.dist-info → kaqing-2.0.213.dist-info}/METADATA +1 -1
  44. {kaqing-2.0.200.dist-info → kaqing-2.0.213.dist-info}/RECORD +53 -61
  45. adam/commands/alter_tables.py +0 -66
  46. adam/commands/cassandra/download_cassandra_log.py +0 -45
  47. adam/commands/cassandra/nodetool.py +0 -64
  48. adam/commands/cassandra/nodetool_commands.py +0 -120
  49. adam/commands/cassandra/restart_cluster.py +0 -47
  50. adam/commands/cassandra/restart_node.py +0 -51
  51. adam/commands/cassandra/restart_nodes.py +0 -47
  52. adam/commands/cassandra/rollout.py +0 -88
  53. adam/commands/download_file.py +0 -47
  54. adam/commands/find_files.py +0 -51
  55. adam/commands/os/find_processes.py +0 -76
  56. adam/commands/os/head.py +0 -36
  57. /adam/commands/{cat.py → fs/cat.py} +0 -0
  58. /adam/commands/{cd.py → fs/cd.py} +0 -0
  59. /adam/commands/{find_processes.py → fs/find_processes.py} +0 -0
  60. /adam/commands/{head.py → fs/head.py} +0 -0
  61. /adam/commands/{ls.py → fs/ls.py} +0 -0
  62. /adam/commands/{os → fs}/shell.py +0 -0
  63. {kaqing-2.0.200.dist-info → kaqing-2.0.213.dist-info}/WHEEL +0 -0
  64. {kaqing-2.0.200.dist-info → kaqing-2.0.213.dist-info}/entry_points.txt +0 -0
  65. {kaqing-2.0.200.dist-info → kaqing-2.0.213.dist-info}/top_level.txt +0 -0
@@ -1,64 +0,0 @@
1
- import click
2
-
3
- from adam.commands.command import Command
4
- from adam.commands.command_helpers import ClusterOrPodCommandHelper
5
- from adam.commands.cql.utils_cql import cassandra
6
- from adam.commands.devices.devices import Devices
7
- from adam.commands.cassandra.nodetool_commands import NODETOOL_COMMANDS
8
- from adam.config import Config
9
- from adam.repl_state import ReplState, RequiredState
10
- from adam.utils import log
11
-
12
- class NodeTool(Command):
13
- COMMAND = 'nodetool'
14
-
15
- # the singleton pattern
16
- def __new__(cls, *args, **kwargs):
17
- if not hasattr(cls, 'instance'): cls.instance = super(NodeTool, cls).__new__(cls)
18
-
19
- return cls.instance
20
-
21
- def __init__(self, successor: Command=None):
22
- super().__init__(successor)
23
-
24
- def command(self):
25
- return NodeTool.COMMAND
26
-
27
- def required(self):
28
- return RequiredState.CLUSTER_OR_POD
29
-
30
- def run(self, cmd: str, state: ReplState):
31
- if not(args := self.args(cmd)):
32
- return super().run(cmd, state)
33
-
34
- with self.validate(args, state) as (args, state):
35
- with cassandra(state) as pods:
36
- pods.nodetool(' '.join(args), status=(args[0] == 'status'))
37
-
38
- return state
39
-
40
- def completion(self, state: ReplState):
41
- return super().completion(state, {c: {'&': None} for c in NODETOOL_COMMANDS}, pods=Devices.of(state).pods(state, '-'))
42
-
43
- def help(self, _: ReplState):
44
- return f'{NodeTool.COMMAND} <sub-command> [&]\t run nodetool with arguments'
45
-
46
- class NodeToolCommandHelper(click.Command):
47
- def get_help(self, ctx: click.Context):
48
- log(super().get_help(ctx))
49
- log()
50
- log('Sub-Commands:')
51
-
52
- cmds = ''
53
- for c in NODETOOL_COMMANDS:
54
- if cmds:
55
- cmds += ', '
56
- cmds += c
57
- if len(cmds) > Config().get('nodetool.commands_in_line', 40):
58
- log(' ' + cmds)
59
- cmds = ''
60
-
61
- if len(cmds) > 0:
62
- log(' ' + cmds)
63
- log()
64
- ClusterOrPodCommandHelper.cluter_or_pod_help()
@@ -1,120 +0,0 @@
1
- NODETOOL_COMMANDS = [
2
- 'assassinate',
3
- 'bootstrap',
4
- 'cleanup',
5
- 'clearsnapshot',
6
- 'clientstats',
7
- 'compact',
8
- 'compactionhistory',
9
- 'compactionstats',
10
- 'decommission',
11
- 'describecluster',
12
- 'describering',
13
- 'disableauditlog',
14
- 'disableautocompaction',
15
- 'disablebackup',
16
- 'disablebinary',
17
- 'disablefullquerylog',
18
- 'disablegossip',
19
- 'disablehandoff',
20
- 'disablehintsfordc',
21
- 'disableoldprotocolversions',
22
- 'drain',
23
- 'enableauditlog',
24
- 'enableautocompaction',
25
- 'enablebackup',
26
- 'enablebinary',
27
- 'enablefullquerylog',
28
- 'enablegossip',
29
- 'enablehandoff',
30
- 'enablehintsfordc',
31
- 'enableoldprotocolversions',
32
- 'failuredetector',
33
- 'flush',
34
- 'garbagecollect',
35
- 'gcstats',
36
- 'getbatchlogreplaythrottle',
37
- 'getcompactionthreshold',
38
- 'getcompactionthroughput',
39
- 'getconcurrency',
40
- 'getconcurrentcompactors',
41
- 'getconcurrentviewbuilders',
42
- 'getendpoints',
43
- 'getfullquerylog',
44
- 'getinterdcstreamthroughput',
45
- 'getlogginglevels',
46
- 'getmaxhintwindow',
47
- 'getseeds',
48
- 'getsnapshotthrottle',
49
- 'getsstables',
50
- 'getstreamthroughput',
51
- 'gettimeout',
52
- 'gettraceprobability',
53
- 'gossipinfo',
54
- 'help',
55
- 'import',
56
- 'info',
57
- 'invalidatecountercache',
58
- 'invalidatekeycache',
59
- 'invalidaterowcache',
60
- 'join',
61
- 'listsnapshots',
62
- 'move',
63
- 'netstats',
64
- 'pausehandoff',
65
- 'profileload',
66
- 'proxyhistograms',
67
- 'rangekeysample',
68
- 'rebuild',
69
- 'rebuild_index',
70
- 'refresh',
71
- 'refreshsizeestimates',
72
- 'reloadlocalschema',
73
- 'reloadseeds',
74
- 'reloadssl',
75
- 'reloadtriggers',
76
- 'relocatesstables',
77
- 'removenode',
78
- 'repair',
79
- 'repair_admin',
80
- 'replaybatchlog',
81
- 'resetfullquerylog',
82
- 'resetlocalschema',
83
- 'resumehandoff',
84
- 'ring',
85
- 'scrub',
86
- 'setbatchlogreplaythrottle',
87
- 'setcachecapacity',
88
- 'setcachekeystosave',
89
- 'setcompactionthreshold',
90
- 'setcompactionthroughput',
91
- 'setconcurrency',
92
- 'setconcurrentcompactors',
93
- 'setconcurrentviewbuilders',
94
- 'sethintedhandoffthrottlekb',
95
- 'setinterdcstreamthroughput',
96
- 'setlogginglevel',
97
- 'setmaxhintwindow',
98
- 'setsnapshotthrottle',
99
- 'setstreamthroughput',
100
- 'settimeout',
101
- 'settraceprobability',
102
- 'sjk',
103
- 'snapshot',
104
- 'status',
105
- 'statusautocompaction',
106
- 'statusbackup',
107
- 'statusbinary',
108
- 'statusgossip',
109
- 'statushandoff',
110
- 'stop',
111
- 'stopdaemon',
112
- 'tablehistograms',
113
- 'tablestats',
114
- 'toppartitions',
115
- 'tpstats',
116
- 'truncatehints',
117
- 'upgradesstables',
118
- 'verify',
119
- 'version',
120
- 'viewbuildstatus']
@@ -1,47 +0,0 @@
1
- from adam.commands import extract_options
2
- from adam.commands.command import Command
3
- from adam.utils_k8s.pods import Pods
4
- from adam.utils_k8s.statefulsets import StatefulSets
5
- from adam.repl_state import ReplState, RequiredState
6
- from adam.utils import log2
7
-
8
- class RestartCluster(Command):
9
- COMMAND = 'restart cluster'
10
-
11
- # the singleton pattern
12
- def __new__(cls, *args, **kwargs):
13
- if not hasattr(cls, 'instance'): cls.instance = super(RestartCluster, 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 RestartCluster.COMMAND
22
-
23
- def required(self):
24
- return RequiredState.CLUSTER
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, '--force') as (args, forced):
32
- if not forced:
33
- log2('Please add --force for restarting all nodes in a cluster.')
34
-
35
- return 'force-needed'
36
-
37
- log2(f'Restarting all pods from {state.sts}...')
38
- for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
39
- Pods.delete(pod_name, state.namespace)
40
-
41
- return state
42
-
43
- def completion(self, state: ReplState):
44
- return super().completion(state, {'--force': None})
45
-
46
- def help(self, _: ReplState):
47
- return f"{RestartCluster.COMMAND} --force\t restart all the nodes in the cluster"
@@ -1,51 +0,0 @@
1
- from adam.commands import extract_options
2
- from adam.commands.command import Command
3
- from adam.commands.devices.devices import Devices
4
- from adam.utils_k8s.pods import Pods
5
- from adam.repl_state import ReplState, RequiredState
6
- from adam.utils import log2
7
-
8
- class RestartNode(Command):
9
- COMMAND = 'restart node'
10
-
11
- # the singleton pattern
12
- def __new__(cls, *args, **kwargs):
13
- if not hasattr(cls, 'instance'): cls.instance = super(RestartNode, 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 RestartNode.COMMAND
22
-
23
- def required(self):
24
- return RequiredState.POD
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
- if not state.pod:
32
- log2("'pod' is required")
33
-
34
- return 'pod-needed'
35
-
36
- with extract_options(args, '--force') as (args, forced):
37
- if not forced:
38
- log2('Please add --force for restarting pod.')
39
-
40
- return 'force-needed'
41
-
42
- log2(f'Restarting {state.pod}...')
43
- Pods.delete(state.pod, state.namespace)
44
-
45
- return state
46
-
47
- def completion(self, state: ReplState):
48
- return super().completion(state, {'--force': None}, pods=Devices.of(state).pods(state, '-'))
49
-
50
- def help(self, _: ReplState):
51
- return f"{RestartNode.COMMAND} --force\t restart the node"
@@ -1,47 +0,0 @@
1
- from adam.commands import extract_options, validate_args
2
- from adam.commands.command import Command
3
- from adam.utils_k8s.pods import Pods
4
- from adam.utils_k8s.statefulsets import StatefulSets
5
- from adam.repl_state import ReplState, RequiredState
6
- from adam.utils import log2
7
-
8
- class RestartNodes(Command):
9
- COMMAND = 'restart nodes'
10
-
11
- # the singleton pattern
12
- def __new__(cls, *args, **kwargs):
13
- if not hasattr(cls, 'instance'): cls.instance = super(RestartNodes, 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 RestartNodes.COMMAND
22
-
23
- def required(self):
24
- return RequiredState.CLUSTER
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, apply=False) as (args, state):
31
- with extract_options(args, '--force') as (args, forced):
32
- with validate_args(args, state, name='pod name'):
33
- if not forced:
34
- log2('Please add --force for restarting nodes.')
35
-
36
- return 'force-needed'
37
-
38
- for arg in args:
39
- Pods.delete(arg, state.namespace)
40
-
41
- return state
42
-
43
- def completion(self, state: ReplState):
44
- return super().completion(state, lambda: {p: {'--force': None} for p in StatefulSets.pod_names(state.sts, state.namespace)})
45
-
46
- def help(self, _: ReplState):
47
- return f"{RestartNodes.COMMAND} <pod-name>... --force\t restart Cassandra nodes"
@@ -1,88 +0,0 @@
1
- import datetime
2
- from kubernetes import client
3
- from kubernetes.client.rest import ApiException
4
-
5
- from adam.commands import extract_options
6
- from adam.commands.command import Command
7
- from adam.commands.watch import Watch
8
- from adam.utils_k8s.statefulsets import StatefulSets
9
- from adam.config import Config
10
- from adam.repl_state import ReplState, RequiredState
11
- from adam.utils import duration, log2
12
-
13
- class RollOut(Command):
14
- COMMAND = 'rollout'
15
-
16
- # the singleton pattern
17
- def __new__(cls, *args, **kwargs):
18
- if not hasattr(cls, 'instance'): cls.instance = super(RollOut, cls).__new__(cls)
19
-
20
- return cls.instance
21
-
22
- def __init__(self, successor: Command=None):
23
- super().__init__(successor)
24
-
25
- def command(self):
26
- return RollOut.COMMAND
27
-
28
- def required(self):
29
- return RequiredState.CLUSTER
30
-
31
- def run(self, cmd: str, state: ReplState):
32
- if not(args := self.args(cmd)):
33
- return super().run(cmd, state)
34
-
35
- with self.validate(args, state) as (args, state):
36
- with extract_options(args, '--force') as (args, forced):
37
- restarted, rollingout = StatefulSets.restarted_at(state.sts, state.namespace)
38
- if rollingout and not forced:
39
- log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
40
-
41
- return state
42
-
43
- self.rolling_restart(state.sts, state.namespace)
44
-
45
- auto_watch = False
46
- if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
47
- cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
48
- if self.command() in cmds:
49
- auto_watch = True
50
- log2('Rolling out cluster with auto watch...')
51
- Watch().run('watch', state)
52
-
53
- if not auto_watch:
54
- log2('Rolling out cluster...')
55
-
56
- return state
57
-
58
- def rolling_restart(self, statefulset, namespace):
59
- # kubectl rollout restart statefulset <statefulset-name>
60
- v1_apps = client.AppsV1Api()
61
-
62
- now = datetime.datetime.now(datetime.timezone.utc)
63
- now = str(now.isoformat("T") + "Z")
64
- body = {
65
- 'spec': {
66
- 'template':{
67
- 'metadata': {
68
- 'annotations': {
69
- 'kubectl.kubernetes.io/restartedAt': now
70
- }
71
- }
72
- }
73
- }
74
- }
75
-
76
- try:
77
- v1_apps.patch_namespaced_stateful_set(statefulset, namespace, body, pretty='true')
78
- except ApiException as e:
79
- log2("Exception when calling AppsV1Api->read_namespaced_statefulset_status: %s\n" % e)
80
-
81
- def completion(self, state: ReplState):
82
- if super().completion(state):
83
- return {RollOut.COMMAND: None}
84
-
85
- return {}
86
-
87
- def help(self, _: ReplState):
88
- return f'{RollOut.COMMAND} [--force]\t rollout all nodes'
@@ -1,47 +0,0 @@
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.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'
@@ -1,51 +0,0 @@
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_tmp_dir
7
-
8
- class FindLocalFiles(Command):
9
- COMMAND = 'find local'
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_tmp_dir()}'
32
- elif len(args) == 1:
33
- cmd = f"find {local_tmp_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'
@@ -1,76 +0,0 @@
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/os/head.py DELETED
@@ -1,36 +0,0 @@
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'
File without changes
File without changes
File without changes
File without changes
File without changes