Added main process to avoid error in the sub process.
This commit is contained in:
parent
393099c714
commit
3b496bae86
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Replace 'script.py' with the name of the Python script you want to run
|
||||||
|
script_path = "speedtest.py"
|
||||||
|
schedule_time = "23:38"
|
||||||
|
repeat_count = 2
|
||||||
|
while True:
|
||||||
|
current_time = datetime.datetime.now().strftime("%H:%M")
|
||||||
|
if current_time == schedule_time:
|
||||||
|
for i in range(repeat_count):
|
||||||
|
subprocess.run(["python", script_path])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
20
speedtest.py
20
speedtest.py
|
|
@ -1997,11 +1997,10 @@ def shell():
|
||||||
if args.share and not machine_format:
|
if args.share and not machine_format:
|
||||||
printer('Share results: %s' % results.share())
|
printer('Share results: %s' % results.share())
|
||||||
|
|
||||||
utilities.convert_and_save_to_xlsx(str(results), "tmp/f24-ch1.xlsx")
|
utilities.convert_and_save_to_xlsx(str(results), "tmp/dev-test.xlsx")
|
||||||
|
|
||||||
|
|
||||||
def main(iteration=1):
|
def main():
|
||||||
for i in range(iteration):
|
|
||||||
try:
|
try:
|
||||||
shell()
|
shell()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
@ -2014,19 +2013,8 @@ def main(iteration=1):
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = '%r' % e
|
msg = '%r' % e
|
||||||
raise SystemExit('ERROR: %s' % msg)
|
raise SystemExit('ERROR: %s' % msg)
|
||||||
i+=1
|
|
||||||
if i == iteration:
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
schedule_time = "23:13"
|
main()
|
||||||
repeat_count = 0
|
|
||||||
while True:
|
|
||||||
current_time = datetime.datetime.now().strftime("%H:%M")
|
|
||||||
if current_time == schedule_time:
|
|
||||||
main(1)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
# main(5)
|
|
||||||
Loading…
Reference in New Issue