From d61daff685578753b3e795dd307c3374d3480aca Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Mon, 9 Nov 2020 20:47:08 -0600 Subject: [PATCH] Refactory run --- source/diff.py | 10 ---------- source/easymacro2.py | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/diff.py b/source/diff.py index fbc9485..91d5822 100644 --- a/source/diff.py +++ b/source/diff.py @@ -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): """ diff --git a/source/easymacro2.py b/source/easymacro2.py index e182ff7..e59ea86 100644 --- a/source/easymacro2.py +++ b/source/easymacro2.py @@ -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