hcs-core 0.1.310__py3-none-any.whl → 0.1.312__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.310"
1
+ __version__ = "0.1.312"
hcs_core/ctxp/util.py CHANGED
@@ -456,5 +456,9 @@ def default_table_formatter(data: Any, mapping: dict = None):
456
456
  )
457
457
  _restrict_readable_length(d, "name", 60)
458
458
  if mapping:
459
- field_mapping.update(mapping)
459
+ for k, v in mapping.items():
460
+ if v is None:
461
+ field_mapping.pop(k, None)
462
+ else:
463
+ field_mapping[k] = v
460
464
  return format_table(data, fields_mapping=field_mapping)
@@ -17,6 +17,7 @@ limitations under the License.
17
17
  # PKCE with authlib: https://docs.authlib.org/en/latest/specs/rfc7636.html
18
18
 
19
19
  import logging
20
+ import platform
20
21
  import secrets
21
22
  import threading
22
23
  import webbrowser
@@ -38,6 +39,7 @@ _public_client_ids = {
38
39
  }
39
40
 
40
41
  _auth_code_event = threading.Event()
42
+ _auth_code_event.value = None
41
43
  _state = None
42
44
 
43
45
  _auth_success_html = """
@@ -64,7 +66,7 @@ _auth_success_html = """
64
66
  <h3>You have successfully logged into Omnissa Horizon Cloud Service.</h3>
65
67
  <p>You can close this window, and return to the terminal.</p>
66
68
  <br/>
67
- <p><a href="https://github.com/euc-eng/hcs-cli/blob/dev/README.md">HCS CLI</a> is in beta. <a href="https://github.com/euc-eng/hcs-cli/blob/main/doc/hcs-cli-cheatsheet.md">Cheatsheet</a>:</p>
69
+ <p><a href="https://github.com/euc-eng/hcs-cli/blob/dev/README.md">HCS CLI</a> is in tech preview. <a href="https://github.com/euc-eng/hcs-cli/blob/main/doc/hcs-cli-cheatsheet.md">Cheatsheet</a>:</p>
68
70
  <code>
69
71
  # To get the login details: <br/>
70
72
  hcs login -d <br/><br/>
@@ -166,9 +168,18 @@ def do_oauth2_pkce(csp_url: str, client_id: str, org_id: str):
166
168
  webbrowser.open(authorization_url, new=0, autoraise=True)
167
169
 
168
170
  try:
169
- _auth_code_event.wait()
170
- except:
171
- log.info("Aborted")
171
+ # On Windows, wait() without timeout doesn't respond to CTRL+C properly
172
+ # Use a polling loop with timeout to allow KeyboardInterrupt to be caught
173
+ if platform.system() == "Windows":
174
+ while not _auth_code_event.wait(timeout=0.5):
175
+ pass # Keep waiting until the event is set
176
+ else:
177
+ _auth_code_event.wait()
178
+ except KeyboardInterrupt:
179
+ log.info("Aborted by user")
180
+ return
181
+ except Exception as e:
182
+ log.error(f"Login error: {e}")
172
183
  return
173
184
  # Once the user is redirected back to your app with an authorization code, exchange it for an access token
174
185
  authorization_code = _auth_code_event.value
hcs_core/util/job_view.py CHANGED
@@ -19,7 +19,7 @@ import threading
19
19
  from time import monotonic, sleep
20
20
  from typing import Optional
21
21
 
22
- from rich.console import RenderableType
22
+ from rich.console import Console, RenderableType
23
23
  from rich.live import Live
24
24
  from rich.progress import Progress, ProgressBar, ProgressColumn, SpinnerColumn, Task, TextColumn, TimeRemainingColumn
25
25
  from rich.table import Column
@@ -27,6 +27,9 @@ from rich.text import Text
27
27
 
28
28
  import hcs_core.util.duration as duration
29
29
 
30
+ # Detect if we're running on Windows
31
+ _IS_WINDOWS = os.name == "nt"
32
+
30
33
 
31
34
  def _shorten_package_name(package_name, max_length):
32
35
  if len(package_name) <= max_length:
@@ -117,6 +120,13 @@ class _MyTimeRemainingColumn(ProgressColumn):
117
120
 
118
121
 
119
122
  class _MySpinnerColumn(SpinnerColumn):
123
+ def __init__(self, *args, **kwargs):
124
+ # Use ASCII spinner for Windows terminals
125
+ if _IS_WINDOWS and "spinner_name" not in kwargs:
126
+ # Use a simple ASCII spinner: | / - \
127
+ kwargs["spinner_name"] = "line"
128
+ super().__init__(*args, **kwargs)
129
+
120
130
  def render(self, task: "Task") -> RenderableType:
121
131
  if task.finished:
122
132
  text = self.finished_text
@@ -148,6 +158,11 @@ class JobView:
148
158
 
149
159
  w, h = os.get_terminal_size()
150
160
  msg_width = w - _NAME_WIDTH - 1 - 1 - 1 - 10 - 1 - 5 - 1 - 1
161
+
162
+ # Create a console with ASCII-only mode for Windows to avoid rendering issues
163
+ # We need to store it and pass it to Live as well
164
+ self._console = Console(legacy_windows=True) if _IS_WINDOWS else None
165
+
151
166
  self._job_ctl = Progress(
152
167
  TextColumn("{task.description}", table_column=Column(max_width=_NAME_WIDTH, min_width=10)),
153
168
  # SpinnerColumn(table_column=Column(min_width=1)),
@@ -158,6 +173,7 @@ class JobView:
158
173
  # TaskProgressColumn(show_speed=True),
159
174
  TimeRemainingColumn(compact=True, elapsed_when_finished=True, table_column=Column(style="white", min_width=5)),
160
175
  TextColumn("{task.fields[details]}", table_column=Column(max_width=msg_width, no_wrap=True)),
176
+ console=self._console,
161
177
  get_time=monotonic,
162
178
  )
163
179
 
@@ -232,7 +248,7 @@ class JobView:
232
248
 
233
249
  def show(self) -> None:
234
250
  try:
235
- with Live(self._job_ctl, refresh_per_second=10):
251
+ with Live(self._job_ctl, refresh_per_second=10, console=self._console):
236
252
  self._view_started.set()
237
253
  while True:
238
254
  self.refresh()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hcs-core
3
- Version: 0.1.310
3
+ Version: 0.1.312
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
@@ -9,7 +9,7 @@ Project-URL: repository, https://github.com/euc-eng/hcs-cli
9
9
  Project-URL: changelog, https://github.com/euc-eng/hcs-cli/blob/main/CHANGELOG.md
10
10
  Author-email: Nanw1103 <nanw1103@gmail.com>
11
11
  Keywords: CLI,Horizon,Horizon Cloud,Horizon Cloud Service
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Programming Language :: Python :: 3
@@ -1,4 +1,4 @@
1
- hcs_core/__init__.py,sha256=qNe_N_xOYVLW7IcTJNa4ZbiRGoqGLfwqhzHzTvVvWq0,24
1
+ hcs_core/__init__.py,sha256=2LCS8KYJynrXugQ7FAsUblKtqbI8zazgWtvJiYq-ppg,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=KFu9_cRB1OyXaZJFLDCb3PpuQ0_5-ou2cdaL_q0_Lns,3098
@@ -22,7 +22,7 @@ hcs_core/ctxp/task_schd.py,sha256=mvZMeKDSSo2p7VidSoZY1XZj433TQn_YF9SGJEzl9lg,45
22
22
  hcs_core/ctxp/telemetry.py,sha256=tSjI_8OE2Ix3n--YHAO9sPmzi8ETbFHEPxzS52-usmM,3476
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=UTTtP-jjt3r5N-CTf0We64yLPWfFIl9dNSHkfsbFvLY,14225
25
+ hcs_core/ctxp/util.py,sha256=29TnUNHmbwVDWUHHMdlVw-dk0c5ffT9n2uyOD6P6CiA,14348
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
@@ -49,7 +49,7 @@ hcs_core/sglib/csp.py,sha256=UcO68YtLOPDQWiTjPVIPwQ2Z-Mywc-154aoIkLdyzwE,10991
49
49
  hcs_core/sglib/ez_client.py,sha256=dWQx-EMTrySz1EVzsSu4ZezORR3_iEOAcZigtbuvIQ8,8404
50
50
  hcs_core/sglib/hcs_client.py,sha256=pjrAVQDEy2tiQMypMpOzODFntT6aNHXjje8or_mkL2U,804
51
51
  hcs_core/sglib/init.py,sha256=w_0ZU70Q1TGbSZsqSi7ewKQqpExFlepOT7mIqH0wnho,310
52
- hcs_core/sglib/login_support.py,sha256=unwzx8_W8knWqSm-jN9wFzkQGpw4U5z4kfzKb_Sjlvw,7575
52
+ hcs_core/sglib/login_support.py,sha256=tniRhn4V5eUAgixi_FLTemzBnOrruLgvx6NsLLx3hTA,8077
53
53
  hcs_core/sglib/payload_util.py,sha256=Hnj7rjzrQ1j5gpbrwZX34biN8MIZjy6dOJZ63ulmzdw,685
54
54
  hcs_core/sglib/requtil.py,sha256=O37DrD4VVBmmRkkHJLbDtPfFq8l6fLZwYZggt2FTEFc,920
55
55
  hcs_core/sglib/utils.py,sha256=8a-e-nUhAbulZtV05CB5loov6Kgq8_Q0TxYwfvu7Bj8,3178
@@ -58,12 +58,12 @@ hcs_core/util/check_license.py,sha256=KUPaphuntMhwqcBJ6V2L85ZJZulaz1Yq5Ysurx2Ren
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=LpyihmDJLXm4DtTST7Z-WydyWNYCJETT_SxCWunvGOg,8424
61
+ hcs_core/util/job_view.py,sha256=mEFs1cntO5Ws2KL9FzhKmMO9qiJxcqPPZ0s7C-kuy6A,9068
62
62
  hcs_core/util/pki_util.py,sha256=Lt3-IzIoGcaQKNE7KUszxR7JSZkpXduVZJ262TszsIs,6685
63
63
  hcs_core/util/query_util.py,sha256=uYfcEF_00eUs_S5OK64zpH0cnb6dwy91_J1OY5ZrFVs,3471
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
66
  hcs_core/util/versions.py,sha256=6nyyZzi3P69WQfioPc2_YWZQcUc13mC1eKoK58b3WUQ,1709
67
- hcs_core-0.1.310.dist-info/METADATA,sha256=1tBWDUz8FAPMkCurFREuONeUiZ-udR5Jk8Mup3SH81g,1951
68
- hcs_core-0.1.310.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
69
- hcs_core-0.1.310.dist-info/RECORD,,
67
+ hcs_core-0.1.312.dist-info/METADATA,sha256=eDI2j9pfI1j1qfRo1728uv5YrQ9bv3XyAygXw1AwNHo,1952
68
+ hcs_core-0.1.312.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
69
+ hcs_core-0.1.312.dist-info/RECORD,,