Skip to content

Commit

Permalink
v1.18.10: Add save on submit feature for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Aug 22, 2020
1 parent d15b555 commit 2290f52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions meleeuploader/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
stopUpdates = False
submitted = True
startQueue = False
saveOnSubmit = False

youtube = None
sheets = None
Expand Down
12 changes: 9 additions & 3 deletions meleeuploader/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(self):
self.mainmenu = [
{'Settings': [{'YouTube Log Out': self.__reset_cred}, {'Toggle OBS Hook': self.__show_obs_form}, {'Toggle SA Hook': self.__show_sa_form}, {'Toggle SC Hook': self.__show_sc_form}, {'Toggle Streameta Hook': self.__show_sm_form}, {'About': self.__about_info}],
'Save/Clear': [{'Save Form': self.__save_form}, {'Clear Match Values': self.__reset_match}, {'Clear Event Values': self.__reset_event}, {'Clear All': self.__reset_forms}],
'Queue': [{'Toggle Uploads': utils.toggle_worker}, {'Save Queue': self.__save_queue}, {'Load Queue': self.__load_queue}],
'Queue': [{'Toggle Uploads': utils.toggle_worker}, {'Save Queue': self.__save_queue}, {'Load Queue': self.__load_queue}, {'Toggle Save on Submit': self.__save_on_submit}],
'History': [{'Show History': self.__show_hview}],
'Characters': [{'Melee': self.__melee_chars}, {'Ultimate': self.__ultimate_chars}, {'64': self.__64_chars}, {'Rivals': self.__rivals_chars}, {'Splatoon': self.__splatoon_chars}, {'Custom': self.__custom_chars}]}]

Expand Down Expand Up @@ -320,6 +320,8 @@ def __button_action(self, data=None):
thr.daemon = True
thr.start()
consts.firstrun = False
if consts.saveOnSubmit:
self.__save_queue(True)

def write_print(self, text):
self._output.value += text
Expand Down Expand Up @@ -520,8 +522,8 @@ def __delete_from_queue_view(self, job_num):
job.ignore = True
self._qview -= job_num

def __save_queue(self):
if os.path.exists(consts.queue_values):
def __save_queue(self, silent=False):
if os.path.exists(consts.queue_values) and not silent:
resp = self.question(f"A queue already exists would you like to overwrite it?\nIt was last modified on {datetime.utcfromtimestamp(int(os.path.getmtime(consts.queue_values))).strftime('%Y-%m-%d')}")
if resp == "yes":
with open(consts.queue_values, "wb") as f:
Expand Down Expand Up @@ -590,6 +592,10 @@ def __load_queue(self):
thr.start()
consts.loadedQueue = True

def __save_on_submit(self) :
consts.saveOnSubmit = not consts.saveOnSubmit
print(f"Save Queue on Submit is turned {'on' if consts.saveOnSubmit else 'off'}.")

def __save_form(self, options=[]):
row = [None] * (len(self._form_fields) + 1)
if options:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from os import path

here = path.abspath(path.dirname(__file__))
version = '1.18.9'
version = '1.18.10'

long_des = ""
with open(path.join(here, 'README.md')) as f:
Expand Down

0 comments on commit 2290f52

Please sign in to comment.