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


Python FileUtils.removeFile方法代码示例

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


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

示例1: restoreBackUp

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import removeFile [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

示例2: makeBackUp

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import removeFile [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: delete

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import removeFile [as 别名]
 def delete(self):
     try:
         answer = Dialogs.ask(translate("ScriptManager", "Your Script Will Be Deleted!.."),
                              translate("ScriptManager",
                                        "Your script will be deleted. Are you sure you want to delete current script?"))
         if answer == Dialogs.Yes:
             fu.removeFile(fu.joinPath(Scripts.pathOfScripsDirectory, self.currentScriptFileName))
             self.refreshScriptList()
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:12,代码来源:ScriptManager.py

示例4: reConfigure

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import removeFile [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

示例5: updateOldSettings

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import removeFile [as 别名]
def updateOldSettings(_oldVersion, _newVersion):
    newSettingsKeys, changedDefaultValuesKeys = [], []
    try:
        oldVersion = int(_oldVersion)
    except:
        oldVersion = _newVersion
    if oldVersion < 1000:
        reFillAll(True)
        return newSettingsKeys, changedDefaultValuesKeys
    if oldVersion < 1081:
        newSettingsKeys = newSettingsKeys + ["isCheckUnSavedValues"]
    if oldVersion < 1082:
        con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
        cur = con.cursor()
        cur.execute(str("ALTER TABLE searchAndReplaceTable RENAME TO tmpSearchAndReplaceTable;"))
        cur.execute(str(
            "CREATE TABLE searchAndReplaceTable ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'label' TEXT,'searching' TEXT,'replacing' TEXT,'intIsActive' INTEGER,'intIsCaseSensitive' INTEGER,'intIsRegExp' INTEGER);"))
        cur.execute(str(
            "INSERT INTO searchAndReplaceTable(label,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp) SELECT searching,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp FROM tmpSearchAndReplaceTable;"))
        cur.execute(str("DROP TABLE tmpSearchAndReplaceTable;"))
        con.commit()
        newSettingsKeys += ["isCorrectValueWithSearchAndReplaceTable"]
    if oldVersion < 1170:
        newSettingsKeys += ["maxDeletedDirectorySize"]
    if oldVersion < 1190:
        changedDefaultValuesKeys += ["applicationStyle", "fileExtensionIs"]
    if oldVersion < 1371:
        changedDefaultValuesKeys += ["fileExtensionIs"]
    if oldVersion < 1372:
        changedDefaultValuesKeys += ["packagerUnneededDirectories", "cleanerUnneededDirectories"]
    if oldVersion < 1373:
        uni.MySettings["AmarokTagSourceTypeAmarokMusicTable"] = "Amarok (Smart)"
        uni.MySettings["AmarokTagSourceTypeAmarokCopyTable"] = "Amarok (Smart)"
    if oldVersion < 1374:
        con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
        cur = con.cursor()
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'File/Directory Name', 'baseName');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Directory Name', 'baseName');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Directory', 'baseNameOfDirectory');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Album Artist', 'albumArtist');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'File Name', 'baseName');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Artist', 'artist');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Title', 'title');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Album', 'album');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Track No', 'trackNum');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Year', 'year');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Genre', 'genre');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Comment', 'firstComment');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Lyrics', 'firstLyrics');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Current Cover', 'currentCover');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Source Cover', 'sourceCover');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Destination Cover', 'destinationCover');")
        cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'albumartist', 'albumArtist');")
        con.commit()
    if oldVersion < 1375:
        con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
        cur = con.cursor()
        cur.execute(
            "DELETE FROM completerTable WHERE id NOT IN (SELECT MAX(id) FROM completerTable GROUP BY value,objectName);")
        cur.execute(
            "DELETE FROM bookmarksOfSpecialTools WHERE id NOT IN (SELECT MAX(id) FROM bookmarksOfSpecialTools GROUP BY value,type);")
        cur.execute(
            "DELETE FROM bookmarksOfDirectories WHERE id NOT IN (SELECT MAX(id) FROM bookmarksOfDirectories GROUP BY value,type,bookmark);")
        cur.execute(
            "DELETE FROM searchAndReplaceTable WHERE id NOT IN (SELECT MAX(id) FROM searchAndReplaceTable GROUP BY label,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp);")
        con.commit()
    if oldVersion < 1951:
        try:
            del uni.MySettings["eyeD3TaggerTypeNameForRead"]
            del uni.MySettings["eyeD3TaggerTypeNameForWrite"]
        except:
            pass
        setting().remove("eyeD3TaggerTypeNameForRead")
        setting().remove("eyeD3TaggerTypeNameForWrite")
        setting().sync()
    if oldVersion < 1952:
        changedDefaultValuesKeys += ["musicExtensions"]
    if oldVersion < 2006:
        try:
            del uni.MySettings["eyed3TaggerTypeNameForRead"]
            del uni.MySettings["eyed3TaggerTypeNameForWrite"]
        except:
            pass
        try:
            setting().remove("eyed3TaggerTypeNameForRead")
            setting().remove("eyed3TaggerTypeNameForWrite")
            setting().sync()
        except:
            pass
    if oldVersion < 2007:
        newSettingsKeys += ["preferedTaggerModule"]
    if oldVersion < 2008:
        for f in fu.readDirectory(fu.joinPath(fu.HamsiManagerDirectory, "Taggers"), "file"):
            if f.find("NewEyeD3Tagger") > -1:
                fu.removeFile(fu.joinPath(fu.HamsiManagerDirectory, "Taggers", f))
    return newSettingsKeys, changedDefaultValuesKeys
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:98,代码来源:Settings.py


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