mirror of
https://github.com/xxh/xxh
synced 2024-11-27 06:00:21 +00:00
28 lines
621 B
Python
28 lines
621 B
Python
|
import os
|
||
|
from pathlib import Path
|
||
|
import subprocess
|
||
|
|
||
|
def S(cmd, trace=False):
|
||
|
if type(cmd) == list:
|
||
|
cmd = ' '.join(cmd)
|
||
|
if trace:
|
||
|
print(cmd)
|
||
|
return os.system(cmd)
|
||
|
|
||
|
def SC(cmd):
|
||
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||
|
[out, err] = proc.communicate()
|
||
|
return (out, err, proc)
|
||
|
|
||
|
def A(args, q=0):
|
||
|
if type(args) == list:
|
||
|
args = ' '.join([str(a) for a in args])
|
||
|
if q == 1:
|
||
|
return f"'{args}'"
|
||
|
elif q == 2:
|
||
|
return f'"{args}"'
|
||
|
return str(args)
|
||
|
|
||
|
def p(path_str):
|
||
|
return Path(path_str).expanduser()
|