本文整理汇总了Python中FileUtils.makeDirs方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.makeDirs方法的具体用法?Python FileUtils.makeDirs怎么用?Python FileUtils.makeDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.makeDirs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeBackUp
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [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
示例2: checkSettings
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [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()
示例3: installKDE4Language
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [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
示例4: reConfigure
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [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()
示例5: installPlugin
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [as 别名]
def installPlugin(self, _pluginName, _isQuiet=False):
isInstalled = False
pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
["pluginName", "pluginFiles", "pluginDirectory", "installThisPlugin",
"setupDirectory", "pluginVersion"], 0)
if pluginModule.installThisPlugin is None:
if pluginModule.pluginDirectory == "":
try: fu.makeDirs(pluginModule.setupDirectory)
except: pass
for pluginFile in pluginModule.pluginFiles:
fu.copyOrChange(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginFile),
fu.joinPath(pluginModule.setupDirectory, pluginFile), "file", "only", True)
MyConfigure.reConfigureFile(fu.joinPath(pluginModule.setupDirectory, pluginFile))
isInstalled = True
else:
oldFilePath = fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName,
pluginModule.pluginDirectory)
newFilePath = fu.copyOrChange(oldFilePath,
fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory),
"directory", "only", True)
if newFilePath != oldFilePath:
isInstalled = True
else:
isInstalled = pluginModule.installThisPlugin()
if isInstalled:
Settings.setUniversalSetting(str(pluginModule.pluginName), str(pluginModule.pluginVersion))
if _isQuiet is False:
Dialogs.show(translate("MyPlugins", "Plug-in Installation Is Complete"),
str(translate("MyPlugins", "\"%s\" is installed on your system.")) % (
pluginModule.pluginName))
elif isInstalled == "AlreadyInstalled":
if _isQuiet is False:
Dialogs.show(translate("MyPlugins", "Plug-in Already Installed"),
str(translate("MyPlugins", "\"%s\" already installed on your system.")) % (
pluginModule.pluginName))
else:
if _isQuiet is False:
Dialogs.showError(translate("MyPlugins", "Plug-in Installation Failed"),
str(translate("MyPlugins", "\"%s\" failed to install on your system.")) % (
pluginModule.pluginName))
示例6: finish
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [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()
示例7: createReadOnlyEmbeddedDB
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [as 别名]
def createReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True):
stopReadOnlyEmbeddedDB()
if fu.isDir(fu.pathOfSettingsDirectory + "/Amarok"):
fu.removeFileOrDir(fu.pathOfSettingsDirectory + "/Amarok")
fu.makeDirs(fu.pathOfSettingsDirectory + "/Amarok/mysqle")
fu.copyFileOrDir(fu.HamsiManagerDirectory + "/Amarok/EmbeddedDBFiles/mysql",
fu.pathOfSettingsDirectory + "/Amarok/mysqle/mysql", )
fu.copyFileOrDir(fu.HamsiManagerDirectory + "/Amarok/EmbeddedDBFiles/my-readOnly.cnf",
fu.pathOfSettingsDirectory + "/Amarok/my.cnf")
MyConfigure.reConfigureFile(fu.pathOfSettingsDirectory + "/Amarok/my.cnf")
fu.makeDirs(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok")
fu.copyFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/ib_logfile0",
fu.pathOfSettingsDirectory + "/Amarok/mysqle/ib_logfile0")
fu.copyFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/ib_logfile1",
fu.pathOfSettingsDirectory + "/Amarok/mysqle/ib_logfile1")
fu.copyFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/ibdata1",
fu.pathOfSettingsDirectory + "/Amarok/mysqle/ibdata1")
generateReadOnlyEmbeddedD()
if _isNoAlertIfSuccessfully is False:
Dialogs.show(translate("EmbeddedDBCore", "Created Embedded Server"),
translate("EmbeddedDBCore", "Embedded Amarok database server created and generated."))
return True
示例8: install
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import makeDirs [as 别名]
def install(self):
try:
MApplication.processEvents()
self.installationDirectory = str(self.leInstallationDirectory.text())
if len(self.installationDirectory) > 0:
if self.installationDirectory[-1] == fu.sep:
self.installationDirectory = self.installationDirectory[:-1]
if self.installationDirectory == fu.HamsiManagerDirectory:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path is Hamsi Manager source directory.<br>Please choose a valid installation path."))
elif fu.isFile(self.installationDirectory) is False:
isMakeInstall = True
if fu.isDir(self.installationDirectory) is False:
self.lblActions.setText(translate("Install", "Creating Installation Folder..."))
fu.makeDirs(self.installationDirectory)
elif len(fu.listDir(self.installationDirectory)) > 0:
currenctAnswer = Dialogs.askSpecial(
translate("Install", "The Installation Path You Selected Is Not Empty."),
translate("Install",
"If the path you selected is an \"Hamsi Manager\" installation path, <b>I recommend you to delete the older files.</b><br>Do you want me to clear the installation path/folder for you?<br><b>Note: </b> Your personal settings are <b>never deleted</b>."),
translate("Install", "Yes (Recommended)"),
translate("Install", "No (Overwrite)"),
translate("Install", "Cancel"))
if currenctAnswer == translate("Install", "Yes (Recommended)"):
self.lblActions.setText(translate("Install", "Clearing Installation Path..."))
try:fu.removeFileOrDir(self.installationDirectory)
except:pass
fu.makeDirs(self.installationDirectory)
isMakeInstall = True
elif currenctAnswer == translate("Install", "No (Overwrite)"):
isMakeInstall = True
else:
isMakeInstall = False
if isMakeInstall:
Settings.setUniversalSetting("pathOfInstallationDirectory", self.installationDirectory)
directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
self.prgbState.setRange(0, len(directoriesAndFiles))
self.lblActions.setText(translate("Install", "Copying Files And Folders..."))
installFileName = Execute.findExecutableBaseName("HamsiManagerInstaller")
for fileNo, fileName in enumerate(directoriesAndFiles):
MApplication.processEvents()
newFileName = self.installationDirectory + fileName.replace(fu.HamsiManagerDirectory,"")
if fu.isDir(fileName) and fileName.find(".svn") == -1:
try: fu.makeDirs(newFileName)
except: pass
elif (fu.isFile(fileName) and fu.getBaseName(fileName) != "install.py" and
fu.getBaseName(fileName) != installFileName and fileName.find(".svn") == -1):
try:
fu.copyFileOrDir(fileName, newFileName)
except:
fileContent = fu.readFromBinaryFile(fileName)
fu.writeToBinaryFile(newFileName, fileContent)
self.prgbState.setValue(fileNo + 1)
self.pageNo += 1
MyConfigure.installKDE4Languages()
else:
self.pageNo -= 1
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
self.pageChanged(True)
except:
from Core import ReportBug
ReportBug.ReportBug()