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


Python FileUtils.isFile方法代码示例

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


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

示例1: checkEmbeddedDB

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def checkEmbeddedDB():
    global isAskEmbeddedDBConfiguration
    if uni.getBoolValue("isReadOnlyAmarokDB"):
        if (fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok") and
                fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/mysql") and
                fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/my.cnf")):
            return startReadOnlyEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
                                     translate("Amarok",
                                               "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
                if answer == Dialogs.Yes:
                    ReadOnlyEmbeddedDBConfigurator()
            else:
                return False
    else:
        if (fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysql/db.frm") and
                fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf")):
            return startEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
                                     translate("Amarok",
                                               "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
                if answer == Dialogs.Yes:
                    EmbeddedDBConfigurator()
            else:
                return False
    return checkEmbeddedDB()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:34,代码来源:__init__.py

示例2: makeBackUp

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def makeBackUp(_settingType="All", _backUpDirectory="BackUps", _newFileName="mirror"):
    files = []
    if _settingType == "database" or _settingType == "All":
        files.append("database.sqlite")
    if _settingType == "Settings" or _settingType == "All":
        files.append(uni.fileOfSettings)
    if fu.isDir(fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory)) is False:
        fu.makeDirs(fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory))
    isReturn = False
    for backupFile in files:
        if _newFileName == "mirror":
            newFileName = backupFile
        elif _newFileName == "random":
            isReturn = True
            import random

            while 1 == 1:
                newFileName = (backupFile[:backupFile.find(".")] + "_" + str(random.randrange(0, 100000000)) +
                               backupFile[backupFile.find("."):])
                if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory, newFileName)) is False:
                    break
        else:
            newFileName = _newFileName
        if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory, newFileName)):
            fu.removeFile(fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory, newFileName))
        try:
            fu.copyFileOrDir(fu.joinPath(fu.pathOfSettingsDirectory, backupFile),
                             fu.joinPath(fu.pathOfSettingsDirectory, _backUpDirectory, newFileName))
            if isReturn:
                return newFileName
        except: pass
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:Settings.py

示例3: checkSettings

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def checkSettings():
    if fu.isDir(fu.pathOfSettingsDirectory) is False:
        fu.makeDirs(fu.pathOfSettingsDirectory)
        reFillSettings()
        reFillDatabases()
    else:
        if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite")) is False:
            reFillDatabases()
        if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, uni.fileOfSettings)) is False:
            reFillSettings()
        checkDatabases()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:13,代码来源:Settings.py

示例4: installKDE4Language

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def installKDE4Language(_language="tr_TR"):
    if uni.isAvailableKDE4():
        KDELocalateDir = fu.joinPath(uni.getKDE4HomePath(), "share", "locale", str(_language[:2]), "LC_MESSAGES")
        if uni.isRunningAsRoot():
            KDELocalateDir = fu.joinPath("/usr", "share", "locale", str(_language[:2]), "LC_MESSAGES")
        KDELocalateDir = str(KDELocalateDir)
        langFile = fu.joinPath(fu.HamsiManagerDirectory, "Languages", "DontTranslate", str(_language),
                               "HamsiManager.mo")
        if fu.isFile(fu.joinPath(KDELocalateDir, "HamsiManager.mo")) is False:
            if fu.isFile(langFile):
                if fu.isDir(KDELocalateDir) is False:
                    fu.makeDirs(KDELocalateDir)
                fu.copyFileOrDir(langFile, fu.joinPath(KDELocalateDir, "HamsiManager.mo"))
        return True
    return False
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:17,代码来源:MyConfigure.py

示例5: getReadOnlyPID

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def getReadOnlyPID():
    global isReadOnlyStarted
    if fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/mysqld.pid"):
        isReadOnlyStarted = True
        return fu.readFromFile(fu.pathOfSettingsDirectory + "/Amarok/mysqld.pid").split("\n")[0]
    isReadOnlyStarted = False
    return None
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:9,代码来源:__init__.py

示例6: getPID

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def getPID():
    global isStarted
    if fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid"):
        isStarted = True
        return fu.readFromFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid").split("\n")[0]
    isStarted = False
    return None
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:9,代码来源:__init__.py

示例7: setSourceToSearch

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(pathToSearch, -1, "return", "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:Searcher.py

示例8: addImage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
 def addImage(self):
     try:
         if self.isActiveAddImage is False:
             self.isActiveAddImage = True
             self.pbtnAddImage.setText(translate("MusicDetails", "OK"))
             self.pbtnSelectImage.show()
             self.leImagePath.show()
             self.lblImagePath.show()
             self.lblImageType.show()
             self.cbImageType.show()
             self.pbtnCancelAddImage.show()
             self.pbtnDeleteImage.hide()
             self.pbtnSaveAsImage.hide()
         else:
             if fu.isFile(self.leImagePath.text()):
                 imageType = Taggers.getTagger().getImageTypesNo()[self.cbImageType.currentIndex()]
                 description = str(imageType)
                 Musics.writeMusicFile(self.musicValues, None, True, imageType, str(self.leImagePath.text()),
                                       description)
                 self.changeFile(self.musicFile)
                 self.cancelAddImage()
             else:
                 Dialogs.showError(translate("MusicDetails", "Image Does Not Exist"),
                                   str(translate("MusicDetails", "\"%s\" does not exist.")
                                   ) % Organizer.getLink(str(self.leImagePath.text())))
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:29,代码来源:MusicDetails.py

示例9: restoreBackUp

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def restoreBackUp(_settingType="All", _isMakeBackUp=True):
    files = []
    isSuccessfully = True
    if _settingType == "database" or _settingType == "All":
        files.append("database.sqlite")
    if _settingType == "Settings" or _settingType == "All":
        files.append(uni.fileOfSettings)
    for backupFile in files:
        oldInfo = ""
        if _isMakeBackUp:
            oldInfo = fu.readFromFile(fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
        else:
            try:
                fu.removeFile(fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
            except: pass
        try:
            if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile)):
                fu.moveFileOrDir(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile),
                                 fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
            else:
                isSuccessfully = False
        except: pass
        if _isMakeBackUp:
            fu.writeToFile(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile), oldInfo)
    return isSuccessfully
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:27,代码来源:Settings.py

示例10: checkSize

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def checkSize():
    setRecordType(1)
    if fu.isFile(fu.recordFilePath):
        if fu.getSize(fu.recordFilePath) > (int(uni.MySettings["maxRecordFileSize"]) * 1024):
            fu.moveFileOrDir(fu.recordFilePath,
                             fu.joinPath(fu.oldRecordsDirectoryPath, str(time.strftime("%Y%m%d_%H%M%S")) + ".txt"))
    restoreRecordType()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:9,代码来源:Records.py

示例11: uninstallPlugin

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
 def uninstallPlugin(self, _pluginName, _isQuiet=False):
     isUninstalled = False
     pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
                               ["pluginName", "pluginFiles", "pluginDirectory", "uninstallThisPlugin",
                                "setupDirectory", "pluginVersion"], 0)
     if pluginModule.uninstallThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             for pluginFile in pluginModule.pluginFiles:
                 if fu.isFile(fu.joinPath(pluginModule.setupDirectory, pluginFile)):
                     fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isUninstalled = True
         else:
             if fu.isDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory)):
                 fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory))
             isUninstalled = True
     else:
         isUninstalled = pluginModule.uninstallThisPlugin()
     if isUninstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(""))
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Uninstallation Is Complete"),
                          str(translate("MyPlugins", "\"%s\" is uninstalled on your system.")) % (
                              pluginModule.pluginName))
     elif isUninstalled == "AlreadyUninstalled":
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Already Uninstalled"),
                          str(translate("MyPlugins", "\"%s\" already uninstalled on your system.")) % (
                              pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(translate("MyPlugins", "Plug-in Uninstallation Failed"),
                               str(translate("MyPlugins", "\"%s\" failed to uninstall on your system.")) % (
                                   pluginModule.pluginName))
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:35,代码来源:__init__.py

示例12: checkMysqldSafe

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def checkMysqldSafe(_isAskIfNotFound=True):
    from Core import Dialogs

    if fu.isFile(MySettings["pathOfMysqldSafe"]) is False and fu.isFile(
            "/usr/bin/" + MySettings["pathOfMysqldSafe"]) is False:
        if _isAskIfNotFound:
            answer = Dialogs.ask(translate("EmbeddedDBCore", "\"mysqld_safe\" Not Found"),
                                 translate("EmbeddedDBCore",
                                           "Executable \"mysqld_safe\" file is not found. Are you want to set path of this file?<br><b>Note :</b> \"mysql-common\" must be installed on your system."))
            if answer == Dialogs.Yes:
                from Options import OptionsForm

                OptionsForm.OptionsForm(getMainWindow(), _focusTo="pathOfMysqldSafe")
        else:
            return False
    else:
        return True
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:19,代码来源:Universals.py

示例13: reConfigure

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
 def reConfigure(self):
     try:
         oldPathOfExecutableHamsi = Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
             if fu.isWritableFileOrDir(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
                 MyConfigure.reConfigureFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop"))
         if self.isCreateDesktopShortcut is not None:
             if self.isCreateDesktopShortcut.checkState() == Mt.Checked:
                 desktopPath = uni.getUserDesktopPath()
                 if uni.isWindows:
                     MyConfigure.createShortCutFile(fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                 else:
                     fileContent = MyConfigure.getConfiguredDesktopFileContent()
                     fu.writeToFile(fu.joinPath(desktopPath, "HamsiManager.desktop"), fileContent)
         if uni.isRunningAsRoot():
             executableLink = str(self.leExecutableLink.text())
             if self.isCreateExecutableLink is not None:
                 if self.isCreateExecutableLink.checkState() == Mt.Checked:
                     if executableLink.strip() != "":
                         HamsiManagerFileName = Execute.findExecutableBaseName("HamsiManager")
                         if fu.isFile(executableLink):
                             fu.removeFileOrDir(executableLink)
                         fu.createSymLink(fu.joinPath(fu.HamsiManagerDirectory, HamsiManagerFileName),
                                          executableLink)
                         Settings.setUniversalSetting("HamsiManagerExecutableLinkPath", executableLink)
                         if oldPathOfExecutableHamsi != executableLink:
                             if fu.isFile(oldPathOfExecutableHamsi):
                                 answer = Dialogs.ask(translate("Reconfigure", "Other Hamsi Manager Was Detected"),
                                                      str(translate("Reconfigure",
                                                                    "Other Hamsi Manager executable file was detected. Are you want to delete old executable file? You can delete this old executable file : \"%s\"")) % (
                                                          oldPathOfExecutableHamsi))
                                 if answer != Dialogs.Yes:
                                     fu.removeFile(oldPathOfExecutableHamsi)
                     if fu.isDir("/usr/share/applications/"):
                         fileContent = MyConfigure.getConfiguredDesktopFileContent()
                         fu.writeToFile("/usr/share/applications/HamsiManager.desktop", fileContent)
         if uni.isRunningAsRoot() is False:
             if fu.isDir(fu.joinPath(fu.userDirectoryPath, ".local", "applications")) is False:
                 fu.makeDirs(fu.joinPath(fu.userDirectoryPath, ".local", "applications"))
             fileContent = MyConfigure.getConfiguredDesktopFileContent()
             fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
                            fileContent)
         MyConfigure.installKDE4Languages()
         self.isInstallFinished = True
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:48,代码来源:Configurator.py

示例14: getPythonPath

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def getPythonPath():
    """Use this only if runnig .py(.py3,.pyw)"""
    try: pathOfPython = uni.trDecode(sys.executable, fu.fileSystemEncoding)
    except: pathOfPython = sys.executable
    if uni.isWindows:
        pathOfPythonWindows = pathOfPython.replace("python.exe", "pythonw.exe")
        if fu.isFile(pathOfPythonWindows):
            pathOfPython = pathOfPythonWindows
    return pathOfPython
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:11,代码来源:Execute.py

示例15: isRunableAsRoot

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isFile [as 别名]
def isRunableAsRoot():
    try:
        if fu.isFile(fu.joinPath(getLibraryDirectoryPath(), "kde4", "libexec", "kdesu")):
            if isRunningAsRoot():
                return False
            return True
        return False
    except:
        return False
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:11,代码来源:Universals.py


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