本文整理汇总了Python中FileUtils.copyFileOrDir方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.copyFileOrDir方法的具体用法?Python FileUtils.copyFileOrDir怎么用?Python FileUtils.copyFileOrDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.copyFileOrDir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeBackUp
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [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: generateReadOnlyEmbeddedD
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [as 别名]
def generateReadOnlyEmbeddedD(_isNoAlertIfSuccessfully=True):
stopReadOnlyEmbeddedDB()
if fu.isExist(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok"):
fu.removeFileOrDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok")
fu.copyFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/amarok",
fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok")
if _isNoAlertIfSuccessfully is False:
Dialogs.show(translate("EmbeddedDBCore", "Generated Embedded Server"),
translate("EmbeddedDBCore", "Embedded Amarok database server generated."))
return True
示例3: configureEmbeddedDB
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [as 别名]
def configureEmbeddedDB(_isNoAlertIfSuccessfully=True):
stopEmbeddedDB()
backupEmbeddedDB()
fu.copyDirContent(fu.HamsiManagerDirectory + "/Amarok/EmbeddedDBFiles/mysql",
uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysql")
fu.copyFileOrDir(fu.HamsiManagerDirectory + "/Amarok/EmbeddedDBFiles/my.cnf",
uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf")
MyConfigure.reConfigureFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf")
if _isNoAlertIfSuccessfully is False:
Dialogs.show(translate("EmbeddedDBCore", "Created Embedded Server"),
translate("EmbeddedDBCore", "Embedded Amarok database server created and generated."))
return True
示例4: installKDE4Language
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [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
示例5: createReadOnlyEmbeddedDB
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [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
示例6: install
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [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()
示例7: backupEmbeddedDB
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import copyFileOrDir [as 别名]
def backupEmbeddedDB():
if fu.isDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle_backup_for_hamsi"):
fu.removeFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle_backup_for_hamsi")
fu.copyFileOrDir(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle",
uni.getKDE4HomePath() + "/share/apps/amarok/mysqle_backup_for_hamsi")