Skip to content

Commit 58b8a5d

Browse files
Version 1.4.6
- fixed an endless loop if firefox was installed but not used
1 parent 5f2b6aa commit 58b8a5d

2 files changed

Lines changed: 47 additions & 7 deletions

File tree

main.py

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from os import remove
23
from os.path import isfile
34

45
from termcolor import cprint
@@ -43,7 +44,8 @@ def main_menu():
4344
# if an update is available, say so and enable option to download update
4445
if update_check_result == UpdateCheckResult.UPDATE_AVAILABLE:
4546
cprint(f'NEW VERSION AVAILABLE: {new_update_version}\n'
46-
f'Changelog: https://github.com/InitialPosition/pyJAMa/releases/tag/v{new_update_version}\n', 'white',
47+
f'Changelog: https://github.com/InitialPosition/pyJAMa/releases/tag/v{new_update_version}\n',
48+
'white',
4749
'on_green')
4850
valid_selections.append('4')
4951

@@ -74,11 +76,13 @@ def main_menu():
7476
# voting failed for some reason. abort and tell the user
7577
clear_console()
7678

77-
cprint('An error occurred during the voting process. This probably means the API is overloaded or you lost '
78-
'internet connection.',
79-
'red')
80-
cprint('The program will now terminate. Check your internet connection and try again. If voting still fails'
81-
', wait a few minutes and try again.', 'red')
79+
cprint(
80+
'An error occurred during the voting process. This probably means the API is overloaded or you lost '
81+
'internet connection.',
82+
'red')
83+
cprint(
84+
'The program will now terminate. Check your internet connection and try again. If voting still fails'
85+
', wait a few minutes and try again.', 'red')
8286

8387
exit(0)
8488

@@ -119,6 +123,7 @@ def cookie_setup():
119123
if cookie_fetch != -1:
120124
print(f'Cookie retrieved: {cookie_fetch}')
121125
save_config(cookie_fetch)
126+
122127
return
123128

124129
clear_console()
@@ -177,9 +182,39 @@ def cookie_setup():
177182
jsonified_themes = json.loads(request.text)
178183

179184
if jsonified_themes['status'] == 200:
185+
if isfile('cookie_fail'):
186+
remove('cookie_fail')
187+
180188
themes = jsonified_themes["ideas"]
181189
else:
182190

191+
if isfile('cookie_fail'):
192+
remove('cookie_fail')
193+
194+
clear_console()
195+
196+
# print logo
197+
print_file('files/logo.txt')
198+
print_version_info()
199+
print()
200+
201+
# explain why cookies are necessary
202+
print_file('files/cookie_explanation.txt')
203+
print()
204+
205+
# get cookie input
206+
cookie_sids = input('SIDS > ')
207+
208+
# treat empty input as deletion request, otherwise save new data
209+
if cookie_sids == '':
210+
delete_config()
211+
exit(0)
212+
else:
213+
save_config(cookie_sids)
214+
215+
print('\nCookie saved. Please restart the program.')
216+
exit(0)
217+
183218
# if we land here, the API was not happy with our theme request, meaning something is most likely wrong with the
184219
# entered cookies. we delete the cookies and let the user enter them again.
185220
clear_console()
@@ -190,13 +225,18 @@ def cookie_setup():
190225
'red')
191226
cprint('If you are, you might want to log out and back in once.',
192227
'red')
228+
cprint('If cookie fetching isn\'t successful next time, you will be required to enter your token manually.',
229+
'red')
193230

194231
print()
195232
print('DEBUG INFO:')
196233
print(jsonified_themes)
197234
print()
198235

199236
delete_config()
237+
with open('cookie_fail', 'w') as f:
238+
f.write('If this file exists, a saved cookie was no longer valid for the API. If a new cookie can\'t be '
239+
'fetched next time the program runs, it will ask you for manual cookie entry.\n')
200240

201241
exit(0)
202242

util/CONSTANTS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CONFIG_FILE = 'config.yml'
2-
VERSION = '1.4.5'
2+
VERSION = '1.4.6'
33
AUTHOR = 'InitialPosition / RedCocoa'

0 commit comments

Comments
 (0)