-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
28 lines (24 loc) · 1.16 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from core.settings import Settings
from core.auth import Authorization
from core.retweet import Retweet
import sys, sched, time
from tweepy.error import TweepError, RateLimitError
from urllib3.exceptions import NewConnectionError, MaxRetryError, ConnectTimeoutError
def main (auth_file_dir):
settings = Settings(auth_file_dir).parse()
auth = Authorization(settings)
api = auth.api()
rt = Retweet(api, settings)
rt.retweet_from_timeline()
if __name__ == "__main__":
try:
_args = sys.argv[1:]
main(str(_args[0]))
except IndexError: print("json file argument is missing.\ntry running: python app.py auth.json")
except MaxRetryError: print("Maximum number of connection attempts, you may be without internet")
except KeyboardInterrupt: print("Process interrupted by user")
except NewConnectionError: print("Failed to establish a new connection, Name or service not known or maybe you are disconnected")
except ConnectTimeoutError: print("Connection with twitter api time out, check your network connection")
except TweepError as r: print(r)
except RateLimitError as r: print(r)
except: pass