File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515logging .basicConfig (
1616 format = "%(asctime)s - %(levelname)s - %(message)s" , level = logging .INFO
1717)
18+ logging .basicConfig (
19+ format = "%(asctime)s - %(levelname)s - %(message)s" , level = logging .WARNING
20+ )
1821logging .basicConfig (
1922 format = "%(asctime)s - %(levelname)s - %(message)s" , level = logging .ERROR
2023)
@@ -48,12 +51,15 @@ def send_news_to_telegram(message):
4851if __name__ == "__main__" :
4952 data_from_db = news_db .create_connection (news_db .DB_FILE )
5053 while True :
51- time .sleep (1 )
52- current_time = datetime .now ().strftime ("%H:%M" )
53- if TIME_TO_SEND_START < current_time < TIME_TO_SEND_END :
54- logging .info (f"Time: { current_time } . Time to send has come !" )
55- for news in news_db .send_all_news (data_from_db ):
56- send_news_to_telegram (news )
57- time .sleep (300 )
54+ if data_from_db :
55+ time .sleep (1 )
56+ current_time = datetime .now ().strftime ("%H:%M" )
57+ if TIME_TO_SEND_START < current_time < TIME_TO_SEND_END :
58+ logging .info (f"Time: { current_time } . Time to send has come !" )
59+ for news in news_db .send_all_news (data_from_db ):
60+ send_news_to_telegram (news )
61+ time .sleep (300 )
62+ else :
63+ logging .info (f"Time: { current_time } . Still waiting to send." )
5864 else :
59- logging .info ( f"Time: { current_time } . Still waiting to send ." )
65+ logging .warning ( "Looks like database is empty ." )
Original file line number Diff line number Diff line change 99
1010TIME_TO_PURGE = "00:00"
1111
12- DB_FILE = Path (f"/mnt/ { dynaconfig .settings ['DB_NAME' ]} " )
12+ DB_FILE = Path (f"{ dynaconfig .settings ['DB_NAME' ]} " )
1313
1414# SQL queries
1515CREATE_TABLE_SQL = """
Original file line number Diff line number Diff line change 1+ newsapi-python
12requests~=2.28.1
23dynaconf~=3.1.11
34dynaconfig~=0.4
Original file line number Diff line number Diff line change 11black
2- isort
2+ isort
3+ newsapi-python
4+ requests ~= 2.28.1
5+ dynaconf ~= 3.1.11
6+ dynaconfig ~= 0.4
You can’t perform that action at this time.
0 commit comments