def on_session_start(self): backend.fix_crontab() self._log = '' self._labeltext = '' self._editing_task = -1 self._editing_other = -1 self._error = '' self._tasks = [] self._others = [] #self._tab = 0 self._show_dialog = 0 self._newtask = False
def on_session_start(self): self._user = shell('whoami').strip() backend.fix_crontab(self._user) self._labeltext = '' self._editing_task = -1 self._editing_other = -1 self._error = '' self._tasks = [] self._others = [] self._tab = 0 self._show_dialog = 0 self._show_dialog_user = 0
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 on_submit_form(self, event, params, vars=None): "For user select or Regular and advanced Task" if params[0] == 'frmUser': self._user = vars.getvalue('users_select') or 'root' backend.fix_crontab(self._user) self._tasks, self._others = backend.read_crontab(self._user) return 0 if params[0] == 'frmAdvanced' and\ vars.getvalue('action') == 'OK': task_str = ' '.join(( vars.getvalue('m').replace(' ', '') or '*', vars.getvalue('h').replace(' ', '') or '*', vars.getvalue('dom').replace(' ', '') or '*', vars.getvalue('mon').replace(' ', '') or '*', vars.getvalue('dow').replace(' ', '') or '*' )) task_str += '\t' + vars.getvalue('a_command') if self.set_task(task_str): return 1 elif params[0] == 'frmSpecial' and\ vars.getvalue('action') == 'OK': task_str = '@' + vars.getvalue('special') task_str += '\t' + vars.getvalue('s_command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempMinutes' and\ vars.getvalue('action') == 'OK': task_str = '*/' + (vars.getvalue('minutes') or '1') task_str += ' * * * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempHours' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute_select_h') + ' ' task_str += '*/' + (vars.getvalue('hours') or '1') task_str += ' * * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempDays' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute_select_d') + ' ' task_str += vars.getvalue('hour_select_d') + ' ' task_str += '*/' + (vars.getvalue('days') or '1') task_str += ' * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempMonths' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute_select_m') + ' ' task_str += vars.getvalue('hour_select_m') + ' ' task_str += vars.getvalue('day_select') + ' ' task_str += '*/' + (vars.getvalue('months') or '1') task_str += ' *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempWeek' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute_select_w') + ' ' task_str += vars.getvalue('hour_select_w') + ' ' task_str += '* * ' task_str += vars.getvalue('weekday_select') task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 self._show_dialog = 0 self._editing_task = -1 self._newtask = False self._tab = 0
def on_submit_form(self, event, params, vars=None): if params[0] == 'frmUsers' and\ vars.getvalue('action') == 'OK': self._user = vars.getvalue('users') or 'root' backend.fix_crontab(self._user) self._tasks, self._others = backend.read_crontab(self._user) if params[0] == 'frmAdvanced' and\ vars.getvalue('action') == 'OK': task_str = ' '.join( (vars.getvalue('m').replace(' ', '') or '*', vars.getvalue('h').replace(' ', '') or '*', vars.getvalue('dom').replace(' ', '') or '*', vars.getvalue('mon').replace(' ', '') or '*', vars.getvalue('dow').replace(' ', '') or '*')) task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmSpecial' and\ vars.getvalue('action') == 'OK': task_str = '@' + vars.getvalue('special') task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempMinutes' and\ vars.getvalue('action') == 'OK': task_str = '*/' + (vars.getvalue('minutes') or '1') task_str += ' * * * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempHours' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minutes') + ' ' task_str += '*/' + (vars.getvalue('hours') or '1') task_str += ' * * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempDays' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute') + ' ' task_str += vars.getvalue('hour') + ' ' task_str += '*/' + (vars.getvalue('days') or '1') task_str += ' * *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempMonths' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute') + ' ' task_str += vars.getvalue('hour') + ' ' task_str += vars.getvalue('day') + ' ' task_str += '*/' + (vars.getvalue('months') or '1') task_str += ' *' task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 elif params[0] == 'frmTempWeek' and\ vars.getvalue('action') == 'OK': task_str = vars.getvalue('minute') + ' ' task_str += vars.getvalue('hour') + ' ' task_str += '* * ' task_str += vars.getvalue('weekday') task_str += '\t' + vars.getvalue('command') if self.set_task(task_str): return 1 self._show_dialog = 0 self._editing_task = -1 self._newtask = False