tracktolib 0.33.0__py3-none-any.whl → 0.34.0__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.
tracktolib/utils.py CHANGED
@@ -8,6 +8,7 @@ from ipaddress import IPv4Address, IPv6Address
8
8
  from pathlib import Path
9
9
  from typing import Iterable, TypeVar, Iterator, Literal, overload, Any
10
10
  import importlib.util
11
+ import asyncio
11
12
 
12
13
  T = TypeVar('T')
13
14
 
@@ -29,6 +30,25 @@ def exec_cmd(cmd: str | list[str],
29
30
  return stdout.decode(encoding)
30
31
 
31
32
 
33
+ async def aexec_cmd(cmd: str | list[str],
34
+ *,
35
+ encoding: str = 'utf-8',
36
+ env: dict | None = None) -> str:
37
+ _cmd = cmd if isinstance(cmd, str) else ' '.join(cmd)
38
+ default_shell = os.getenv('SHELL', '/bin/bash')
39
+
40
+ proc = await asyncio.create_subprocess_shell(_cmd,
41
+ shell=True,
42
+ stdout=subprocess.PIPE,
43
+ stderr=subprocess.PIPE,
44
+ executable=default_shell,
45
+ env=env)
46
+ stdout, stderr = await proc.communicate()
47
+ if proc.returncode != 0:
48
+ raise Exception(stderr.decode(encoding))
49
+ return stdout.decode(encoding)
50
+
51
+
32
52
  def import_module(path: Path):
33
53
  """
34
54
  Import a module from a path.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tracktolib
3
- Version: 0.33.0
3
+ Version: 0.34.0
4
4
  Summary: Utility library for python
5
5
  Home-page: https://github.com/tracktor/tracktolib
6
6
  License: MIT
@@ -12,8 +12,8 @@ tracktolib/s3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  tracktolib/s3/minio.py,sha256=gkpI2bvVwfXaAFY7M9e0Mlv82x0PjuriS8LdRmEJtMo,1258
13
13
  tracktolib/s3/s3.py,sha256=kvxXYLjI2pT0yMWFpCzEljmHZH-G4CvVRRZuoPpZ1zQ,3725
14
14
  tracktolib/tests.py,sha256=GycCVRUOdzazxqBXKBWWzhrlkV8yyD7NaActz_A2WXU,590
15
- tracktolib/utils.py,sha256=pboJbFfD_OYjGS6OlGxo6L17iu69TFZdxnv-3K-jvXI,4592
16
- tracktolib-0.33.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
17
- tracktolib-0.33.0.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
18
- tracktolib-0.33.0.dist-info/METADATA,sha256=aC7vhArQFpZ0zgdj1c26iOrsjOstye-5iKcnOqshfFY,3630
19
- tracktolib-0.33.0.dist-info/RECORD,,
15
+ tracktolib/utils.py,sha256=kU35LCJaFDNg0IR9ekAi4uEJ3unZCC3VPzqgkctt06Q,5437
16
+ tracktolib-0.34.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
17
+ tracktolib-0.34.0.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
18
+ tracktolib-0.34.0.dist-info/METADATA,sha256=fSmbCpCBnXEUJPyohPIFJKxEiuNZRF9FdjhGz1RLjzc,3630
19
+ tracktolib-0.34.0.dist-info/RECORD,,