Refactory run

This commit is contained in:
Mauricio Baeza 2020-11-09 20:47:08 -06:00
parent cfb99b335c
commit d61daff685
2 changed files with 14 additions and 11 deletions

View File

@ -3470,16 +3470,6 @@ def merge_zip(target, zips):
return True
def get_size_screen():
if IS_WIN:
user32 = ctypes.windll.user32
res = '{}x{}'.format(user32.GetSystemMetrics(0), user32.GetSystemMetrics(1))
else:
args = 'xrandr | grep "*" | cut -d " " -f4'
res = run(args, True)
return res.strip()
# ~ Export ok
def format(template, data):
"""

View File

@ -534,7 +534,10 @@ def call_macro(args, in_thread=False):
return result
def run(command, capture=False):
def run(command, capture=False, split=True):
if not split:
return subprocess.check_output(command, shell=True).decode()
cmd = shlex.split(command)
result = subprocess.run(cmd, capture_output=capture, text=True)
if capture:
@ -672,6 +675,16 @@ def render(template, data):
return s.safe_substitute(**data)
def get_size_screen():
if IS_WIN:
user32 = ctypes.windll.user32
res = f'{user32.GetSystemMetrics(0)}x{user32.GetSystemMetrics(1)}'
else:
args = 'xrandr | grep "*" | cut -d " " -f4'
res = run(args, split=False)
return res.strip()
def _get_key(password):
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC