本文整理汇总了Python中FileUtils.isDir方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.isDir方法的具体用法?Python FileUtils.isDir怎么用?Python FileUtils.isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.isDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkEmbeddedDB
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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()
示例2: emendDirectoryWithContents
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def emendDirectoryWithContents(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if uni.getBoolValue("isShowQuickMakeWindow"):
newEmendedName = str(self.leNewValue.text())
else:
newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
fu.activateSmartCheckIcon()
oldFileName = _path
newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
if newDirName != oldFileName:
fileAndDirectoryNames = fu.readDirectory(newDirName, "fileAndDirectory")
for fileAndDirs in fileAndDirectoryNames:
objectType = fu.getObjectType(fu.joinPath(newDirName, fileAndDirs))
fu.moveOrChange(fu.joinPath(newDirName, fileAndDirs),
fu.joinPath(newDirName, Organizer.emend(fileAndDirs, objectType)), objectType)
if uni.isActiveDirectoryCover and uni.getBoolValue(
"isActiveAutoMakeIconToDirectory") and uni.getBoolValue(
"isAutoMakeIconToDirectoryWhenFileMove"):
fu.checkIcon(newDirName)
if fu.isDir(newDirName):
fu.completeSmartCheckIcon()
Dialogs.show(translate("QuickMake", "Directory And Contents Emended"),
str(translate("QuickMake",
"\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
(Organizer.getLink(_path), Organizer.getLink(newDirName)))
self.close()
except:
ReportBug.ReportBug()
示例3: uninstallPlugin
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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))
示例4: makeBackUp
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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
示例5: uninstall
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def uninstall(self):
try:
MApplication.processEvents()
self.UninstallationDirectory = str(self.leUninstallationDirectory.text())
if len(self.UninstallationDirectory) > 0:
if self.UninstallationDirectory[-1] == fu.sep:
self.UninstallationDirectory = self.UninstallationDirectory[:-1]
if self.UninstallationDirectory == fu.HamsiManagerDirectory:
self.pageNo -= 1
Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
translate("Uninstall",
"The selected path is Hamsi Manager source directory.<br>Please choose a valid uninstallation path."))
elif fu.isDir(self.UninstallationDirectory):
fu.removeFileOrDir(self.UninstallationDirectory)
else:
self.pageNo -= 1
Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
translate("Uninstall",
"The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."))
else:
self.pageNo -= 1
Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
translate("Uninstall",
"The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."))
self.pageChanged(True)
except:
from Core import ReportBug
ReportBug.ReportBug()
示例6: setSourceToSearch
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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()
示例7: reConfigure
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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()
示例8: getMyPluginsNames
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def getMyPluginsNames():
plugins = []
for name in fu.readDirectoryAll(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins")):
try:
if (name[:1] != "." and name[:2] != "__" and name[-2:] != "__" and
fu.isDir(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", name))):
plugins.append(name)
except: pass
return plugins
示例9: getInstalledThemes
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def getInstalledThemes():
themes = []
for name in fu.readDirectoryAll(fu.joinPath(fu.HamsiManagerDirectory, "Themes")):
try:
if (name[:1] != "." and name[:2] != "__" and name[-2:] != "__" and
fu.isDir(fu.joinPath(fu.HamsiManagerDirectory, "Themes", name))):
themes.append(name)
except: pass
return themes
示例10: __init__
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
try:
if uni.getBoolValue("isForceOpenWithDefaultApplication"):
_path = fu.checkSource(_filePath)
Execute.openWith([_path])
else:
_path = fu.checkSource(_filePath, "file", False)
if _path is not None:
isOpened = False
mtype = fu.getMimeType(_path)
if mtype[0] is not None:
if mtype[0].split("/")[0] == "text":
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
elif mtype[0].split("/")[0] == "audio":
if Taggers.getTagger(True) is not None:
MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
elif mtype[0].split("/")[0] == "image":
ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
isOpened = True
elif fu.isBinary(_path) is False:
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
else:
if fu.isBinary(_path) is False:
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
if isOpened is False:
if uni.getBoolValue("isOpenWithDefaultApplication"):
Execute.openWith([_path])
else:
Dialogs.showError(translate("Details", "File Is Not Supported"),
str(translate("Details",
"\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
str(_path)))
elif fu.isDir(_filePath):
if uni.getBoolValue("isOpenWithDefaultApplication"):
Execute.openWith([_filePath])
else:
Dialogs.showError(translate("Details", "Directories Is Not Supported"),
str(translate("Details",
"\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
str(_filePath)))
else:
Dialogs.showError(translate("Details", "File Is Not Exist"),
str(translate("Details",
"\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
str(_filePath)))
except:
answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
str(translate("Details",
"\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
str(_filePath)),
translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
if answer == translate("QuickMake", "Report This Bug"):
ReportBug.ReportBug()
示例11: checkSettings
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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()
示例12: setMyCurrentIndexByTree
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def setMyCurrentIndexByTree(self, _index):
try:
while 1 == 1:
selected = str(self.getPathOfIndexByTree(_index))
if fu.isDir(selected) or fu.isFile(selected):
self.makeRefreshOnlyFileListByTree(_index)
break
else:
_index = _index.parent()
self.goTo(self.getPathOfIndexByTree(_index))
except:
ReportBug.ReportBug()
示例13: finish
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def finish(self):
try:
if fu.isFile(fu.joinPath(self.installationDirectory, "HamsiManager.desktop")):
MyConfigure.reConfigureFile(fu.joinPath(self.installationDirectory, "HamsiManager.desktop"),
self.installationDirectory)
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"),
self.installationDirectory)
else:
fileContent = MyConfigure.getConfiguredDesktopFileContent(self.installationDirectory)
fu.writeToFile(fu.joinPath(desktopPath, "HamsiManager.desktop"), fileContent)
if self.isCreateExecutableLink is not None:
executableLink = str(self.leExecutableLink.text())
if self.isCreateExecutableLink.checkState() == Mt.Checked:
if executableLink.strip() != "":
executableLink = fu.checkNewDestination(executableLink)
if executableLink:
HamsiManagerFileName = Execute.findExecutableBaseName("HamsiManager")
fu.createSymLink(fu.joinPath(self.installationDirectory, HamsiManagerFileName),
executableLink)
Settings.setUniversalSetting("HamsiManagerExecutableLinkPath", executableLink)
if fu.isDir("/usr/share/applications/"):
fileContent = MyConfigure.getConfiguredDesktopFileContent(self.installationDirectory)
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(self.installationDirectory)
fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
fileContent)
self.isInstallFinished = True
self.close()
except:
from Core import ReportBug
ReportBug.ReportBug()
示例14: installKDE4Language
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [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
示例15: clearEmptyDirectories
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import isDir [as 别名]
def clearEmptyDirectories(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if fu.isWritableFileOrDir(_path):
fu.activateSmartCheckIcon()
fu.checkEmptyDirectories(_path, True, True, True, True)
if fu.isDir(_path):
fu.completeSmartCheckIcon()
Dialogs.show(translate("QuickMake", "Directory Cleaned"),
str(translate("QuickMake",
"\"%s\" is cleaned based on the criteria you set.")) % Organizer.getLink(
_path))
self.close()
except:
ReportBug.ReportBug()