def on_submit_dlg(self, event, params, vars=None): if params[0] == 'dlgEditOther' and\ vars.getvalue('action') == 'OK': if self._editing_other < len(self._others): self._others[self._editing_other] = vars.getvalue('other_str') else: self._others.append(vars.getvalue('other_str')) self._error = backend.write_crontab(self._others +\ self._tasks) if self._error: self._tasks, self._others = backend.read_crontab() self._show_dialog = 0 self._editing_other = -1
def on_click(self, event, params, vars=None): if params[0] == 'add_task': self._editing_task = len(self._tasks) self._show_dialog = 1 self._newtask = True if params[0] == 'edit_task': self._editing_task = int(params[1]) self._show_dialog = 1 if params[0] == 'del_task': self._tasks.pop(int(params[1])) self._error = backend.write_crontab(self._others +\ self._tasks) if params[0] == 'add_oth': self._editing_other = len(self._others) self._show_dialog = 1 if params[0] == 'edit_oth': self._editing_other = int(params[1]) self._show_dialog = 1 if params[0] == 'del_oth': self._others.pop(int(params[1])) self._error = backend.write_crontab(self._others +\ self._tasks)
def on_click(self, event, params, vars=None): if params[0] == 'show': self._user = params[1] backend.fix_crontab(self._user) self._tasks, self._others = backend.read_crontab(self._user) if params[0] == 'add_task': self._editing_task = len(self._tasks) self._show_dialog = 1 if params[0] == 'del_task': self._tasks.pop(int(params[1])) self._error = backend.write_crontab(self._others + self._tasks, self._user) if params[0] == 'add_oth': self._editing_other = len(self._others) self._show_dialog = 1 if params[0] == 'edit_oth': self._editing_other = int(params[1]) self._show_dialog = 1 if params[0] == 'del_oth': self._others.pop(int(params[1])) self._error = backend.write_crontab(self._others + self._tasks, self._user) self._tab = 1
def set_task(self, task_str): try: new_task = backend.Task(task_str) except: self._error = 'Error: Wrong options.' self._editing_task = -1 return 1 if self._editing_task < len(self._tasks): self._tasks[self._editing_task] = new_task else: self._tasks.append(new_task) self._error = backend.write_crontab(self._others +\ self._tasks) if self._error: self._tasks, self._others = backend.read_crontab() return 0
def set_task(self, task_str): "Set new or edited task" #noinspection PyBroadException try: new_task = backend.Task(task_str) except: self._error = 'Error: Wrong options.' self._editing_task = -1 return 1 if self._editing_task < len(self._tasks): self._tasks[self._editing_task] = new_task else: self._tasks.append(new_task) self._error = backend.write_crontab(self._others + self._tasks, self._user) if self._error: self._tasks, self._others = backend.read_crontab() ConfManager.get().commit('cron') return 0