hcs-core 0.1.295__py3-none-any.whl → 0.1.297__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.
- hcs_core/__init__.py +1 -1
- hcs_core/ctxp/util.py +26 -0
- hcs_core/sglib/ez_client.py +8 -8
- hcs_core/util/job_view.py +6 -3
- hcs_core/util/versions.py +10 -8
- {hcs_core-0.1.295.dist-info → hcs_core-0.1.297.dist-info}/METADATA +2 -2
- {hcs_core-0.1.295.dist-info → hcs_core-0.1.297.dist-info}/RECORD +8 -8
- {hcs_core-0.1.295.dist-info → hcs_core-0.1.297.dist-info}/WHEEL +0 -0
hcs_core/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.297"
|
hcs_core/ctxp/util.py
CHANGED
|
@@ -368,3 +368,29 @@ def format_table(data: list, fields_mapping: dict, columns_to_sum: list = None):
|
|
|
368
368
|
traceback.print_exc()
|
|
369
369
|
|
|
370
370
|
return tabulate(table, headers=headers) + "\n"
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def colorize(data: dict, name: str, mapping: dict):
|
|
374
|
+
if os.environ.get("TERM_COLOR") == "0":
|
|
375
|
+
return
|
|
376
|
+
|
|
377
|
+
s = data.get(name)
|
|
378
|
+
if not s:
|
|
379
|
+
return
|
|
380
|
+
|
|
381
|
+
if isinstance(mapping, dict):
|
|
382
|
+
c = mapping.get(s)
|
|
383
|
+
if c:
|
|
384
|
+
if isinstance(c, str):
|
|
385
|
+
data[name] = click.style(s, fg=c)
|
|
386
|
+
elif callable(c):
|
|
387
|
+
color = c(data)
|
|
388
|
+
data[name] = click.style(s, fg=color)
|
|
389
|
+
else:
|
|
390
|
+
raise Exception(f"Unexpected color type: {type(c)} {c}")
|
|
391
|
+
elif callable(mapping):
|
|
392
|
+
c = mapping(s)
|
|
393
|
+
if c:
|
|
394
|
+
data[name] = click.style(s, fg=c)
|
|
395
|
+
else:
|
|
396
|
+
raise Exception(f"Unexpected mapping type: {type(mapping)} {mapping}")
|
hcs_core/sglib/ez_client.py
CHANGED
|
@@ -206,10 +206,10 @@ class EzClient:
|
|
|
206
206
|
raise
|
|
207
207
|
return data
|
|
208
208
|
|
|
209
|
-
def get(self, url: str, raise_on_404: bool = False, type: Optional[Type[BaseModel]] = None):
|
|
209
|
+
def get(self, url: str, headers: dict = None, raise_on_404: bool = False, type: Optional[Type[BaseModel]] = None):
|
|
210
210
|
try:
|
|
211
211
|
# print("->", url)
|
|
212
|
-
resp = self._client().get(url)
|
|
212
|
+
resp = self._client().get(url, headers=headers)
|
|
213
213
|
data = _parse_resp(resp)
|
|
214
214
|
if data and type:
|
|
215
215
|
try:
|
|
@@ -228,17 +228,17 @@ class EzClient:
|
|
|
228
228
|
else:
|
|
229
229
|
_raise_http_error(e)
|
|
230
230
|
|
|
231
|
-
def patch(self, url: str, json: dict):
|
|
231
|
+
def patch(self, url: str, json: dict = None, text=None, headers: dict = None):
|
|
232
232
|
try:
|
|
233
|
-
resp = self._client().patch(url, json=json)
|
|
233
|
+
resp = self._client().patch(url, json=json, content=text, headers=headers)
|
|
234
234
|
return _parse_resp(resp)
|
|
235
235
|
except httpx.HTTPStatusError as e:
|
|
236
236
|
_raise_http_error(e)
|
|
237
237
|
raise
|
|
238
238
|
|
|
239
|
-
def delete(self, url: str, raise_on_404: bool = False):
|
|
239
|
+
def delete(self, url: str, headers: dict = None, raise_on_404: bool = False):
|
|
240
240
|
try:
|
|
241
|
-
resp = self._client().delete(url)
|
|
241
|
+
resp = self._client().delete(url, headers=headers)
|
|
242
242
|
return _parse_resp(resp)
|
|
243
243
|
except httpx.HTTPStatusError as e:
|
|
244
244
|
if _is_404(e):
|
|
@@ -249,9 +249,9 @@ class EzClient:
|
|
|
249
249
|
else:
|
|
250
250
|
_raise_http_error(e)
|
|
251
251
|
|
|
252
|
-
def put(self, url: str, json: dict):
|
|
252
|
+
def put(self, url: str, json: dict = None, text=None, headers: dict = None):
|
|
253
253
|
try:
|
|
254
|
-
resp = self._client().put(url, json=json)
|
|
254
|
+
resp = self._client().put(url, json=json, content=text, headers=headers)
|
|
255
255
|
return _parse_resp(resp)
|
|
256
256
|
except httpx.HTTPStatusError as e:
|
|
257
257
|
_raise_http_error(e)
|
hcs_core/util/job_view.py
CHANGED
|
@@ -134,6 +134,9 @@ def _timeout_to_seconds(timeout: str, default: int = 60) -> int:
|
|
|
134
134
|
return t
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
_NAME_WIDTH = 40
|
|
138
|
+
|
|
139
|
+
|
|
137
140
|
class JobView:
|
|
138
141
|
def __init__(self, auto_close: bool = True):
|
|
139
142
|
self._map = {}
|
|
@@ -144,9 +147,9 @@ class JobView:
|
|
|
144
147
|
self._view_exited = threading.Event()
|
|
145
148
|
|
|
146
149
|
w, h = os.get_terminal_size()
|
|
147
|
-
msg_width = w -
|
|
150
|
+
msg_width = w - _NAME_WIDTH - 1 - 1 - 1 - 10 - 1 - 5 - 1 - 1
|
|
148
151
|
self._job_ctl = Progress(
|
|
149
|
-
TextColumn("{task.description}", table_column=Column(max_width=
|
|
152
|
+
TextColumn("{task.description}", table_column=Column(max_width=_NAME_WIDTH, min_width=10)),
|
|
150
153
|
# SpinnerColumn(table_column=Column(min_width=1)),
|
|
151
154
|
_MySpinnerColumn(table_column=Column(min_width=1)),
|
|
152
155
|
# BarColumn(pulse_style='white'),
|
|
@@ -159,7 +162,7 @@ class JobView:
|
|
|
159
162
|
)
|
|
160
163
|
|
|
161
164
|
def add(self, id: str, name: str):
|
|
162
|
-
name = _shorten_package_name(name,
|
|
165
|
+
name = _shorten_package_name(name, _NAME_WIDTH)
|
|
163
166
|
self._map[id] = self._job_ctl.add_task(name, start=False, details="")
|
|
164
167
|
self._todo.add(id)
|
|
165
168
|
|
hcs_core/util/versions.py
CHANGED
|
@@ -30,14 +30,16 @@ def check_upgrade():
|
|
|
30
30
|
checked_at = hcs_core.ctxp.state.get(last_upgrade_check_at, 0)
|
|
31
31
|
|
|
32
32
|
now = time.time()
|
|
33
|
-
if now - checked_at
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
if now - checked_at < 24 * 60 * 60:
|
|
34
|
+
return
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
latest = get_latest_version()
|
|
38
|
+
current = Version(get_version())
|
|
39
|
+
if current < latest:
|
|
40
|
+
log.warning(f"New version available: {latest}. Execute 'hcs upgrade' to upgrade.")
|
|
41
|
+
except Exception as e:
|
|
42
|
+
logging.debug(e)
|
|
41
43
|
|
|
42
44
|
hcs_core.ctxp.state.set(last_upgrade_check_at, now)
|
|
43
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hcs-core
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.297
|
|
4
4
|
Summary: Horizon Cloud Service CLI module.
|
|
5
5
|
Project-URL: Homepage, https://github.com/euc-eng/hcs-cli
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/euc-eng/hcs-cli/issues
|
|
@@ -36,7 +36,7 @@ Requires-Dist: schedule>=1.1.0
|
|
|
36
36
|
Requires-Dist: setuptools>=70.0.0
|
|
37
37
|
Requires-Dist: tabulate>=0.9.0
|
|
38
38
|
Requires-Dist: websocket-client>=1.2.3
|
|
39
|
-
Requires-Dist: yumako>=0.1.
|
|
39
|
+
Requires-Dist: yumako>=0.1.30
|
|
40
40
|
Provides-Extra: dev
|
|
41
41
|
Requires-Dist: bandit; extra == 'dev'
|
|
42
42
|
Requires-Dist: black; extra == 'dev'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
hcs_core/__init__.py,sha256=
|
|
1
|
+
hcs_core/__init__.py,sha256=niVeDT-oZbAKWXvYcymanePQGxWtGyYEm_NveVEXzSs,24
|
|
2
2
|
hcs_core/ctxp/__init__.py,sha256=bHVHhJP10Luz1a3Kk3zFx14dAO4SY6Q20Lrv8rNWWGc,1075
|
|
3
3
|
hcs_core/ctxp/_init.py,sha256=fMcRMPfJx-N0c-u0Zj2sFVKQL1-lWQd28gooAZETGUA,2933
|
|
4
4
|
hcs_core/ctxp/cli_options.py,sha256=cwlUgYXzIie9eRcu8fkBo_iFvC8LhflKGblWYtM2Hto,2739
|
|
@@ -22,7 +22,7 @@ hcs_core/ctxp/task_schd.py,sha256=mvZMeKDSSo2p7VidSoZY1XZj433TQn_YF9SGJEzl9lg,45
|
|
|
22
22
|
hcs_core/ctxp/telemetry.py,sha256=iZv9x2n2aovpjYxNhnih_LS1fEJZjH_rbTsRKngv_Q0,3477
|
|
23
23
|
hcs_core/ctxp/template_util.py,sha256=XslvIuRBlTVsUW0Y9M_D8gUPc1jWq6X2p4At2VAe1KU,731
|
|
24
24
|
hcs_core/ctxp/timeutil.py,sha256=RyRrIRdFHbIghdB8wbC8VdABvc7hki2v51b1x2JvHgo,445
|
|
25
|
-
hcs_core/ctxp/util.py,sha256=
|
|
25
|
+
hcs_core/ctxp/util.py,sha256=ckPyheoS08-bP4aixtBhYwi-C6syjFA6UHyIL6cUsPs,12350
|
|
26
26
|
hcs_core/ctxp/var_template.py,sha256=cTjj1UJ58ac6s5z4Oh5hSDQwKixq-rdbCF1D8akjAo0,3219
|
|
27
27
|
hcs_core/ctxp/built_in_cmds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
hcs_core/ctxp/built_in_cmds/_ut.py,sha256=e50XBmPim2qRe0RYk_XAuRz1HWYyLJuMu-6dVxWR_fQ,3356
|
|
@@ -46,7 +46,7 @@ hcs_core/sglib/auth.py,sha256=x2LjNCOTf_OJYsNggTG2rVagnVartyDCOlK4lSpXfso,6773
|
|
|
46
46
|
hcs_core/sglib/cli_options.py,sha256=NvdiHpX_o6IYPEM8cQYLb_R7T4aiXVvYLqn6Vk4Q2-Y,1761
|
|
47
47
|
hcs_core/sglib/client_util.py,sha256=t7zCldRRWt5f0l4TTRhmX-ZIaEm6MzNs_3B2RlwtXfk,14119
|
|
48
48
|
hcs_core/sglib/csp.py,sha256=UcO68YtLOPDQWiTjPVIPwQ2Z-Mywc-154aoIkLdyzwE,10991
|
|
49
|
-
hcs_core/sglib/ez_client.py,sha256=
|
|
49
|
+
hcs_core/sglib/ez_client.py,sha256=M3BqAXizWbdE1mba0nPHZXC5qJ_t2k_Vurttpg_VqF4,8355
|
|
50
50
|
hcs_core/sglib/hcs_client.py,sha256=pjrAVQDEy2tiQMypMpOzODFntT6aNHXjje8or_mkL2U,804
|
|
51
51
|
hcs_core/sglib/init.py,sha256=w_0ZU70Q1TGbSZsqSi7ewKQqpExFlepOT7mIqH0wnho,310
|
|
52
52
|
hcs_core/sglib/login_support.py,sha256=rHKZDAZXlo62IsjETyXxCSPxg1L4nV6ffZM_tulfe0A,7574
|
|
@@ -58,12 +58,12 @@ hcs_core/util/check_license.py,sha256=-ZBMVoVcEUwICZ0QRK-e2uMMla7gFbjP9upun93lPE
|
|
|
58
58
|
hcs_core/util/duration.py,sha256=e7Nw22aYXJK-pLM59QDel5atLZxShKBiVILFgrtLJks,4194
|
|
59
59
|
hcs_core/util/exit.py,sha256=UStMZKlfCFN7GBouc1y3pPFGPFQ66qfcRZ_fYQXFD0E,838
|
|
60
60
|
hcs_core/util/hcs_constants.py,sha256=Ic1Tx_UNJiQchfsdnRDzgiOaCjKHnsWXx997nElppm4,1755
|
|
61
|
-
hcs_core/util/job_view.py,sha256
|
|
61
|
+
hcs_core/util/job_view.py,sha256=LpyihmDJLXm4DtTST7Z-WydyWNYCJETT_SxCWunvGOg,8424
|
|
62
62
|
hcs_core/util/pki_util.py,sha256=Lt3-IzIoGcaQKNE7KUszxR7JSZkpXduVZJ262TszsIs,6685
|
|
63
63
|
hcs_core/util/query_util.py,sha256=5bh3bUVIQuY9qerndfuyfyzkTExYJ8zD0_e3PSN7y-4,3142
|
|
64
64
|
hcs_core/util/scheduler.py,sha256=bPpCmGUL1UctJMfLPAg-h4Hl2YZr96FiI78-G_Usn08,2958
|
|
65
65
|
hcs_core/util/ssl_util.py,sha256=MvU102fGwWWh9hhSmLnn1qQIWuD6TjZnN0iH0MXUtW0,1239
|
|
66
|
-
hcs_core/util/versions.py,sha256=
|
|
67
|
-
hcs_core-0.1.
|
|
68
|
-
hcs_core-0.1.
|
|
69
|
-
hcs_core-0.1.
|
|
66
|
+
hcs_core/util/versions.py,sha256=6nyyZzi3P69WQfioPc2_YWZQcUc13mC1eKoK58b3WUQ,1709
|
|
67
|
+
hcs_core-0.1.297.dist-info/METADATA,sha256=rqaQNgZqiVd-wok1KFUcp9TB5-1sAsQaMpOSiEJngbU,1951
|
|
68
|
+
hcs_core-0.1.297.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
69
|
+
hcs_core-0.1.297.dist-info/RECORD,,
|
|
File without changes
|