1+ from configparser import ConfigParser
12from datetime import datetime
23from notifypy import Notify
34from colorama import Fore
67import requests
78import logging
89import os .path
9- import dotenv
1010import time
1111import sys
1212import os
1515
1616logging .basicConfig (level = logging .INFO ,format = '%(asctime)s : %(levelname)s : %(message)s' )
1717
18- config_path = "assets/config.env"
19- dotenv .load_dotenv (config_path )
18+ config_path = "assets/config.ini"
2019
21- COLOR = os .environ .get ("COLOR" )
20+ cfg = ConfigParser ()
21+ cfg .read (config_path )
22+
23+ COLOR = cfg ["settings" ]["color" ]
2224
2325user_choice = - 1
2426user_choice_block_website = ""
2931user_choice_settings_confirm_clear = - 1
3032user_choice_settings_choice_list = ""
3133
32- current_version = "1.4 "
34+ current_version = "1.5 "
3335
3436version_url = "https://raw.githubusercontent.com/Rabixx/updater/main/version.txt"
3537
@@ -152,8 +154,8 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
152154 user_confirm_choice = str (input ("(yes,no): " ))
153155
154156 if user_confirm_choice == "yes" :
155- os .system ('start https://cutt.ly/wWoOWvb ' )
156- os . system ( 'cls' )
157+ os .system ('start ../update/updater.exe ' )
158+ sys . exit ( )
157159 elif user_confirm_choice == "no" :
158160 os .system ('cls' )
159161 else :
@@ -201,9 +203,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
201203 if user_choice_settings_confirm_color == 1 :
202204 os .system ('cls' )
203205
204- os . environ [ "COLOR" ] = " RED"
206+ cfg . set ( 'settings' , 'color' , ' RED' )
205207
206- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
208+ with open (config_path ,"w" ) as clr_1 :
209+ cfg .write (clr_1 )
207210
208211 print ("Changed color to red!" )
209212 print ()
@@ -214,9 +217,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
214217 elif user_choice_settings_confirm_color == 2 :
215218 os .system ('cls' )
216219
217- os . environ [ "COLOR" ] = " GREEN"
220+ cfg . set ( 'settings' , 'color' , ' GREEN' )
218221
219- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
222+ with open (config_path ,"w" ) as clr_2 :
223+ cfg .write (clr_2 )
220224
221225 print ("Changed color to green!" )
222226 print ()
@@ -227,9 +231,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
227231 elif user_choice_settings_confirm_color == 3 :
228232 os .system ('cls' )
229233
230- os . environ [ "COLOR" ] = " YELLOW"
234+ cfg . set ( 'settings' , 'color' , ' YELLOW' )
231235
232- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
236+ with open (config_path ,"w" ) as clr_3 :
237+ cfg .write (clr_3 )
233238
234239 print ("Changed color to yellow!" )
235240 print ()
@@ -240,9 +245,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
240245 elif user_choice_settings_confirm_color == 4 :
241246 os .system ('cls' )
242247
243- os . environ [ "COLOR" ] = " BLUE"
248+ cfg . set ( 'settings' , 'color' , ' BLUE' )
244249
245- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
250+ with open (config_path ,"w" ) as clr_4 :
251+ cfg .write (clr_4 )
246252
247253 print ("Changed color to blue!" )
248254 print ()
@@ -253,9 +259,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
253259 elif user_choice_settings_confirm_color == 5 :
254260 os .system ('cls' )
255261
256- os . environ [ "COLOR" ] = " MAGENTA"
262+ cfg . set ( 'settings' , 'color' , ' MAGENTA' )
257263
258- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
264+ with open (config_path ,"w" ) as clr_5 :
265+ cfg .write (clr_5 )
259266
260267 print ("Changed color to magenta!" )
261268 print ()
@@ -266,9 +273,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
266273 elif user_choice_settings_confirm_color == 6 :
267274 os .system ('cls' )
268275
269- os . environ [ "COLOR" ] = " CYAN"
276+ cfg . set ( 'settings' , 'color' , ' CYAN' )
270277
271- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
278+ with open (config_path ,"w" ) as clr_6 :
279+ cfg .write (clr_6 )
272280
273281 print ("Changed color to cyan!" )
274282 print ()
@@ -279,9 +287,10 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
279287 elif user_choice_settings_confirm_color == 7 :
280288 os .system ('cls' )
281289
282- os . environ [ "COLOR" ] = " WHITE"
290+ cfg . set ( 'settings' , 'color' , ' WHITE' )
283291
284- dotenv .set_key (config_path ,"COLOR" ,os .environ ["COLOR" ])
292+ with open (config_path ,"w" ) as clr_7 :
293+ cfg .write (clr_7 )
285294
286295 print ("Changed color to deafult!" )
287296 print ()
@@ -373,9 +382,15 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
373382
374383if __name__ == "__main__" :
375384 if sys .platform .startswith ("win" ):
376- on_start ()
377- load_config ()
378- main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path ,version_url ,current_version ,user_confirm_choice ,user_choice_settings ,user_choice_settings_confirm_clear ,user_choice_settings_confirm_color ,config_path ,COLOR ,user_choice_settings_choice_list )
385+ try :
386+ on_start ()
387+ load_config ()
388+ main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path ,version_url ,current_version ,user_confirm_choice ,user_choice_settings ,user_choice_settings_confirm_clear ,user_choice_settings_confirm_color ,config_path ,COLOR ,user_choice_settings_choice_list )
389+ except Exception as ex_6 :
390+ os .system ('cls' )
391+ print (f"[ERROR] { ex_6 } " )
392+ time .sleep (2 )
393+ os .system ('cls' )
379394 else :
380395 logging .warning ("SimpleWebsiteBlocker works only on Windows operating system!" )
381396 os .system ('pause' )
0 commit comments