def post(self): if self.get_argument('name', None) == shelve_get('admin_name') and \ self.get_argument('password', None) == shelve_get('admin_password'): self.set_secure_cookie('user', 'admin') self.redirect('/admin') return self.redirect(self.request.path)
def last_program_state(): state = shelve_get(['last_state']) if state: state = state['last_state'] else: state = 'main' return state
def __init__(self): self.handlers = [(r'/', CheckForUpdates), (r'/admin/login', AdminLogin), (r'/admin', Admin)] self.settings = dict( template_path=TEMPLATE_PATH, static_path=STATIC_PATH, cookie_secret='ss1sx!sd15cx1vfgsdf453s2~1`!s=d453', login_url='/admin/login', debug=DEBUG) self.version = shelve_get('version') super(Application, self).__init__(handlers=self.handlers, **self.settings)
def __init__(self): self.handlers = [(r'/', CheckForUpdates), (r'/admin/login', AdminLogin), (r'/admin', Admin)] self.settings = dict( template_path=TEMPLATE_PATH, static_path=STATIC_PATH, cookie_secret='ss1sx!sd15cx1vfgsdf453s2~1`!s=d453', login_url='/admin/login', debug=DEBUG ) self.version = shelve_get('version') super(Application, self).__init__(handlers=self.handlers, **self.settings)
def setup_app(self): logging.debug('Setting up UI application...') self.setupUi(self) self.setWindowIcon(QIcon(config.app_icon_path)) self.hide_install_updates() logging.debug('Setting default date time for timers') self.action_after_time.setTime( QTime(*config.action_after_time_default)) self.action_after_time.setMinimumTime( QTime(*config.action_after_time_minimum)) self.action_at_datetime.setDateTime(self.run_from_dt) self.action_at_datetime.setMinimumDateTime(self.run_from_dt + datetime.timedelta( minutes=1)) self.action_at_datetime.setMaximumDateTime(self.run_from_dt + datetime.timedelta(7)) self.action_at_datetime.setDisplayFormat('MM/dd/yy hh:mm') if self.os_version == constants.DARWIN: self.action_after_select.removeItem(2) self.action_at_select.removeItem(2) elif self.os_version in (constants.LINUX, constants.LINUX2): self.action_at_select.removeItem(3) self.action_after_select.removeItem(3) logging.debug('Getting values from shelve for timers') timer_at = shelve_get(constants.TIMER_AT_DATETIME) timer_after = shelve_get(constants.TIMER_AFTER_TIME) self.callbacks = Callback(self) if timer_at: logging.debug('At timer exists in shelve file. \n' 'Timer at time: %s' % timer_at) if seconds_from_datetime(timer_at) > self.run_from_timestamp: logging.debug('Starting at timer gotten from shelve') threading.Thread(target=self.callbacks.start_timer, args=(constants.DATE_AT, timer_at, shelve_get(constants.TIMER_AT_ACTION)), daemon=True).start() self.callbacks.set_disabled_timer(constants.DATE_AT) else: logging.debug('Setting timer at to shelve as None') shelve_save( **{ constants.TIMER_AT_DATETIME: None, constants.TIMER_AT_ACTION: None }) if timer_after: logging.debug('After timer exists in shelve file. \n' 'Timer after time: %s' % timer_after) if seconds_from_datetime(timer_after, tm_format='%m/%d/%y %H:%M %S') > \ time.time(): seconds_to_action = seconds_from_datetime( timer_after, tm_format='%m/%d/%y %H:%M %S') - \ self.run_from_timestamp days_time_to_action = format_hours_minutes_from_seconds( seconds_to_action) self.callbacks.show_time_to_action(days_time_to_action) logging.debug('Starting after timer gotten from shelve') threading.Thread(target=self.callbacks.start_timer, args=(constants.DATE_AFTER, timer_after, shelve_get( constants.TIMER_AFTER_ACTION)), daemon=True).start() self.callbacks.set_disabled_timer(constants.DATE_AFTER) else: logging.debug('Setting timer after to shelve as None') shelve_save( **{ constants.TIMER_AFTER_TIME: None, constants.TIMER_AFTER_ACTION: None })
def get_user_credentials(): return shelve_get(['email', 'password'])
def get_canvas_coordinates(): coordinates = shelve_get('list_coordinates') return coordinates
def get(self): data = dict(version=shelve_get('version')) self.render('admin/admin_panel.html', data=data)