datatailr 0.1.26__py3-none-any.whl → 0.1.28__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.

Potentially problematic release.


This version of datatailr might be problematic. Click here for more details.

@@ -32,6 +32,7 @@
32
32
  # DATATAILR_JOB_ID - the unique identifier for the job.
33
33
 
34
34
 
35
+ import subprocess
35
36
  import os
36
37
  import sys
37
38
  from typing import Tuple
@@ -80,18 +81,31 @@ def create_user_and_group() -> Tuple[str, str]:
80
81
  return user, group
81
82
 
82
83
 
83
- def run_command_as_user(command: str, user: str, env_vars: dict):
84
+ def run_command_as_user(command: str | list, user: str, env_vars: dict):
84
85
  """
85
86
  Run a command as a specific user with the given environment variables.
86
87
  """
87
- env_vars.update({"PATH": get_env_var("PATH")})
88
- env_vars.update({"PYTHONPATH": get_env_var("PYTHONPATH", "")})
89
- env_vars_str = " ".join(f"{key}='{value}'" for key, value in env_vars.items())
90
- full_command = f"sudo -u {user} {env_vars_str} {command}"
91
- logger.debug(f"Running command: {full_command}")
92
- status = os.system(full_command)
93
- if status != 0:
94
- logger.error(f"Command failed with status {status / 256:g}")
88
+ if isinstance(command, str):
89
+ command = command.split(" ")
90
+ env_vars = {
91
+ "PATH": get_env_var("PATH", ""),
92
+ "PYTHONPATH": get_env_var("PYTHONPATH", ""),
93
+ } | env_vars
94
+ full_command = ["sudo", "-u", user, *command]
95
+
96
+ try:
97
+ result = subprocess.run(
98
+ full_command,
99
+ env=env_vars,
100
+ check=True, # raises if returncode != 0
101
+ capture_output=True,
102
+ text=True,
103
+ )
104
+ logger.info(f"stdout: {result.stdout}")
105
+ logger.debug(f"stderr: {result.stderr}")
106
+ except subprocess.CalledProcessError as e:
107
+ logger.error(f"Command failed with exit code {e.returncode}")
108
+ logger.error(f"stderr: {e.stderr}")
95
109
  sys.exit(1)
96
110
 
97
111
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datatailr
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: Ready-to-Use Platform That Drives Business Insights
5
5
  Author-email: Datatailr <info@datatailr.com>
6
6
  License-Expression: MIT
@@ -12,7 +12,7 @@ datatailr/version.py,sha256=N9K8ZxlwFFSz8XSgbgaTWZY4k2J0JKfj698nZ_O2pIU,536
12
12
  datatailr/wrapper.py,sha256=K9ZD76cWey_ikA6C5sKejwRaYBDln4QMg-RcoRGiuFc,7991
13
13
  datatailr/build/__init__.py,sha256=_dA7b4L6wsaAFaSxUoYSJ1oaRqDHDMR20kqoCocSOss,487
14
14
  datatailr/build/image.py,sha256=YC8ML-l-sj6TcIBY-DCx_vaeI_7SmL9fPFhHnuxzRh0,5509
15
- datatailr/sbin/datatailr_run.py,sha256=7zJR8dBkj_GX9qO75AJCnxF4GouGmU-fieIvtgryH_k,6079
15
+ datatailr/sbin/datatailr_run.py,sha256=CRGObkOmu9URymcY6ZE_HS3gFTKFNJl2-XCQypbFWBc,6382
16
16
  datatailr/sbin/datatailr_run_app.py,sha256=AOkutzv4DeKfWZs-ZBciAMKnK4A05SfkVf1ZJnSSFwA,1231
17
17
  datatailr/sbin/datatailr_run_batch.py,sha256=UWnp96j_G66R_Cape7Bb-rbK6UBLF7Y5_mTlWyGJAVQ,1818
18
18
  datatailr/sbin/datatailr_run_excel.py,sha256=Gr_QZgqJrwgRVD9_o4v-2tbvU-QMvNHL7xUvFGhftFc,1163
@@ -25,9 +25,9 @@ datatailr/scheduler/batch_decorator.py,sha256=LqL1bsupWLn-YEQUvFJYae7R3ogrL5-Vod
25
25
  datatailr/scheduler/constants.py,sha256=5WWTsfwZ_BA8gVDOTa2AQX9DJ0NzfaWgtY3vrODS2-8,606
26
26
  datatailr/scheduler/schedule.py,sha256=0XJJen2nL1xplRs0Xbjwgq3T-0bFCOrJzkSALdio998,3741
27
27
  datatailr/scheduler/utils.py,sha256=up6oR2iwe6G52LkvgfO394xchXgCYNjOMGRQW3e8PQk,1082
28
- datatailr-0.1.26.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
29
- datatailr-0.1.26.dist-info/METADATA,sha256=sMAu0znbTVDR4J-3Im5cIyLvTGWDfHfGa2-s92A2VJM,5146
30
- datatailr-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- datatailr-0.1.26.dist-info/entry_points.txt,sha256=YqXfk2At-olW4PUSRkqvy_O3Mbv7uTKCCPuAAiz3Qbg,312
32
- datatailr-0.1.26.dist-info/top_level.txt,sha256=75gntW0X_SKpqxLL6hAPipvpk28GAhJBvoyqN_HohWU,10
33
- datatailr-0.1.26.dist-info/RECORD,,
28
+ datatailr-0.1.28.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
29
+ datatailr-0.1.28.dist-info/METADATA,sha256=nvPuYMkWFZJPLsQZ-u60a8KxHHWfU3sGTP6-phtd8Wo,5146
30
+ datatailr-0.1.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ datatailr-0.1.28.dist-info/entry_points.txt,sha256=YqXfk2At-olW4PUSRkqvy_O3Mbv7uTKCCPuAAiz3Qbg,312
32
+ datatailr-0.1.28.dist-info/top_level.txt,sha256=75gntW0X_SKpqxLL6hAPipvpk28GAhJBvoyqN_HohWU,10
33
+ datatailr-0.1.28.dist-info/RECORD,,