hcs-core 0.1.290__tar.gz → 0.1.291__tar.gz
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-0.1.290 → hcs_core-0.1.291}/PKG-INFO +1 -1
- hcs_core-0.1.291/hcs_core/__init__.py +1 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/_init.py +6 -3
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/cli_processor.py +7 -1
- hcs_core-0.1.291/hcs_core/ctxp/telemetry.py +88 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/util.py +4 -0
- hcs_core-0.1.290/hcs_core/__init__.py +0 -1
- {hcs_core-0.1.290 → hcs_core-0.1.291}/.gitignore +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/README.md +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/built_in_cmds/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/built_in_cmds/_ut.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/built_in_cmds/context.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/built_in_cmds/profile.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/cli_options.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/cmd_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/config.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/context.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/data_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/dispatcher.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/duration.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/extension.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/fn_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/fstore.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/jsondot.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/logger.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/profile.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/profile_store.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/recent.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/state.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/task_schd.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/template_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/timeutil.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/ctxp/var_template.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/actions.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/base_provider.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/context.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/core.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/dag.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/helper.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/kop.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/provider/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/provider/dev/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/provider/dev/_prepare.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/provider/dev/dummy.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/plan/provider/dev/fibonacci.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/auth.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/cli_options.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/client_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/csp.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/ez_client.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/hcs_client.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/init.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/login_support.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/payload_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/requtil.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/sglib/utils.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/__init__.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/check_license.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/duration.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/exit.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/hcs_constants.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/job_view.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/pki_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/query_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/scheduler.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/ssl_util.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/hcs_core/util/versions.py +0 -0
- {hcs_core-0.1.290 → hcs_core-0.1.291}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.291"
|
|
@@ -19,7 +19,7 @@ from pathlib import Path
|
|
|
19
19
|
|
|
20
20
|
import click
|
|
21
21
|
|
|
22
|
-
from . import cli_processor, config, profile, state
|
|
22
|
+
from . import cli_processor, config, profile, state, telemetry
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _get_store_path():
|
|
@@ -79,8 +79,11 @@ def app_name():
|
|
|
79
79
|
|
|
80
80
|
def init_cli(main_cli: click.Group, commands_dir: str = "./cmds"):
|
|
81
81
|
try:
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
ret = cli_processor.init(main_cli, commands_dir)
|
|
83
|
+
telemetry.end()
|
|
84
|
+
return ret
|
|
85
|
+
except BaseException as e:
|
|
86
|
+
telemetry.end(error=e)
|
|
84
87
|
if _need_stack_trace(e):
|
|
85
88
|
raise e
|
|
86
89
|
else:
|
|
@@ -24,7 +24,6 @@ from pathlib import Path
|
|
|
24
24
|
import click
|
|
25
25
|
from click.core import Group
|
|
26
26
|
|
|
27
|
-
from .extension import ensure_extension
|
|
28
27
|
from .util import avoid_trace_for_ctrl_c, print_error, print_output, validate_error_return
|
|
29
28
|
|
|
30
29
|
_eager_loading = os.environ.get("_CTXP_EAGER_LOAD")
|
|
@@ -61,6 +60,8 @@ class LazyGroup(click.Group):
|
|
|
61
60
|
|
|
62
61
|
def _ensure_extension(self):
|
|
63
62
|
if self._extension:
|
|
63
|
+
from .extension import ensure_extension
|
|
64
|
+
|
|
64
65
|
ensure_extension(self._extension)
|
|
65
66
|
|
|
66
67
|
|
|
@@ -186,6 +187,11 @@ def _default_io(cmd: click.Command):
|
|
|
186
187
|
"first": kwargs.pop("first"),
|
|
187
188
|
"exclude_field": kwargs.pop("exclude_field"),
|
|
188
189
|
}
|
|
190
|
+
ctx = click.get_current_context()
|
|
191
|
+
from .telemetry import start as telemetry_start
|
|
192
|
+
|
|
193
|
+
telemetry_start(ctx.command_path, ctx.params)
|
|
194
|
+
|
|
189
195
|
if io_args["output"] == "table":
|
|
190
196
|
|
|
191
197
|
def _format(data):
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import sys
|
|
4
|
+
import time
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
import httpx
|
|
9
|
+
from yumako import env
|
|
10
|
+
|
|
11
|
+
log = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
_record = None
|
|
14
|
+
_enabled = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def disable():
|
|
18
|
+
global _enabled
|
|
19
|
+
_enabled = False
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _is_disabled():
|
|
23
|
+
global _enabled
|
|
24
|
+
if _enabled is None:
|
|
25
|
+
_enabled = env.bool("HCS_CLI_TELEMETRY", True)
|
|
26
|
+
return not _enabled
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def start(cmd_path: str, params: dict):
|
|
30
|
+
if _is_disabled():
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
global _record
|
|
34
|
+
_record = {
|
|
35
|
+
"@timestamp": datetime.now(timezone.utc).isoformat(timespec="milliseconds"),
|
|
36
|
+
"command": cmd_path,
|
|
37
|
+
"options": [k.replace("_", "-") for k, v in params.items() if v],
|
|
38
|
+
"return": -1,
|
|
39
|
+
"error": None,
|
|
40
|
+
"time_ms": -1,
|
|
41
|
+
"env": {
|
|
42
|
+
"python_version": sys.version,
|
|
43
|
+
"platform": sys.platform,
|
|
44
|
+
"executable": sys.executable,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def end(return_code: int = 0, error: Exception = None):
|
|
50
|
+
if _is_disabled():
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
if _record is None:
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
if error:
|
|
57
|
+
if isinstance(error, click.exceptions.Exit):
|
|
58
|
+
return_code = error.exit_code
|
|
59
|
+
elif isinstance(error, SystemExit):
|
|
60
|
+
return_code = error.code
|
|
61
|
+
else:
|
|
62
|
+
_record["error"] = str(error)
|
|
63
|
+
if return_code == 0:
|
|
64
|
+
return_code = 1
|
|
65
|
+
_record["return"] = return_code
|
|
66
|
+
_record["time_ms"] = int((time.time() - datetime.fromisoformat(_record["@timestamp"]).timestamp()) * 1000)
|
|
67
|
+
|
|
68
|
+
# print('TELEMETRY end', json.dumps(_record, indent=4), flush=True)
|
|
69
|
+
|
|
70
|
+
_injest(_record)
|
|
71
|
+
return _record
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _injest(doc):
|
|
75
|
+
try:
|
|
76
|
+
response = httpx.post(
|
|
77
|
+
f"https://collie.omnissa.com/es/hcs-cli/_doc",
|
|
78
|
+
auth=("append_user", "public"),
|
|
79
|
+
headers={"Content-Type": "application/json"},
|
|
80
|
+
content=json.dumps(doc),
|
|
81
|
+
timeout=4,
|
|
82
|
+
)
|
|
83
|
+
response.raise_for_status()
|
|
84
|
+
except Exception as e:
|
|
85
|
+
log.debug(f"Telemetry ingestion failed: {e}", exc_info=True)
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
log.debug(f"Telemetry ingestion successful: {response.status_code}")
|
|
@@ -189,6 +189,10 @@ def _exclude_fields(obj: Any, fields_exclude: str):
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
def panic(reason: Any = None, code: int = 1):
|
|
192
|
+
if isinstance(reason, SystemExit):
|
|
193
|
+
os._exit(reason.code)
|
|
194
|
+
if isinstance(reason, click.exceptions.Exit):
|
|
195
|
+
os._exit(reason.exit_code)
|
|
192
196
|
if isinstance(reason, Exception):
|
|
193
197
|
text = error_details(reason)
|
|
194
198
|
else:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.290"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|