mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 05:12:25 +08:00
chore: improve scripts for running the app
This commit is contained in:
parent
4c986929c8
commit
a7b8c77246
@ -21,11 +21,18 @@ def run_and_monitor(program, program_args=None, output_file="output.png", wait_t
|
||||
start_time = time.time()
|
||||
|
||||
while time.time() - start_time < timeout:
|
||||
print("Polling for file {output_file}".format(output_file=output_file))
|
||||
# Check if the file is created
|
||||
if os.path.exists(output_file):
|
||||
# wait for the process to die, if it did, stop the waiting already
|
||||
try:
|
||||
process.wait(wait_time)
|
||||
break
|
||||
time.sleep(wait_time)
|
||||
except subprocess.TimeoutExpired:
|
||||
# otherwise check for the file, if it exists stop waiting
|
||||
print("Polling for file {output_file}".format(output_file=output_file))
|
||||
# Check if the file is created
|
||||
if os.path.exists(output_file):
|
||||
# give the screenshot some time to be written properly, just in case
|
||||
time.sleep(wait_time)
|
||||
break
|
||||
else:
|
||||
print("Timeout reached. File not found.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user