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


Python FileUtils.copyFileOrDir方法代码示例

本文整理汇总了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
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:Settings.py

示例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
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:12,代码来源:__init__.py

示例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
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:14,代码来源:__init__.py

示例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
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:17,代码来源:MyConfigure.py

示例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
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:24,代码来源:__init__.py

示例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()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:79,代码来源:install.py

示例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")
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:7,代码来源:__init__.py


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