我有几个自定义模块,它们是通过运行apscheduler
的clock.py调用的:
apscheduler会按计划的间隔不断重复插入相同的日期,这时应该首先检查Twitter提要,然后如果与Google表格不同,则不进行任何操作。
BlockingScheduler()
.start()
工作If
的值不同:
True
,则发送电子邮件更新当前问题出在 clock.py和模块a
sched = BlockingScheduler()
sched.add_job(tweet_bss.main, 'interval', seconds = 120)
sched.print_jobs()
sched.start()
def main():
"""
This script will import the sheets module, open a connection to twitter
pass account name and numb of tweets open a connection with sheets,
if last row 'text' from 'sheets' != 'tweet text' and 'is not None'
then it will enter the exchange into the spread sheet
"""
last_row = sheets.row_count()
last_entry = sheets.get_text(last_row)
last_entry = str(last_entry)
for tweet in tweets('tweet_account', 1):
if last_entry != bss_extract(tweet.text) is not None:
sheets.bss_insert([str(tweet.created_at), tweet.lang,
tweet.source_url, float(bss_extract(tweet.text))])
pickler([str(tweet.created_at), float(bss_extract(tweet.text))])
sc.bss_update(True)
print(f'from tweet_bss.py for {TODAY} @ {TIME}')
print(f'if {last_entry} != {bss_extract(tweet.text)} is not None')
print(f'a. Twitter data inserted on {tweet.created_at} to sheets')
print('b. pickler() function updated the pickle file with date and exchange rate to be used for email')
print('c. The status.yaml was updated to True, letting the SMTP script know "update" can be emailed')
print('~' * 45)
else:
print(f'from tweet_bss.py for {TODAY} @ {TIME}')
print(f'No update needed:')
print(f'\tSheets last entry {last_entry} == {bss_extract(tweet.text)} (current tweet exchange) and is not None')
print('\t\t* The email pickle was not updated with exchange rate and date')
print('\t\t* The status was not updated to True')
print('~' * 45)
我期望发生的事情:
正在发生的事情:
tweet_feed != google.sheets
仅检查一次Twitter feed,并且如果apscheduler
是否按预期更新google.sheet 但 tweet_feed != google.sheets
会按计划的时间间隔不断插入相同的日期,这是每次应检查Twitter feed的时候。apscheduler
"""
print statements I wrote for particular conditions in Module A
"""
Pending jobs:
main (trigger: interval[0:02:00], pending)
from tweet_bss.py for 2019-04-15 @ 15:12:09
if 5009.63 != 5015.26 is not None
Twitter data inserted on 2019-04-15 19:07:19 to sheets
pickler() function updated the pickle file with date and exchange rate to be used for email
the status.yaml was updated to True, letting the SMTP script know it can be email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from tweet_bss.py for 2019-04-15 @ 15:12:09
if 5009.63 != 5015.26 is not None
Twitter data inserted on 2019-04-15 19:07:19 to sheets
pickler() function updated the pickle file with date and exchange rate to be used for email
the status.yaml was updated to True, letting the SMTP script know it can be email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from tweet_bss.py for 2019-04-15 @ 15:12:09
if 5009.63 != 5015.26 is not None
Twitter data inserted on 2019-04-15 19:07:19 to sheets
pickler() function updated the pickle file with date and exchange rate to be used for email
the status.yaml was updated to True, letting the SMTP script know it can be email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from tweet_bss.py for 2019-04-15 @ 15:12:09
if 5009.63 != 5015.26 is not None
Twitter data inserted on 2019-04-15 19:07:19 to sheets
pickler() function updated the pickle file with date and exchange rate to be used for email
the status.yaml was updated to True, letting the SMTP script know it can be email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?谢谢!