當前位置: 首頁>>代碼示例>>Python>>正文


Python DBCache.__init__方法代碼示例

本文整理匯總了Python中MythTV.database.DBCache.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python DBCache.__init__方法的具體用法?Python DBCache.__init__怎麽用?Python DBCache.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MythTV.database.DBCache的用法示例。


在下文中一共展示了DBCache.__init__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from MythTV.database import DBCache [as 別名]
# 或者: from MythTV.database.DBCache import __init__ [as 別名]
    def __init__(self, path=None, setting=None, db=None, useshell=True, prefix=''):
        DBCache.__init__(self, db=db)
        self.log = MythLog(self.logmodule, db=self)
        self.path = None

        if setting is not None:
            # pull local setting from database
            host = self.gethostname()
            self.path = self.settings[host][setting]
            if self.path is None:
                # see if that setting is applied globally
                self.path = self.settings['NULL'][setting]
            if self.path is None:
                # not set globally either, use supplied default
                self.path = path
            if self.path is None:
                # no default supplied, just error out
                raise MythDBError(MythError.DB_SETTING, setting, host)

        if self.path is None:
            # setting not given, use path from argument
            if path is None:
                raise MythError('Invalid input to System()')
            self.path = path

        if prefix:
            self.path = os.path.join(prefix, self.path)

        cmd = self.path.split()[0]
        if self.path.startswith('/'):
            # test full given path
            if not os.access(cmd, os.F_OK):
                raise MythFileError('Defined executable path does not exist.')
        else:
            # search command from PATH
            for folder in os.environ['PATH'].split(':'):
                if os.access(os.path.join(folder,cmd), os.F_OK):
                    self.path = os.path.join(folder,self.path)
                    break
            else:
                raise MythFileError('Defined executable path does not exist.')
                
        self.returncode = 0
        self.stderr = ''
        self.useshell = useshell
開發者ID:DaveDaCoda,項目名稱:mythtv,代碼行數:47,代碼來源:system.py


注:本文中的MythTV.database.DBCache.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。