File tree Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Original file line number Diff line number Diff line change 2
2
import os
3
3
4
4
# Bot version (MAJOR.MINOR.PATCH)
5
- bot_version = "1.0.2 "
5
+ bot_version = "1.0.3 "
6
6
7
7
# Today
8
8
today = dt .date .today ()
Original file line number Diff line number Diff line change @@ -53,8 +53,12 @@ def parse_args():
53
53
return parser .parse_args ()
54
54
55
55
56
- # * Script Starts Here
57
- if __name__ == "__main__" :
56
+ def main ():
57
+ """
58
+ Initialize & starts the bot
59
+ If the bot crashes, it will attempt to restart itself
60
+ """
61
+
58
62
args = parse_args ()
59
63
60
64
color_me = wbm_logger .ColoredLogger (__appname__ )
@@ -99,15 +103,26 @@ def parse_args():
99
103
page_changed = False
100
104
LOG .info (color_me .cyan (f"Connecting to '{ start_url } ' 🔗" ))
101
105
102
- webDriverOperations .process_flats (
103
- web_driver ,
104
- user_profile ,
105
- start_url ,
106
- current_page ,
107
- previous_page ,
108
- page_changed ,
109
- args .interval ,
110
- args .test ,
111
- )
106
+ try :
107
+ while True :
108
+ webDriverOperations .process_flats (
109
+ web_driver ,
110
+ user_profile ,
111
+ start_url ,
112
+ current_page ,
113
+ previous_page ,
114
+ page_changed ,
115
+ args .interval ,
116
+ args .test ,
117
+ )
118
+ except Exception as e :
119
+ LOG .error (color_me .red (f"Bot has crashed... Attempting to restart it now! ❤️🩹" ))
120
+ # Wait for a few seconds before restarting
121
+ time .sleep (5 )
122
+ # Restart the script
123
+ main ()
124
+
112
125
113
- # driver.quit()
126
+ # * Script Starts Here
127
+ if __name__ == "__main__" :
128
+ main ()
You can’t perform that action at this time.
0 commit comments