From 704ee89f03882faffb09933a4388c2e2dbb37e02 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 2 Nov 2023 09:28:19 +0100 Subject: [PATCH] Alternative approach to PB screenshots process check Signed-off-by: falkTX --- mod/screenshot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mod/screenshot.py b/mod/screenshot.py index d8e177a2..a7e0a0d8 100644 --- a/mod/screenshot.py +++ b/mod/screenshot.py @@ -24,11 +24,10 @@ def generate_screenshot(bundle_path, callback): # running packaged through cxfreeze if os.path.isfile(sys.argv[0]): - # TODO this does not work yet - return - cmd = [os.path.join(cwd, 'mod-screenshot'), 'take_screenshot', bundle_path, HTML_DIR, CACHE_DIR] + cmd = [os.path.join(cwd, 'mod-pedalboard'), 'take_screenshot', bundle_path, HTML_DIR, CACHE_DIR] if sys.platform == 'win32': cmd[0] += ".exe" + print(' '.join(cmd)) # regular run else: @@ -36,20 +35,21 @@ def generate_screenshot(bundle_path, callback): if not DEV_ENVIRONMENT and DEVICE_KEY: # if using a real MOD, setup niceness cmd = ['/usr/bin/nice', '-n', '+34'] + cmd - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, cwd=cwd) + proc = subprocess.Popen(cmd, cwd=cwd) loop = IOLoop.instance() - def proc_callback(fileno, _): + def proc_callback(): if proc.poll() is None: + loop.call_later(0.5, proc_callback) return - loop.remove_handler(fileno) if not os.path.exists(screenshot) or not os.path.exists(thumbnail): - return callback() + callback() + return callback(thumbnail) - loop.add_handler(proc.stdout.fileno(), proc_callback, 16) + loop.call_later(0.5, proc_callback) class ScreenshotGenerator(object):