kaqing 2.0.41__py3-none-any.whl → 2.0.42__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.
adam/commands/cd.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from adam.commands.command import Command
2
+ from adam.commands.postgres.pg_utils import pg_database_names
2
3
  from adam.commands.postgres.postgres_session import PostgresSession
3
4
  from adam.k8s_utils.cassandra_clusters import CassandraClusters
4
5
  from adam.k8s_utils.kube_context import KubeContext
@@ -91,7 +92,7 @@ class Cd(Command):
91
92
  if pg and pg.db:
92
93
  return {Cd.COMMAND: {'..': None}}
93
94
  elif pg and pg.host:
94
- return {Cd.COMMAND: {'..': None} | {p['name']: None for p in pg.databases()}}
95
+ return {Cd.COMMAND: {'..': None} | {p: None for p in pg_database_names(state.namespace, pg.directory())}}
95
96
  else:
96
97
  return {Cd.COMMAND: {p: None for p in PostgresSession.hosts(state.namespace)}}
97
98
  elif state.device == ReplState.A:
adam/commands/ls.py CHANGED
@@ -4,6 +4,7 @@ import re
4
4
  from adam.commands.command import Command
5
5
  from adam.commands.commands_utils import show_pods, show_rollout
6
6
  from adam.commands.cqlsh import Cqlsh
7
+ from adam.commands.postgres.pg_utils import pg_database_names, pg_table_names
7
8
  from adam.commands.postgres.postgres_session import PostgresSession
8
9
  from adam.config import Config
9
10
  from adam.k8s_utils.custom_resources import CustomResources
@@ -123,14 +124,10 @@ class Ls(Command):
123
124
  log(lines_to_tabular(lines, 'NAME,NAMESPACE,ENDPOINT,USERNAME,PASSWORD', separator=','))
124
125
 
125
126
  def show_pg_databases(self, pg: PostgresSession):
126
- lines = [db["name"] for db in pg.databases() if db["owner"] == PostgresSession.default_owner()]
127
-
128
- log(lines_to_tabular(lines, 'DATABASE', separator=','))
127
+ log(lines_to_tabular(pg_database_names(pg.namespace, pg.directory()), 'DATABASE', separator=','))
129
128
 
130
129
  def show_pg_tables(self, pg: PostgresSession):
131
- lines = [db["name"] for db in pg.tables() if db["schema"] == PostgresSession.default_schema()]
132
-
133
- log(lines_to_tabular(lines, 'NAME', separator=','))
130
+ log(lines_to_tabular(pg_table_names(pg.namespace, pg.directory()), 'NAME', separator=','))
134
131
 
135
132
  def completion(self, state: ReplState):
136
133
  if state.pod:
@@ -0,0 +1,18 @@
1
+ import functools
2
+
3
+ from adam.commands.postgres.postgres_session import PostgresSession
4
+
5
+ def pg_database_names(ns: str, pg_path: str):
6
+ pg = PostgresSession(ns, pg_path)
7
+ return [db['name'] for db in pg.databases() if db['owner'] == PostgresSession.default_owner()]
8
+
9
+ @functools.lru_cache()
10
+ def pg_table_names(ns: str, pg_path: str):
11
+ return [table['name'] for table in pg_tables(ns, pg_path) if table['schema'] == PostgresSession.default_schema()]
12
+
13
+ def pg_tables(ns: str, pg_path: str):
14
+ pg = PostgresSession(ns, pg_path)
15
+ if pg.db:
16
+ return pg.tables()
17
+
18
+ return []
@@ -2,6 +2,7 @@ import functools
2
2
  import click
3
3
 
4
4
  from adam.commands.command import Command
5
+ from adam.commands.postgres.pg_utils import pg_table_names
5
6
  from .postgres_ls import PostgresLs
6
7
  from .postgres_preview import PostgresPreview
7
8
  from .postgres_session import PostgresSession
@@ -67,19 +68,19 @@ class Postgres(Command):
67
68
  leaf = {}
68
69
  session = PostgresSession(state.namespace, state.pg_path)
69
70
  if session.db:
70
- ts = self.tables(state.namespace, state.pg_path)
71
+ if tables := pg_table_names(state.namespace, state.pg_path):
71
72
  leaf = {
72
73
  '\h': None,
73
74
  '\d': None,
74
75
  '\dt': None,
75
76
  '\du': None,
76
- 'delete': {'from': {t: {'where': {'id': {'=': None}}} for t in ts}},
77
- 'insert': {'into': {t: {'values': None} for t in ts}},
77
+ 'delete': {'from': {t: {'where': {'id': {'=': None}}} for t in tables}},
78
+ 'insert': {'into': {t: {'values': None} for t in tables}},
78
79
  'select': {'*': {'from': {t: {
79
80
  'limit': {'1': None},
80
81
  'where': {'id': {'=': None}}
81
- } for t in ts}}},
82
- 'update': {t: {'set': None} for t in ts},
82
+ } for t in tables}}},
83
+ 'update': {t: {'set': None} for t in tables},
83
84
  }
84
85
  elif state.pg_path:
85
86
  leaf = {
@@ -92,15 +93,6 @@ class Postgres(Command):
92
93
  else:
93
94
  return {}
94
95
 
95
- # TODO fix cache
96
- # @functools.lru_cache()
97
- def tables(self, ns: str, pg_path: str):
98
- session = PostgresSession(ns, pg_path)
99
- if session.db:
100
- return [f'{t["schema"]}.{t["name"]}' for t in session.tables()]
101
-
102
- return []
103
-
104
96
  def help(self, _: ReplState):
105
97
  return f'[{Postgres.COMMAND}] <sql-statements>\t run psql with queries'
106
98
 
@@ -2,9 +2,9 @@ import functools
2
2
 
3
3
  from adam.commands.command import Command
4
4
  from adam.commands.cql_utils import run_cql, tables
5
+ from adam.commands.postgres.pg_utils import pg_table_names
5
6
  from adam.commands.postgres.postgres_session import PostgresSession
6
7
  from adam.config import Config
7
- from adam.pod_exec_result import PodExecResult
8
8
  from adam.repl_state import ReplState, RequiredState
9
9
  from adam.utils import lines_to_tabular, log, log2
10
10
 
@@ -72,8 +72,8 @@ class PreviewTable(Command):
72
72
 
73
73
  def completion(self, state: ReplState):
74
74
  if state.device == ReplState.P:
75
- if tables := PreviewTable.pg_tables(state.namespace, state.pg_path):
76
- return {PreviewTable.COMMAND: {db["name"]: None for db in tables if db["schema"] == PostgresSession.default_schema()}}
75
+ if tables := pg_table_names(state.namespace, state.pg_path):
76
+ return {PreviewTable.COMMAND: {table: None for table in tables}}
77
77
  elif state.sts:
78
78
  tables = PreviewTable.cql_tables(state)
79
79
  return {PreviewTable.COMMAND: {f'{k}.{t}': None for k, ts in tables.items() for t in ts}}
@@ -88,18 +88,4 @@ class PreviewTable(Command):
88
88
  if state.pod:
89
89
  return tables(state)
90
90
 
91
- return tables(state, on_any=True)
92
-
93
- # r: list[PodExecResult] = run_cql(state, 'describe tables', show_out=False, on_any=True)
94
- # if not r:
95
- # return []
96
-
97
- # return parse_cql_desc_tables(r[0].stdout)
98
-
99
- @functools.lru_cache()
100
- def pg_tables(ns: str, pg_path: str):
101
- pg = PostgresSession(ns, pg_path)
102
- if pg.db:
103
- return pg.tables()
104
-
105
- return None
91
+ return tables(state, on_any=True)
adam/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- __version__ = "2.0.41" #: the working version
4
+ __version__ = "2.0.42" #: the working version
5
5
  __release__ = "1.0.0" #: the release version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaqing
3
- Version: 2.0.41
3
+ Version: 2.0.42
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -14,7 +14,7 @@ adam/repl_commands.py,sha256=aH7xxbsQGrpL9Ozk9QF54iToK6wbDT3Pu9rMyw9sDBY,4719
14
14
  adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
15
15
  adam/repl_state.py,sha256=591d7gV6uQSFtm7IWdlIYAHjfAzs9bdvIkwlIAeKddE,7540
16
16
  adam/utils.py,sha256=2DoWsrcaioFFH0-RjT30qelVRPUJqCGTfz_ucfE7F8g,7406
17
- adam/version.py,sha256=dFQ-OBXEqCb5aUcKIvnOUqGZNXXCV8b55Fb031UN2b0,139
17
+ adam/version.py,sha256=eljjZE7kqyuzTMa7Yo7ey3W4bRuXcbF2q2tkG1C7Izg,139
18
18
  adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
20
20
  adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
@@ -51,7 +51,7 @@ adam/commands/alter_tables.py,sha256=Y5cWg0Ow93rIDusbHgxQcC7sSB64LmULTlDxPLybiVM
51
51
  adam/commands/app.py,sha256=7alV8wK801t67_rUe6EmhtHJTl-6K7fGCm6Uz1dDgpM,1963
52
52
  adam/commands/app_ping.py,sha256=Xk7cfefphXM2w-UvpnhNUTZ3BU38f0deehUb2FEyLCI,1337
53
53
  adam/commands/bash.py,sha256=1O9cCl9JHQdttqNAgdB44rO0NjCqHzHv4psAEQMJcjw,2714
54
- adam/commands/cd.py,sha256=XEoiMhbJgA2KVKwhHFcs5BRAlf9qpgbAh6IImpKOtHI,4486
54
+ adam/commands/cd.py,sha256=eOVpddySWkBSwaIocQ4xU_N_GwFcg6qF5mj2NcGfACE,4576
55
55
  adam/commands/check.py,sha256=853FPfgTMGxQXI_5UaPAtzaSWB_BvEVm48EkJhsHe4w,2181
56
56
  adam/commands/cli_commands.py,sha256=PEEyrG9yz7RAEZwHbbuFpyE3fVi8vrIWbr0d1H0Gp9o,3620
57
57
  adam/commands/command.py,sha256=Ph7IduCTGQ04dcwNegl1ekYbqCzOwAOYeWZVIRWnKyU,3958
@@ -66,12 +66,12 @@ adam/commands/help.py,sha256=Ey3R1X8w_CMhdADI0t8dSQ28euhDHheJm7NermiGni4,1645
66
66
  adam/commands/issues.py,sha256=VS-PC7e-2lywsa-lbmoUX8IY77OPGzFudwbw1g8XmQc,2599
67
67
  adam/commands/login.py,sha256=bj95WWIF7mJDJhnyS9T8xvaZUGL37dj7GlH8TgmODbk,1877
68
68
  adam/commands/logs.py,sha256=T-O9DYXmWEm4G1I5SM6MwyeRwq2aT-WMqNW0XA2MWmo,1165
69
- adam/commands/ls.py,sha256=-AT0UnjvotSpFguaUoRAnJ8XXfshwh0ElHa_Ofl5l9w,5671
69
+ adam/commands/ls.py,sha256=il1eQOLcfub0Yx8nDsCvlKpx2UONK7_WaidXLzlBvkU,5621
70
70
  adam/commands/nodetool.py,sha256=HV9yDzMhRjS4lw6UfV7Hc1pcmeSx5a1jU6cAEKSZ1Bg,2334
71
71
  adam/commands/nodetool_commands.py,sha256=5IgWC3rmeDD1cgwqQjiiWzi-wJpJ3n_8pAzz_9phXuk,2635
72
72
  adam/commands/param_get.py,sha256=kPAAppK2T0tEFRnSIVFLDPIIGHhgLA7drJhn8TRyvvE,1305
73
73
  adam/commands/param_set.py,sha256=QDIuqfU80aWCB16OK49yf7XRaRTWwiLkwMsJuVikq9I,1271
74
- adam/commands/preview_table.py,sha256=ROEYHwCOhTxkSNqEyYZ9ASSevNmkN_mHEeH8LXa4gw8,3513
74
+ adam/commands/preview_table.py,sha256=yxxSQDqwM-vYSZm6ITTC6b9t4rTVXtSzq3o6z8Cfx8A,3084
75
75
  adam/commands/pwd.py,sha256=VlgFjxFl66I7Df1YI6cuiEeY6Q13lEavMKfrzHLESKo,2340
76
76
  adam/commands/report.py,sha256=Ky45LIzSlB_X4V12JZWjU3SA2u4_FKRencRTq7psOWU,1944
77
77
  adam/commands/restart.py,sha256=Hik1t5rjH2ATZv4tzwrGB3e44b3dNuATgY327_Nb8Bs,2044
@@ -104,7 +104,8 @@ adam/commands/medusa/medusa_restore.py,sha256=MU47bmozrjfGJ6GVkj_OVgLH6Uz_fGh03M
104
104
  adam/commands/medusa/medusa_show_backupjobs.py,sha256=QekHpKezVJdgfa9hOxfgyx-y4D08tmHzyu_AAa8QPR0,1756
105
105
  adam/commands/medusa/medusa_show_restorejobs.py,sha256=wgPonSmC6buDIp3k3WUY-Yu2MyP1xyE3Q_XhvAwpnx4,1651
106
106
  adam/commands/postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- adam/commands/postgres/postgres.py,sha256=zi6zicBLe2ZM6UCZgL3L3tdKIISEMGAh8UFcTuTUp5k,3649
107
+ adam/commands/postgres/pg_utils.py,sha256=s9v28RGIhgPDfueucwTepedDWXBcIy85CwF2Zo266Uc,587
108
+ adam/commands/postgres/postgres.py,sha256=95RPzGcVEWDR2Vhuy2RReJUGKdchZJjOWAtgvAbPnJ0,3473
108
109
  adam/commands/postgres/postgres_ls.py,sha256=HwZTgwGKXUqHX33S8aQPF6FqCrLqtoz4cLyJV2SpoE0,1186
109
110
  adam/commands/postgres/postgres_preview.py,sha256=MLzdEc4mvNj6V1Q8jO5OPznXyYELJHgd35_eQgLlNIU,1274
110
111
  adam/commands/postgres/postgres_session.py,sha256=CK5rkYcRHZqg2AR3fRrP81zF5P71yroPV7SvyQ6pJ7c,9509
@@ -167,8 +168,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
167
168
  adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
168
169
  adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
169
170
  adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
170
- kaqing-2.0.41.dist-info/METADATA,sha256=2BK4sM2oap6IJ6uhJ-SU_cXy8YJg3QKmd8peq4QhvYU,132
171
- kaqing-2.0.41.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
172
- kaqing-2.0.41.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
173
- kaqing-2.0.41.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
174
- kaqing-2.0.41.dist-info/RECORD,,
171
+ kaqing-2.0.42.dist-info/METADATA,sha256=1AEwxOTmZfdz85m7S8MwkKLltlOtf6MxYvqjBHe7TB0,132
172
+ kaqing-2.0.42.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
173
+ kaqing-2.0.42.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
174
+ kaqing-2.0.42.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
175
+ kaqing-2.0.42.dist-info/RECORD,,