Added script for periodic running
This commit is contained in:
parent
01b93f121b
commit
92aab37d77
31
parser/__main__.py
Normal file
31
parser/__main__.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import sys
|
||||||
|
import schedule
|
||||||
|
import time
|
||||||
|
|
||||||
|
from . import RossetiParser
|
||||||
|
|
||||||
|
|
||||||
|
def job():
|
||||||
|
parser = RossetiParser()
|
||||||
|
|
||||||
|
print(parser)
|
||||||
|
|
||||||
|
parser.save_df(f'./data_{parser.today.strftime("%d-%m-%y_%H:%M")}.csv')
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
if sys.argv[1] == '-h' or sys.argv[1] == '--help':
|
||||||
|
print("python -m parser [<running period in hours>]")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
interval = int(sys.argv[1])
|
||||||
|
if interval > 0:
|
||||||
|
schedule.every(interval).hours.do(job)
|
||||||
|
|
||||||
|
job()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
schedule.run_pending()
|
||||||
|
time.sleep(schedule.idle_seconds())
|
||||||
|
else:
|
||||||
|
job()
|
Loading…
x
Reference in New Issue
Block a user