Example #1
0
    def save_task_file(self, task, filepath, version=None):
        if task is None or filepath is None: return None

        filepath = os.path.normcase(os.path.normpath(filepath))
        if version is None:
            version = self.version_for_file(filepath)

        self.config_taskfile[filepath] = {}
        self.config_taskfile[filepath]["id"] = task["id"]
        self.config_taskfile[filepath]["version"] = version
        self.config_taskfile[filepath]["time"] = (
            datetime.datetime.now() -
            datetime.datetime.fromtimestamp(86400)).total_seconds()

        jsonio.write(os.path.join(utils.configdir(), self.source_taskfile),
                     self.config_taskfile)
Example #2
0
	def load_config(self):
		self.log.debug('Loading connection config started...')
		
		self.cfg = jsonio.read(os.path.join(utils.configdir(), '.ula'))
		self.cfg.setdefault('autologin', True)	
		self.cfg.setdefault('remember', True)
		self.cfg.setdefault('lastlogin', None)
		self.cfg.setdefault('accounts', [])

		accs = self.cfg.get('accounts')
		
		for acc in accs:
			if acc.get('psw'):
				try:
					acc["psw"] = utils.string_unicode(base64.b64decode(utils.string_byte(acc["psw"]))[:-len(acc["login"])])
				except Exception:
					acc["psw"] = u''
		

		self.log.debug('Autologin: %s, Remember: %s, Lastlogin: %s', self.cfg.get('autologin'), self.cfg.get('remember'), self.cfg.get('lastlogin')) 
		self.log.debug('Loading connection config has been successfully.')
Example #3
0
	def save_config(self):
		self.log.debug('Save connection config started...')
		
		if self.current_acc and self.current_acc.get('id'):
			accs = self.cfg.get('accounts')
			self.cfg.update({'lastlogin': self.user_id})
			saved = False
			for index, account in enumerate(accs):
				if account.get('id') == self.user_id:
					accs[index] = self.current_acc
					if not self.cfg.get('remember'):
						accs[index]['psw'] = u''
					saved = True
					break

			if not saved:
				accs.insert(0, self.current_acc)
				if not self.cfg.get('remember'):
					accs[0]['psw'] = u''
			"""
			else:
				self.cfg.update({'lastlogin': None})
				for index, account in enumerate(accs):
					if account.get('id') == self.user_id:
						#accs.pop(index)
						accs[index]['psw'] = u''
						break
			"""
			self.cfg.update({'accounts': accs})

			save_cfg = copy.deepcopy(self.cfg)
			for acc in save_cfg["accounts"]:
				acc["psw"] = utils.string_unicode(base64.b64encode(utils.string_byte(acc["psw"] + acc["login"])))

			jsonio.write(os.path.join(utils.configdir(), '.ula'), save_cfg)

		self.log.debug('Save connection config has been successfully.')
Example #4
0
	def state_load(self):
		state = jsonio.read(os.path.join(utils.configdir(), self.state_file))
		if state is not None and len(state) > 0:
			self.cb_version.setChecked(state["current_version"])
Example #5
0
	def state_save(self):
		state = {}
		state["current_version"] = self.cb_version.isChecked()
		jsonio.write(os.path.join(utils.configdir(), self.state_file), state)
Example #6
0
 def load_task_file(self):
     self.config_taskfile = jsonio.read(
         os.path.join(utils.configdir(), self.source_taskfile))