当前位置: 首页>>代码示例>>Python>>正文


Python Observable.getData方法代码示例

本文整理汇总了Python中observable.Observable.getData方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.getData方法的具体用法?Python Observable.getData怎么用?Python Observable.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在observable.Observable的用法示例。


在下文中一共展示了Observable.getData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EfaLiveSettings

# 需要导入模块: from observable import Observable [as 别名]
# 或者: from observable.Observable import getData [as 别名]

#.........这里部分代码省略.........
            elif line.startswith("MAILER_PASSWORD="):
                passStr=line[(line.index('=') + 1):].rstrip()
                self.mailer_password.updateData(base64.b64decode(passStr))
                self._logger.debug("Parsed efa mailer password setting: " + passStr)
            elif line.startswith("MAILER_SENDER="):
                senderStr=line[(line.index('=') + 2):].rstrip()[:-1]
                self.mailer_sender.updateData(senderStr)
                self._logger.debug("Parsed efa mailer sender setting: " + userStr)
            elif line.startswith("HOURLY_TASKS="):
                valueStr=line[(line.index('=') + 2):].rstrip()[:-1]
                tasks = json.loads(valueStr)
                if tasks != None:
                    task_map = {}
                    for task in tasks:
                        task_id = self._create_id(task)
                        task_map[task_id] = task
                    self.hourly_tasks.updateData(task_map)
                self._logger.debug("Parsed hourly tasks setting: " + valueStr)
            elif line.startswith("DAILY_TASKS="):
                valueStr=line[(line.index('=') + 2):].rstrip()[:-1]
                tasks = json.loads(valueStr)
                if tasks != None:
                    task_map = {}
                    for task in tasks:
                        task_id = self._create_id(task)
                        task_map[task_id] = task
                    self.daily_tasks.updateData(task_map)
                self._logger.debug("Parsed daily tasks setting: " + valueStr)
            elif line.startswith("WEEKLY_TASKS="):
                valueStr=line[(line.index('=') + 2):].rstrip()[:-1]
                tasks = json.loads(valueStr)
                if tasks != None:
                    task_map = {}
                    for task in tasks:
                        task_id = self._create_id(task)
                        task_map[task_id] = task
                    self.weekly_tasks.updateData(task_map)
                self._logger.debug("Parsed weekly tasks setting: " + valueStr)
            elif line.startswith("MONTHLY_TASKS="):
                valueStr=line[(line.index('=') + 2):].rstrip()[:-1]
                tasks = json.loads(valueStr)
                if tasks != None:
                    task_map = {}
                    for task in tasks:
                        task_id = self._create_id(task)
                        task_map[task_id] = task
                    self.monthly_tasks.updateData(task_map)
                self._logger.debug("Parsed monthly tasks setting: " + valueStr)

    def _create_id(self, task):
        hasher = md5.new()
        hasher.update(task[0])
        hasher.update(str(task[1]))
        return hasher.hexdigest()

    def save(self):
        self._logger.info("Saving settings to file: %s" % (self._settingsFileName))
        try:
            settingsFile=open(self._settingsFileName, "w")
            settingsFile.write("EFA_SHUTDOWN_ACTION=%s\n" % self.efaShutdownAction.getData())
            if self.autoUsbBackup._data == True:
                settingsFile.write("AUTO_USB_BACKUP=\"TRUE\"\n")
            else:
                settingsFile.write("AUTO_USB_BACKUP=\"FALSE\"\n")
            if self.autoUsbBackupDialog._data == True:
                settingsFile.write("AUTO_USB_BACKUP_DIALOG=\"TRUE\"\n")
            else:
                settingsFile.write("AUTO_USB_BACKUP_DIALOG=\"FALSE\"\n")
            settingsFile.write("EFALIVE_BACKUP_PATHS=\"%s\"\n" % self.efaLiveBackupPaths)
            settingsFile.write("EFA_PORT=%d\n" % self.efaPort.getData())
            settingsFile.write("EFA_CREDENTIALS_FILE=%s\n" % self.efaCredentialsFile)
            settingsFile.write("AUTO_BACKUP_PASSWORD=%s\n" % self.auto_backup_password)
            if self.auto_backup_use_password._data == True:
                settingsFile.write("AUTO_BACKUP_USE_PASSWORD=\"TRUE\"\n")
            else:
                settingsFile.write("AUTO_BACKUP_USE_PASSWORD=\"FALSE\"\n")
            settingsFile.write("MAILER_HOST=%s\n" % self.mailer_host.getData())
            settingsFile.write("MAILER_PORT=%d\n" % self.mailer_port.getData())
            if self.mailer_use_ssl.getData() == True:
                settingsFile.write("MAILER_USE_SSL=\"TRUE\"\n")
            else:
                settingsFile.write("MAILER_USE_SSL=\"FALSE\"\n")
            if self.mailer_use_starttls.getData() == True:
                settingsFile.write("MAILER_USE_STARTTLS=\"TRUE\"\n")
            else:
                settingsFile.write("MAILER_USE_STARTTLS=\"FALSE\"\n")
            settingsFile.write("MAILER_USER=%s\n" % self.mailer_user.getData())
            password = self.mailer_password.getData()
            if password != None:
                password = base64.b64encode(password)
            settingsFile.write("MAILER_PASSWORD=%s\n" % password)
            settingsFile.write("MAILER_SENDER='%s'\n" % self.mailer_sender.getData())
            settingsFile.write("HOURLY_TASKS='%s'\n" % json.dumps(self._get_tasks(self.hourly_tasks)))
            settingsFile.write("DAILY_TASKS='%s'\n" % json.dumps(self._get_tasks(self.daily_tasks)))
            settingsFile.write("WEEKLY_TASKS='%s'\n" % json.dumps(self._get_tasks(self.weekly_tasks)))
            settingsFile.write("MONTHLY_TASKS='%s'\n" % json.dumps(self._get_tasks(self.monthly_tasks)))
            settingsFile.close()
        except IOError, exception:
            self._logger.error("Could not save files: %s" % exception)
            raise Exception("Could not save files")
开发者ID:efalive,项目名称:efalive,代码行数:104,代码来源:settings.py


注:本文中的observable.Observable.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。