uipath 2.1.12__py3-none-any.whl → 2.1.14__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.
@@ -86,3 +86,19 @@ def get_org_scoped_url(base_url: str) -> str:
86
86
  org_name, *_ = parsed.path.strip("/").split("/")
87
87
  org_scoped_url = f"{parsed.scheme}://{parsed.netloc}/{org_name}"
88
88
  return org_scoped_url
89
+
90
+
91
+ def clean_directory(directory: str) -> None:
92
+ """Clean up Python files in the specified directory.
93
+
94
+ Args:
95
+ directory (str): Path to the directory to clean.
96
+
97
+ This function removes all Python files (*.py) from the specified directory.
98
+ It's used to prepare a directory for a quickstart agent/coded MCP server.
99
+ """
100
+ for file_name in os.listdir(directory):
101
+ file_path = os.path.join(directory, file_name)
102
+
103
+ if os.path.isfile(file_path) and file_name.endswith(".py"):
104
+ os.remove(file_path)
uipath/_cli/cli_init.py CHANGED
@@ -8,7 +8,9 @@ from typing import Any, Dict, Optional
8
8
  import click
9
9
  from dotenv import load_dotenv
10
10
 
11
+ from .._utils.constants import ENV_TELEMETRY_ENABLED
11
12
  from ..telemetry import track
13
+ from ..telemetry._constants import _PROJECT_KEY, _TELEMETRY_CONFIG_FILE
12
14
  from ._utils._console import ConsoleLogger
13
15
  from ._utils._input_args import generate_args
14
16
  from ._utils._parse_ast import generate_bindings_json
@@ -19,6 +21,30 @@ console = ConsoleLogger()
19
21
  CONFIG_PATH = "uipath.json"
20
22
 
21
23
 
24
+ def create_telemetry_config_file(target_directory: str) -> None:
25
+ """Create telemetry file if telemetry is enabled.
26
+
27
+ Args:
28
+ target_directory: The directory where the .uipath folder should be created.
29
+ """
30
+ telemetry_enabled = os.getenv(ENV_TELEMETRY_ENABLED, "true").lower() == "true"
31
+
32
+ if not telemetry_enabled:
33
+ return
34
+
35
+ uipath_dir = os.path.join(target_directory, ".uipath")
36
+ telemetry_file = os.path.join(uipath_dir, _TELEMETRY_CONFIG_FILE)
37
+
38
+ if os.path.exists(telemetry_file):
39
+ return
40
+
41
+ os.makedirs(uipath_dir, exist_ok=True)
42
+ telemetry_data = {_PROJECT_KEY: str(uuid.uuid4())}
43
+
44
+ with open(telemetry_file, "w") as f:
45
+ json.dump(telemetry_data, f, indent=4)
46
+
47
+
22
48
  def generate_env_file(target_directory):
23
49
  env_path = os.path.join(target_directory, ".env")
24
50
 
@@ -103,6 +129,7 @@ def init(entrypoint: str, infer_bindings: bool) -> None:
103
129
  with console.spinner("Initializing UiPath project ..."):
104
130
  current_directory = os.getcwd()
105
131
  generate_env_file(current_directory)
132
+ create_telemetry_config_file(current_directory)
106
133
 
107
134
  result = Middlewares.next(
108
135
  "init",
uipath/_cli/cli_pack.py CHANGED
@@ -8,6 +8,7 @@ from string import Template
8
8
  import click
9
9
 
10
10
  from ..telemetry import track
11
+ from ..telemetry._constants import _PROJECT_KEY, _TELEMETRY_CONFIG_FILE
11
12
  from ._utils._console import ConsoleLogger
12
13
  from ._utils._project_files import (
13
14
  ensure_config_file,
@@ -23,6 +24,27 @@ console = ConsoleLogger()
23
24
  schema = "https://cloud.uipath.com/draft/2024-12/entry-point"
24
25
 
25
26
 
27
+ def get_project_id() -> str:
28
+ """Get project ID from telemetry file if it exists, otherwise generate a new one.
29
+
30
+ Returns:
31
+ Project ID string (either from telemetry file or newly generated).
32
+ """
33
+ telemetry_file = os.path.join(".uipath", _TELEMETRY_CONFIG_FILE)
34
+
35
+ if os.path.exists(telemetry_file):
36
+ try:
37
+ with open(telemetry_file, "r") as f:
38
+ telemetry_data = json.load(f)
39
+ project_id = telemetry_data.get(_PROJECT_KEY)
40
+ if project_id:
41
+ return project_id
42
+ except (json.JSONDecodeError, IOError):
43
+ pass
44
+
45
+ return str(uuid.uuid4())
46
+
47
+
26
48
  def get_project_version(directory):
27
49
  toml_path = os.path.join(directory, "pyproject.toml")
28
50
  if not os.path.exists(toml_path):
@@ -40,7 +62,7 @@ def validate_config_structure(config_data):
40
62
 
41
63
 
42
64
  def generate_operate_file(entryPoints, dependencies=None):
43
- project_id = str(uuid.uuid4())
65
+ project_id = get_project_id()
44
66
 
45
67
  first_entry = entryPoints[0]
46
68
  file_path = first_entry["filePath"]
@@ -3,6 +3,9 @@ _CONNECTION_STRING = "InstrumentationKey=4128b5ed-f5ec-4612-ac32-b8cff0f2de93;In
3
3
  _APP_INSIGHTS_EVENT_MARKER_ATTRIBUTE = "APPLICATION_INSIGHTS_EVENT_MARKER_ATTRIBUTE"
4
4
  _OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES"
5
5
  _SDK_VERSION = "SdkVersion"
6
+ _PROJECT_KEY = "ProjectKey"
7
+
8
+ _TELEMETRY_CONFIG_FILE = ".telemetry.json"
6
9
 
7
10
  _CODE_FILEPATH = "code.file.path"
8
11
  _CODE_FUNCTION = "code.function.name"
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os
2
3
  from functools import wraps
3
4
  from importlib.metadata import version
@@ -25,7 +26,9 @@ from ._constants import (
25
26
  _CODE_LINENO,
26
27
  _CONNECTION_STRING,
27
28
  _OTEL_RESOURCE_ATTRIBUTES,
29
+ _PROJECT_KEY,
28
30
  _SDK_VERSION,
31
+ _TELEMETRY_CONFIG_FILE,
29
32
  _UNKNOWN,
30
33
  )
31
34
 
@@ -33,6 +36,26 @@ _logger = getLogger(__name__)
33
36
  _logger.propagate = False
34
37
 
35
38
 
39
+ def _get_project_key() -> str:
40
+ """Get project key from telemetry file if present.
41
+
42
+ Returns:
43
+ Project key string if available, otherwise empty string.
44
+ """
45
+ try:
46
+ telemetry_file = os.path.join(".uipath", _TELEMETRY_CONFIG_FILE)
47
+ if os.path.exists(telemetry_file):
48
+ with open(telemetry_file, "r") as f:
49
+ telemetry_data = json.load(f)
50
+ project_id = telemetry_data.get(_PROJECT_KEY)
51
+ if project_id:
52
+ return project_id
53
+ except (json.JSONDecodeError, IOError, KeyError):
54
+ pass
55
+
56
+ return _UNKNOWN
57
+
58
+
36
59
  class _AzureMonitorOpenTelemetryEventHandler(LoggingHandler):
37
60
  @staticmethod
38
61
  def _get_attributes(record: LogRecord) -> Attributes:
@@ -43,6 +66,7 @@ class _AzureMonitorOpenTelemetryEventHandler(LoggingHandler):
43
66
  attributes[_CLOUD_URL] = os.getenv(ENV_BASE_URL, _UNKNOWN)
44
67
  attributes[_APP_NAME] = "UiPath.Sdk"
45
68
  attributes[_SDK_VERSION] = version("uipath")
69
+ attributes[_PROJECT_KEY] = _get_project_key()
46
70
 
47
71
  if _CODE_FILEPATH in attributes:
48
72
  del attributes[_CODE_FILEPATH]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath
3
- Version: 2.1.12
3
+ Version: 2.1.14
4
4
  Summary: Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools.
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-python
@@ -9,10 +9,10 @@ uipath/_cli/__init__.py,sha256=oG0oTrb60qfIncJ0EcGsytBYxAVbepcBlOkqBKQlsJM,2104
9
9
  uipath/_cli/cli_auth.py,sha256=RUSBHfmqhBtITrx52FeXMlVCuNyo8vrjTdjEhmM1Khw,6734
10
10
  uipath/_cli/cli_deploy.py,sha256=KPCmQ0c_NYD5JofSDao5r6QYxHshVCRxlWDVnQvlp5w,645
11
11
  uipath/_cli/cli_eval.py,sha256=z0ER8pN5rJyINcSr1tM75HbSlmZXtx96YtqDvDI6zHk,2945
12
- uipath/_cli/cli_init.py,sha256=SmB7VplpXRSa5sgqgzojNsZDw0zfsEi2TfkMx3eQpTo,5132
12
+ uipath/_cli/cli_init.py,sha256=DHy8J1dLgIYeuR1hA9dZNeLbEWXjJf_VZyZ6D7Rfftg,6039
13
13
  uipath/_cli/cli_invoke.py,sha256=FurosrZNGlmANIrplKWhw3EQ1b46ph5Z2rPwVaYJgmc,4001
14
14
  uipath/_cli/cli_new.py,sha256=9378NYUBc9j-qKVXV7oja-jahfJhXBg8zKVyaon7ctY,2102
15
- uipath/_cli/cli_pack.py,sha256=mjmt2KA4UpZSsmf5dHEhuUVBudvqpc_MWLT5WmL8yMg,10573
15
+ uipath/_cli/cli_pack.py,sha256=om7pUDncQFRuuGm9gg1Ik_w57tyl3-brigAcy8pZqNg,11301
16
16
  uipath/_cli/cli_publish.py,sha256=QT17JTClAyLve6ZjB-WvQaJ-j4DdmNneV_eDRyXjeeQ,6578
17
17
  uipath/_cli/cli_pull.py,sha256=zVcLciXyccaUUJX75rkUvihYAO4-yCsIz4c4Dcly3aw,7535
18
18
  uipath/_cli/cli_push.py,sha256=PP6smnwMjxFbfb2IuD8cZHCoYifEsz5o-1r5ilNVUD0,18893
@@ -51,7 +51,7 @@ uipath/_cli/_templates/.rels.template,sha256=-fTcw7OA1AcymHr0LzBqbMAAtzZTRXLTNa_
51
51
  uipath/_cli/_templates/[Content_Types].xml.template,sha256=bYsKDz31PkIF9QksjgAY_bqm57YC8U_owsZeNZAiBxQ,584
52
52
  uipath/_cli/_templates/main.py.template,sha256=QB62qX5HKDbW4lFskxj7h9uuxBITnTWqu_DE6asCwcU,476
53
53
  uipath/_cli/_templates/package.nuspec.template,sha256=YZyLc-u_EsmIoKf42JsLQ55OGeFmb8VkIU2VF7DFbtw,359
54
- uipath/_cli/_utils/_common.py,sha256=EwtNvcSgjK1dZcQhwR1ZOue7E4Uj7AD7m4Vr5twdx7I,2595
54
+ uipath/_cli/_utils/_common.py,sha256=OVPe09pPq5yqk6oJKk17YfFU7rxrQJ8flBydin8VOqY,3135
55
55
  uipath/_cli/_utils/_console.py,sha256=scvnrrFoFX6CE451K-PXKV7UN0DUkInbOtDZ5jAdPP0,10070
56
56
  uipath/_cli/_utils/_constants.py,sha256=AXeVidtHUFiODrkB2BCX_bqDL-bUzRg-Ieh1-2cCrGA,1374
57
57
  uipath/_cli/_utils/_debug.py,sha256=zamzIR4VgbdKADAE4gbmjxDsbgF7wvdr7C5Dqp744Oc,1739
@@ -105,16 +105,16 @@ uipath/models/llm_gateway.py,sha256=rUIus7BrUuuRriXqSJUE9FnjOyQ7pYpaX6hWEYvA6AA,
105
105
  uipath/models/processes.py,sha256=Atvfrt6X4TYST3iA62jpS_Uxc3hg6uah11p-RaKZ6dk,2029
106
106
  uipath/models/queues.py,sha256=N_s0GKucbyjh0RnO8SxPk6wlRgvq8KIIYsfaoIY46tM,6446
107
107
  uipath/telemetry/__init__.py,sha256=Wna32UFzZR66D-RzTKlPWlvji9i2HJb82NhHjCCXRjY,61
108
- uipath/telemetry/_constants.py,sha256=85xzIK0gDMECYOtldFygM9OXyO6_vUF9ghWwWRruCJo,691
109
- uipath/telemetry/_track.py,sha256=v0e3hgwtetMsUco4yosBzNU00Ek5SI9RxUTumrTTNyo,3872
108
+ uipath/telemetry/_constants.py,sha256=uRDuEZayBYtBA0tMx-2AS_D-oiVA7oKgp9zid9jNats,763
109
+ uipath/telemetry/_track.py,sha256=I8SzROQcySAXNfxx4QgZlJ6ib8DjTKn50CiZYsbjjr8,4598
110
110
  uipath/tracing/__init__.py,sha256=GKRINyWdHVrDsI-8mrZDLdf0oey6GHGlNZTOADK-kgc,224
111
111
  uipath/tracing/_otel_exporters.py,sha256=X7cnuGqvxGbACZuFD2XYTWXwIse8pokOEAjeTPE6DCQ,3158
112
112
  uipath/tracing/_traced.py,sha256=qeVDrds2OUnpdUIA0RhtF0kg2dlAZhyC1RRkI-qivTM,18528
113
113
  uipath/tracing/_utils.py,sha256=ZeensQexnw69jVcsVrGyED7mPlAU-L1agDGm6_1A3oc,10388
114
114
  uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
115
115
  uipath/utils/_endpoints_manager.py,sha256=hiGEu6vyfQJoeiiql6w21TNiG6tADUfXlVBimxPU1-Q,4160
116
- uipath-2.1.12.dist-info/METADATA,sha256=ARj9kngrjykfrqrO_OplCZuXFfoNXsvFyhrnAYCbUSI,6367
117
- uipath-2.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
118
- uipath-2.1.12.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
119
- uipath-2.1.12.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
120
- uipath-2.1.12.dist-info/RECORD,,
116
+ uipath-2.1.14.dist-info/METADATA,sha256=NvFzEwkpuk2EiageBt0CSzkf7y-F5oHiTx1jDN-btxQ,6367
117
+ uipath-2.1.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
118
+ uipath-2.1.14.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
119
+ uipath-2.1.14.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
120
+ uipath-2.1.14.dist-info/RECORD,,