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


Python Observable.updateData方法代码示例

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


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

示例1: EfaLiveSettings

# 需要导入模块: from observable import Observable [as 别名]
# 或者: from observable.Observable import updateData [as 别名]
class EfaLiveSettings(object):

    def __init__(self, confPath = os.path.join(os.path.expanduser('~'), ".efalive")):
        self._logger = logging.getLogger('efalive.common.EfaLiveSettings')
        self._checkPath(confPath)
        self.confPath = confPath
        self._logger.info("Using configuration directory '%s'" % confPath)
        self._settingsFileName = os.path.join(self.confPath, "settings.conf")
        self._backupFileName = os.path.join(self.confPath, "backup.conf")
        self.efaShutdownAction = Observable()
        self.autoUsbBackup = Observable()
        self.autoUsbBackupDialog = Observable()
        self.efaLiveBackupPaths = "/home/efa/.efalive"
        self.efaPort = Observable()
        self.efaCredentialsFile = "~/.efalive/.efacred"
        self.auto_backup_use_password = Observable()
        self.auto_backup_password = ""
        self.mailer_host = Observable()
        self.mailer_port = Observable()
        self.mailer_use_ssl = Observable()
        self.mailer_use_starttls = Observable()
        self.mailer_user = Observable()
        self.mailer_password = Observable()
        self.mailer_sender = Observable()
        self.backup_mail_recipient = Observable()
        self.hourly_tasks = Observable()
        self.daily_tasks = Observable()
        self.weekly_tasks = Observable()
        self.monthly_tasks = Observable()

    def initSettings(self):
        self.efaShutdownAction.updateData("shutdown")
        self.efaPort.updateData(3834)
        self.mailer_host.updateData("")
        self.mailer_port.updateData(25)
        self.mailer_use_ssl.updateData(False)
        self.mailer_use_starttls.updateData(True)
        self.mailer_user.updateData("")
        self.mailer_password.updateData("")
        self.mailer_sender.updateData("")
        self.load_settings()

    def load_settings(self):
        if os.path.isfile(self._settingsFileName):
            settingsFile=open(self._settingsFileName, "r")
            self.parseSettingsFile(settingsFile)
            settingsFile.close()

    def _checkPath(self, path):
        if not os.path.exists(path):
            self._logger.debug("Creating directory: %s" % path)
            os.makedirs(path, 0755)

    def parseSettingsFile(self, file):
        self._logger.info("Parsing settings file")
        for line in file:
            if line.startswith("EFA_SHUTDOWN_ACTION="):
                actionStr=line[(line.index('=') + 1):].rstrip()
                self.efaShutdownAction.updateData(actionStr)
                self._logger.debug("Parsed shutdown action: " + actionStr)
            elif line.startswith("AUTO_USB_BACKUP="):
                enableStr=line[(line.index('=') + 1):].rstrip()
                self.autoUsbBackup.updateData(enableStr == "\"TRUE\"")
                self._logger.debug("Parsed auto USB backup setting: " + enableStr)
            elif line.startswith("AUTO_USB_BACKUP_DIALOG="):
                enableStr=line[(line.index('=') + 1):].rstrip()
                self.autoUsbBackupDialog.updateData(enableStr == "\"TRUE\"")
                self._logger.debug("Parsed auto USB backup dialog setting: " + enableStr)
            elif line.startswith("EFALIVE_BACKUP_PATHS="):
                backupStr=line[(line.index('=') + 1):].rstrip()
                self.efaLiveBackupPaths = backupStr.replace("\"", "")
                self._logger.debug("Parsed efaLive backup paths: " + backupStr)
            elif line.startswith("EFA_PORT="):
                portStr=line[(line.index('=') + 1):].rstrip()
                self.efaPort.updateData(int(portStr))
                self._logger.debug("Parsed efa port: " + portStr)
            elif line.startswith("EFA_CREDENTIALS_FILE="):
                credStr=line[(line.index('=') + 1):].rstrip()
                self.efaCredentialsFile = credStr
                self._logger.debug("Parsed efa credentials file setting: " + credStr)
            elif line.startswith("AUTO_BACKUP_PASSWORD="):
                pwdStr=line[(line.index('=') + 1):].rstrip()
                self.auto_backup_password = pwdStr
                self._logger.debug("Parsed efa auto backup password setting: " + pwdStr)
            elif line.startswith("AUTO_BACKUP_USE_PASSWORD="):
                enableStr=line[(line.index('=') + 1):].rstrip()
                self.auto_backup_use_password.updateData(enableStr == "\"TRUE\"")
                self._logger.debug("Parsed auto backup enable password setting: " + enableStr)
            elif line.startswith("MAILER_HOST="):
                hostStr=line[(line.index('=') + 1):].rstrip()
                self.mailer_host.updateData(hostStr)
                self._logger.debug("Parsed efa mailer host setting: " + hostStr)
            elif line.startswith("MAILER_PORT="):
                portStr=line[(line.index('=') + 1):].rstrip()
                self.mailer_port.updateData(int(portStr))
                self._logger.debug("Parsed efa mailer port setting: " + portStr)
            elif line.startswith("MAILER_USE_SSL="):
                enableStr=line[(line.index('=') + 1):].rstrip()
                self.mailer_use_ssl.updateData(enableStr == "\"TRUE\"")
                self._logger.debug("Parsed efa mailer use SSL setting: " + enableStr)
#.........这里部分代码省略.........
开发者ID:efalive,项目名称:efalive,代码行数:103,代码来源:settings.py


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