Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
def readMusicFile(_filePath, _isAlertWhenNotAvailable=True):
    _directoryPath = fu.getDirName(_filePath)
    isCanNoncompatible = False
    if fu.isReadableFileOrDir(_filePath):
        tagger = Taggers.getTagger()
        try:
            tagger.loadFile(_filePath)
        except:
            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                              str(translate("FileUtils/Musics",
                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                              ) % Organizer.getLink(_filePath))
        if tagger.isAvailableFile() is False:
            isCanNoncompatible = True
        content = {}
        content["path"] = _filePath
        content["baseNameOfDirectory"] = fu.getBaseName(_directoryPath)
        content["baseName"] = fu.getBaseName(_filePath)
        content["artist"] = tagger.getArtist()
        content["title"] = tagger.getTitle()
        content["album"] = tagger.getAlbum()
        content["albumArtist"] = tagger.getAlbumArtist()
        content["trackNum"] = tagger.getTrackNum()
        content["year"] = tagger.getYear()
        content["genre"] = tagger.getGenre()
        content["firstComment"] = tagger.getFirstComment()
        content["firstLyrics"] = tagger.getFirstLyrics()
        content["images"] = tagger.getImages()
        if isCanNoncompatible and _isAlertWhenNotAvailable:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
        return content
Exemplo n.º 3
0
 def addImage(self):
     try:
         if self.isActiveAddImage is False:
             self.isActiveAddImage = True
             self.pbtnAddImage.setText(translate("MusicDetails", "OK"))
             self.pbtnSelectImage.show()
             self.leImagePath.show()
             self.lblImagePath.show()
             self.lblImageType.show()
             self.cbImageType.show()
             self.pbtnCancelAddImage.show()
             self.pbtnDeleteImage.hide()
             self.pbtnSaveAsImage.hide()
         else:
             if fu.isFile(self.leImagePath.text()):
                 imageType = Taggers.getTagger().getImageTypesNo()[self.cbImageType.currentIndex()]
                 description = str(imageType)
                 Musics.writeMusicFile(self.musicValues, None, True, imageType, str(self.leImagePath.text()),
                                       description)
                 self.changeFile(self.musicFile)
                 self.cancelAddImage()
             else:
                 Dialogs.showError(translate("MusicDetails", "Image Does Not Exist"),
                                   str(translate("MusicDetails", "\"%s\" does not exist.")
                                   ) % Organizer.getLink(str(self.leImagePath.text())))
     except:
         ReportBug.ReportBug()
Exemplo n.º 4
0
    def save(self):
        try:
            filePath = str(self.leFilePath.text())
            if self.fileValues is not None:
                from Core import Records

                Records.setTitle(translate("TextCorrector", "Text File"))
                newFileValues = {}
                newFileValues["path"] = filePath
                newFileValues["content"] = str(
                    self.pteFileContent.toPlainText())
                newPath = fu.writeTextFile(self.fileValues, newFileValues,
                                           str(self.charSet.currentText()))
                if newPath != self.fileValues["path"]:
                    self.changeFile(newPath)
                if hasattr(getMainWindow(), "FileManager") and getMainWindow(
                ).FileManager is not None:
                    getMainWindow().FileManager.makeRefresh()
                Records.saveAllRecords()
            else:
                Dialogs.showError(
                    translate("TextCorrector", "File Does Not Exist"),
                    str(
                        translate(
                            "TextDetails",
                            "\"%s\" does not exist.<br>Please select an exist file and try again."
                        )) % Organizer.getLink(str(filePath)))
        except:
            ReportBug.ReportBug()
Exemplo n.º 5
0
 def addImage(self):
     try:
         if self.isActiveAddImage is False:
             self.isActiveAddImage = True
             self.pbtnAddImage.setText(translate("MusicDetails", "OK"))
             self.pbtnSelectImage.show()
             self.leImagePath.show()
             self.lblImagePath.show()
             self.lblImageType.show()
             self.cbImageType.show()
             self.pbtnCancelAddImage.show()
             self.pbtnDeleteImage.hide()
             self.pbtnSaveAsImage.hide()
         else:
             if fu.isFile(self.leImagePath.text()):
                 imageType = Taggers.getTagger().getImageTypesNo()[
                     self.cbImageType.currentIndex()]
                 description = str(imageType)
                 Musics.writeMusicFile(self.musicValues, None, True,
                                       imageType,
                                       str(self.leImagePath.text()),
                                       description)
                 self.changeFile(self.musicFile)
                 self.cancelAddImage()
             else:
                 Dialogs.showError(
                     translate("MusicDetails", "Image Does Not Exist"),
                     str(translate("MusicDetails",
                                   "\"%s\" does not exist.")) %
                     Organizer.getLink(str(self.leImagePath.text())))
     except:
         ReportBug.ReportBug()
Exemplo n.º 6
0
 def triggered(self, _action):
     try:
         if _action.objectName() == "Edit Bookmarks":
             getMainWindow().FileManager.bookmarks.makeRefresh()
             getMainWindow().FileManager.bookmarks.show()
             return
         for info in BookmarksOfDirectories.fetchAll():
             if info[1] == str(_action.objectName()):
                 if fu.isDir(str(info[2])):
                     getMainWindow().FileManager.goTo(str(info[2]))
                     return
                 else:
                     answer = Dialogs.ask(
                         translate("BookmarksMenu", "Cannot Find Folder"),
                         str(
                             translate(
                                 "BookmarksMenu",
                                 "\"%s\" cannot be found.<br>Delete this folder from the bookmarks?"
                             )) % Organizer.getLink(info[1]))
                     if answer == Dialogs.Yes:
                         BookmarksOfDirectories.delete(str(info[0]))
                         self.makeRefresh()
                         getMainWindow().FileManager.bookmarks.makeRefresh()
         getMainWindow().FileManager.makeRefreshOnlyFileList()
         getMainWindow().FileManager.makeRefreshOnlyFileListByTree()
     except:
         ReportBug.ReportBug()
Exemplo n.º 7
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     global currentDialogs
     _filePath = fu.checkSource(_filePath, "file")
     if _filePath is not None:
         if _isOpenDetailsOnNewWindow is False:
             isHasOpenedDialog = False
             for dialog in currentDialogs:
                 if dialog.isVisible():
                     isHasOpenedDialog = True
                     dialog.changeFile(_filePath)
                     dialog.activateWindow()
                     dialog.raise_()
                     break
             if isHasOpenedDialog is False:
                 _isOpenDetailsOnNewWindow = True
         if _isOpenDetailsOnNewWindow:
             currentDialogs.append(self)
             MDialog.__init__(self, MApplication.activeWindow())
             if isActivePyKDE4:
                 self.setButtons(MDialog.NoDefault)
             self.charSet = MComboBox()
             self.charSet.addItems(uni.getCharSets())
             self.charSet.setCurrentIndex(self.charSet.findText(uni.MySettings["fileSystemEncoding"]))
             self.infoLabels = {}
             self.infoValues = {}
             self.fileValues = {}
             pbtnClose = MPushButton(translate("TextDetails", "Close"))
             pbtnSave = MPushButton(translate("TextDetails", "Save Changes"))
             pbtnSave.setIcon(MIcon("Images:save.png"))
             MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
             MObject.connect(pbtnSave, SIGNAL("clicked()"), self.save)
             self.labels = [translate("TextDetails", "File Path : "),
                            translate("TextDetails", "Content : ")]
             self.pnlMain = MWidget()
             self.vblMain = MVBoxLayout(self.pnlMain)
             self.pnlClearable = None
             self.changeFile(_filePath, True)
             HBOXs, VBOXs = [], []
             VBOXs.append(MVBoxLayout())
             HBOXs.append(MHBoxLayout())
             HBOXs[-1].addWidget(self.charSet, 1)
             HBOXs[-1].addWidget(pbtnSave, 4)
             VBOXs[0].addLayout(HBOXs[-1])
             VBOXs[0].addWidget(pbtnClose)
             self.vblMain.addLayout(VBOXs[0], 1)
             if isActivePyKDE4:
                 self.setMainWidget(self.pnlMain)
             else:
                 self.setLayout(self.vblMain)
             self.show()
             self.setMinimumWidth(700)
             self.setMinimumHeight(500)
     else:
         Dialogs.showError(translate("TextDetails", "File Does Not Exist"),
                           str(translate("TextDetails",
                                         "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                           ) % Organizer.getLink(str(_filePath)))
         if hasattr(getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Exemplo n.º 8
0
 def cellDoubleClickedTable(self, _row, _column):
     try:
         if uni.getBoolValue("isRunOnDoubleClick"):
             self.showTableDetails(_row, _column)
     except:
         Dialogs.showError(translate("SubFolderTable", "Cannot Open File"),
                           str(translate("SubFolderTable",
                                         "\"%s\" : cannot be opened. Please make sure that you selected a text file.")
                           ) % Organizer.getLink(self.values[_row]["path"]))
Exemplo n.º 9
0
 def emendDirectory(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))
             oldFileName = _path
             newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
             if newDirName != oldFileName:
                 Dialogs.show(translate("QuickMake", "Directory 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()
Exemplo n.º 10
0
 def Clear(self):
     try:
         uni.isCanBeShowOnMainWindow = False
         answer = Dialogs.ask(translate("Cleaner", "Your Files Will Be Removed"),
                              str(translate("Cleaner",
                                            "The files in the \"%s\" folder will be cleared according to the criteria you set.<br>" +
                                            "This action will delete the files completely, without any chance to recover.<br>" +
                                            "Are you sure you want to perform the action?")) % Organizer.getLink(
                                  Organizer.getLink(str(self.lePathOfProject.text()))))
         if answer == Dialogs.Yes:
             if fu.isWritableFileOrDir(str(self.lePathOfProject.text())):
                 if fu.clearCleaningDirectory(str(self.lePathOfProject.text()), True, True):
                     Dialogs.show(translate("Cleaner", "Directory Is Cleared"),
                                  str(translate("Cleaner",
                                                "This directory is cleared : \"%s\"")) % Organizer.getLink(
                                      str(self.lePathOfProject.text())))
         uni.isCanBeShowOnMainWindow = True
     except:
         ReportBug.ReportBug()
Exemplo n.º 11
0
    def save(self):
        try:
            filePath = str(self.leFilePath.text())
            if self.fileValues is not None:
                from Core import Records

                Records.setTitle(translate("TextCorrector", "Text File"))
                newFileValues = {}
                newFileValues["path"] = filePath
                newFileValues["content"] = str(self.pteFileContent.toPlainText())
                newPath = fu.writeTextFile(self.fileValues, newFileValues, str(self.charSet.currentText()))
                if newPath != self.fileValues["path"]:
                    self.changeFile(newPath)
                if hasattr(getMainWindow(),
                           "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
                Records.saveAllRecords()
            else:
                Dialogs.showError(translate("TextCorrector", "File Does Not Exist"),
                                  str(translate("TextDetails",
                                                "\"%s\" does not exist.<br>Please select an exist file and try again.")
                                  ) % Organizer.getLink(str(filePath)))
        except:
            ReportBug.ReportBug()
Exemplo n.º 12
0
    def downloadAndInstall(self):
        try:
            if uni.isBuilt() is False:
                if fu.isWritableFileOrDir(fu.HamsiManagerDirectory,
                                          True) is False:
                    from Core import Organizer

                    Dialogs.showError(
                        translate("UpdateControl", "Access Denied"),
                        str(
                            translate(
                                "UpdateControl",
                                "\"%s\" : you do not have the necessary permissions to change this directory.<br />Please check your access controls and retry. <br />Note: You can run Hamsi Manager as root and try again."
                            )) % Organizer.getLink(fu.HamsiManagerDirectory))
            self.setFixedHeight(130)
            self.isDownloading = True
            self.prgbState.setVisible(True)
            self.lblInfo.setVisible(False)
            self.setWindowTitle(
                translate("UpdateControl", "Downloading Latest Release..."))
            self.request = MNetworkRequest(MUrl(self.updateInformations[1]))
            self.willDownload(self.request)
        except:
            ReportBug.ReportBug()
Exemplo n.º 13
0
 def triggered(self, _action):
     try:
         if _action.objectName() == "Edit Bookmarks":
             getMainWindow().FileManager.bookmarks.makeRefresh()
             getMainWindow().FileManager.bookmarks.show()
             return
         for info in BookmarksOfDirectories.fetchAll():
             if info[1] == str(_action.objectName()):
                 if fu.isDir(str(info[2])):
                     getMainWindow().FileManager.goTo(str(info[2]))
                     return
                 else:
                     answer = Dialogs.ask(translate("BookmarksMenu", "Cannot Find Folder"),
                                 str(translate("BookmarksMenu",
                                     "\"%s\" cannot be found.<br>Delete this folder from the bookmarks?")) %
                                 Organizer.getLink(info[1]))
                     if answer == Dialogs.Yes:
                         BookmarksOfDirectories.delete(str(info[0]))
                         self.makeRefresh()
                         getMainWindow().FileManager.bookmarks.makeRefresh()
         getMainWindow().FileManager.makeRefreshOnlyFileList()
         getMainWindow().FileManager.makeRefreshOnlyFileListByTree()
     except:
         ReportBug.ReportBug()
Exemplo n.º 14
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(
                translate("MenuBar", "Open State Of Hamsi Manager"),
                fu.userDirectoryPath,
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(
                translate("MenuBar", "Save State Of Hamsi Manager"),
                fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(
                    translate("MenuBar", "Current State Saved"),
                    translate(
                        "MenuBar",
                        "Current state saved with preferences.<br>You can continue where you left off."
                    ))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(
                ["--sDirectoryPath", fu.pathOfSettingsDirectory],
                    "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "html", "fileTree", "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "plainText", "fileTree",
                               "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

            OptionsForm.OptionsForm(getMainWindow())
        elif actionName == "My Plugins":
            import MyPlugins

            MyPlugins.MyPlugins()
        elif actionName == "Reconfigure":
            from Tools import Configurator

            Configurator.Configurator("configurePage")
        elif actionName == "My Plugins (System)":
            Execute.execute(["--qm", "--plugins", "--runAsRoot"],
                            "HamsiManager")
        elif actionName == "Reconfigure (System)":
            Execute.execute(["--qm", "--configurator", "--runAsRoot"],
                            "HamsiManager")
        elif actionName == "Update":
            from Core import UpdateControl

            UpdateControl.UpdateControl(getMainWindow())
        elif actionName == "Report Bug":
            ReportBug.ReportBug(True)
        elif actionName == "Suggest Idea":
            from Core import SuggestIdea

            SuggestIdea.SuggestIdea()
        elif actionName == "About Hamsi Manager":
            if isActivePyKDE4 is False:
                MMessageBox.about(getMainWindow(),
                                  translate("MenuBar", "About Hamsi Manager"),
                                  uni.aboutOfHamsiManager)
        elif actionName == translate("ToolsBar", "Check Icon"):
            getMainWindow().setEnabled(False)
            fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath())
            Dialogs.show(
                translate("ToolsBar", "Directory Icon Checked"),
                translate(
                    "ToolsBar",
                    "Current directory icon checked.<br>The default action based on the data is executed."
                ))
            getMainWindow().setEnabled(True)
        elif actionName == "Clear Empty Directories":
            if getMainTable().checkUnSavedValues() is False:
                _action.setChecked(False)
                return False
            answer = Dialogs.ask(
                translate("ToolsBar", "Empty Directories Will Be Removed"),
                str(
                    translate(
                        "ToolsBar",
                        "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?"
                    )) % Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                currentDirPath = getMainWindow(
                ).FileManager.getCurrentDirectoryPath()
                if fu.isWritableFileOrDir(currentDirPath):
                    fu.checkEmptyDirectories(currentDirPath, True, True, True,
                                             True)
                    Dialogs.show(
                        translate("ToolsBar", "Directory Cleaned"),
                        translate(
                            "ToolsBar",
                            "The current directory is cleaned based on the criteria you set."
                        ))
                getMainWindow().setEnabled(True)
                getMainWindow().FileManager.makeRefresh()
        elif actionName == "Pack":
            from Tools import Packager

            Packager.Packager(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Hash":
            from Tools import Hasher

            Hasher.Hasher(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Clear":
            from Tools import Cleaner

            Cleaner.Cleaner(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Text Corrector":
            from Tools import TextCorrector

            TextCorrector.TextCorrector(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "File Tree":
            from Tools import FileTreeBuilder

            FileTreeBuilder.FileTreeBuilder(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Search":
            from Tools import Searcher

            Searcher.Searcher(
                [getMainWindow().FileManager.getCurrentDirectoryPath()])
        elif actionName == "Script Manager":
            from Tools import ScriptManager

            if ScriptManager.ScriptManager.checkScriptManager():
                ScriptManager.ScriptManager(getMainWindow())
        elif actionName == "Show Last Actions":
            from Core import RecordsForm

            RecordsForm.RecordsForm(getMainWindow())
        elif actionName == "Remove Sub Files":
            answer = Dialogs.ask(
                translate("ToolsBar", "All Files Will Be Removed"),
                str(
                    translate(
                        "ToolsBar",
                        "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders."
                    )) % Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                fu.removeOnlySubFiles(
                    getMainWindow().FileManager.getCurrentDirectoryPath())
                getMainWindow().setEnabled(True)
                Dialogs.show(
                    translate("ToolsBar", "Removed Only All Files"),
                    str(
                        translate(
                            "ToolsBar",
                            "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders."
                        )) %
                    Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
        elif actionName == "Amarok Embedded Database Configurator":
            import Amarok

            if Amarok.checkAmarok():
                Amarok.openEmbeddedDBConfigurator()
        elif _action.parent().objectName() == "Table Types":
            changeTableType(_action)
        elif _action.parent().objectName() == "File Renamer Types":
            changeReNamerType(_action)
        elif _action.parent().objectName() == "Scripts":
            from Core import Scripts

            Scripts.runScriptFile(
                fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 15
0
 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()
Exemplo n.º 16
0
    def downloadAndInstall(self):
        try:
            if uni.isBuilt() is False:
                if fu.isWritableFileOrDir(fu.HamsiManagerDirectory, True) is False:
                    from Core import Organizer

                    Dialogs.showError(translate("UpdateControl", "Access Denied"),
                                      str(translate("UpdateControl",
                                                    "\"%s\" : you do not have the necessary permissions to change this directory.<br />Please check your access controls and retry. <br />Note: You can run Hamsi Manager as root and try again.")) % Organizer.getLink(
                                          fu.HamsiManagerDirectory))
            self.setFixedHeight(130)
            self.isDownloading = True
            self.prgbState.setVisible(True)
            self.lblInfo.setVisible(False)
            self.setWindowTitle(translate("UpdateControl", "Downloading Latest Release..."))
            self.request = MNetworkRequest(MUrl(self.updateInformations[1]))
            self.willDownload(self.request)
        except:
            ReportBug.ReportBug()
Exemplo n.º 17
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover") or
                                 self.isChangeableItem(rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo]["destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(rowNo, "destinationCover"):
                                 destinationPath = str(self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath or sourcePath != destinationPath or str(
                                 self.item(rowNo, 2).text()) != destinationPath) or (
                                         str(self.item(rowNo, 2).text()) !=
                                         self.values[rowNo]["currentCover"] and (
                                             str(self.item(rowNo, 2).text()) != sourcePath and str(
                                         self.item(rowNo, 2).text()) != destinationPath)):
                                 if str(self.item(rowNo, 3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(sourcePath,
                                                                 self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(destinationPath,
                                                                              self.values[
                                                                                  rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(sourcePath, destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(self.values[rowNo]["path"],
                                                               destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                             baseNameOfDirectory = str(self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName", baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                     fu.checkEmptyDirectories(oldDirName, True, True,
                                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
                           True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                  str(translate("FileUtils/Musics",
                                                "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                      Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                             newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                             fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                       rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                         uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
Exemplo n.º 18
0
 def clearIgnoreds(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             fu.clearIgnoreds(_path)
             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()
Exemplo n.º 19
0
 def checkIcon(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             fu.checkIcon(_path)
             Dialogs.show(translate("QuickMake", "Directory Icon Checked"),
                          str(translate("QuickMake",
                                        "\"%s\"`s icon checked.<br>The default action based on the data is executed.")) % Organizer.getLink(
                              _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 20
0
 def copyPath(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "fileAndDirectory", False)
         if _path is not None:
             MApplication.clipboard().setText(str(_path))
             Dialogs.show(translate("QuickMake", "Copied To Clipboard"),
                          str(translate("QuickMake", "\"%s\" copied to clipboard.")) % Organizer.getLink(_path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 21
0
 def exportValues(self,
                  _actionType="return",
                  _formatType="html",
                  _extInfo="no"):
     info = ""
     if _formatType == "html":
         if _extInfo == "no":
             pass
         elif _extInfo == "title":
             info += " \n<h3>%s : </h3>" % (str(
                 translate("Tables", "Table Contents")))
         info += " \n<table border=1> \n<tr> \n<td>*</td> \n"
         for columnNo in range(self.columnCount()):
             if self.isColumnHidden(columnNo) is False:
                 info += "<td><b>"
                 info += str(self.tableColumns[columnNo])
                 info += "</b></td> \n"
         info += "</tr> \n"
         for rowNo in range(self.rowCount()):
             if self.isRowHidden(rowNo) is False:
                 info += " \n<tr> \n<td>" + str(rowNo + 1) + "</td> \n"
                 for columnNo in range(self.columnCount()):
                     if self.isColumnHidden(columnNo) is False:
                         info += "<td>"
                         info += str(str(self.item(rowNo, columnNo).text()))
                         info += "</td> \n"
                 info += "</tr> \n"
         info += "</table> \n"
     elif _formatType == "plainText":
         if _extInfo == "no":
             pass
         elif _extInfo == "title":
             info += " %s : \n" % (str(translate("Tables",
                                                 "Table Contents")))
         info += "*\t"
         for columnNo in range(self.columnCount()):
             if self.isColumnHidden(columnNo) is False:
                 info += str(self.tableColumns[columnNo])
                 info += "\t"
         info += "\n"
         for rowNo in range(self.rowCount()):
             info += str(rowNo + 1) + "\t"
             if self.isRowHidden(rowNo) is False:
                 for columnNo in range(self.columnCount()):
                     if self.isColumnHidden(columnNo) is False:
                         info += str(str(self.item(rowNo, columnNo).text()))
                         info += "\t"
                 info += "\n"
     if _actionType == "return":
         return info
     elif _actionType == "file":
         fileExt = None
         formatTypeName = None
         if _formatType == "html":
             if _extInfo != "no":
                 strHeader = (
                     "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n"
                     +
                     "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> \n"
                     +
                     "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"tr\" lang=\"tr\" dir=\"ltr\"> \n"
                     +
                     "<head> \n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> \n</head> \n<body> \n"
                 )
                 strFooter = " \n</body> \n</html>"
                 info = strHeader + info + strFooter
             formatTypeName = translate("Tables", "HTML")
             fileExt = "html"
         elif _formatType == "plainText":
             formatTypeName = translate("Tables", "Plain Text")
             fileExt = "txt"
         filePath = Dialogs.getSaveFileName(
             translate("Tables", "Save As"),
             fu.joinPath(
                 fu.userDirectoryPath,
                 fu.getBaseName(self.currentDirectoryPath) + "." + fileExt),
             formatTypeName + " (*." + fileExt + ")", 2)
         if filePath is not None:
             if _formatType == "html" and filePath[-5:] != ".html":
                 filePath += ".html"
             elif _formatType == "plainText" and filePath[-4:] != ".txt":
                 filePath += ".txt"
             fu.writeToFile(filePath, info)
             Dialogs.show(
                 translate("Tables", "Table Exported"),
                 str(
                     translate(
                         "Tables",
                         "Table contents are exported to file: \"%s\".")) %
                 Organizer.getLink(filePath))
     elif _actionType == "dialog":
         dDialog = MDialog(getMainWindow())
         if isActivePyKDE4:
             dDialog.setButtons(MDialog.NoDefault)
         dDialog.setWindowTitle(translate("Tables", "Table Contents"))
         mainPanel = MWidget(dDialog)
         vblMain = MVBoxLayout(mainPanel)
         if _formatType == "html":
             QtWebKit = getMyObject("QtWebKit")
             wvWeb = QtWebKit.QWebView()
             wvWeb.setHtml(str(info))
             vblMain.addWidget(wvWeb)
         elif _formatType == "plainText":
             teContent = MTextEdit()
             teContent.setPlainText(str(info))
             vblMain.addWidget(teContent)
         pbtnClose = MPushButton(translate("Tables", "OK"))
         MObject.connect(pbtnClose, SIGNAL("clicked()"), dDialog.close)
         vblMain.addWidget(pbtnClose)
         if isActivePyKDE4:
             dDialog.setMainWidget(mainPanel)
         else:
             dDialog.setLayout(vblMain)
         dDialog.setMinimumWidth(600)
         dDialog.setMinimumHeight(400)
         dDialog.show()
     elif _actionType == "clipboard":
         MApplication.clipboard().setText(str(info))
Exemplo n.º 22
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(translate("MenuBar", "Open State Of Hamsi Manager"),
                                        fu.userDirectoryPath,
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(translate("MenuBar", "Save State Of Hamsi Manager"),
                                        fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(translate("MenuBar", "Current State Saved"),
                             translate("MenuBar",
                                       "Current state saved with preferences.<br>You can continue where you left off."))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree",
                               "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText",
                               "fileTree", "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

            OptionsForm.OptionsForm(getMainWindow())
        elif actionName == "My Plugins":
            import MyPlugins

            MyPlugins.MyPlugins()
        elif actionName == "Reconfigure":
            from Tools import Configurator

            Configurator.Configurator("configurePage")
        elif actionName == "My Plugins (System)":
            Execute.execute(["--qm", "--plugins", "--runAsRoot"], "HamsiManager")
        elif actionName == "Reconfigure (System)":
            Execute.execute(["--qm", "--configurator", "--runAsRoot"], "HamsiManager")
        elif actionName == "Update":
            from Core import UpdateControl

            UpdateControl.UpdateControl(getMainWindow())
        elif actionName == "Report Bug":
            ReportBug.ReportBug(True)
        elif actionName == "Suggest Idea":
            from Core import SuggestIdea

            SuggestIdea.SuggestIdea()
        elif actionName == "About Hamsi Manager":
            if isActivePyKDE4 is False:
                MMessageBox.about(getMainWindow(), translate("MenuBar", "About Hamsi Manager"),
                                  uni.aboutOfHamsiManager)
        elif actionName == translate("ToolsBar", "Check Icon"):
            getMainWindow().setEnabled(False)
            fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath())
            Dialogs.show(translate("ToolsBar", "Directory Icon Checked"),
                         translate("ToolsBar",
                                   "Current directory icon checked.<br>The default action based on the data is executed."))
            getMainWindow().setEnabled(True)
        elif actionName == "Clear Empty Directories":
            if getMainTable().checkUnSavedValues() is False:
                _action.setChecked(False)
                return False
            answer = Dialogs.ask(translate("ToolsBar", "Empty Directories Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                currentDirPath = getMainWindow().FileManager.getCurrentDirectoryPath()
                if fu.isWritableFileOrDir(currentDirPath):
                    fu.checkEmptyDirectories(currentDirPath, True, True, True, True)
                    Dialogs.show(translate("ToolsBar", "Directory Cleaned"),
                                 translate("ToolsBar",
                                           "The current directory is cleaned based on the criteria you set."))
                getMainWindow().setEnabled(True)
                getMainWindow().FileManager.makeRefresh()
        elif actionName == "Pack":
            from Tools import Packager

            Packager.Packager(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Hash":
            from Tools import Hasher

            Hasher.Hasher(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Clear":
            from Tools import Cleaner

            Cleaner.Cleaner(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Text Corrector":
            from Tools import TextCorrector

            TextCorrector.TextCorrector(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "File Tree":
            from Tools import FileTreeBuilder

            FileTreeBuilder.FileTreeBuilder(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Search":
            from Tools import Searcher

            Searcher.Searcher([getMainWindow().FileManager.getCurrentDirectoryPath()])
        elif actionName == "Script Manager":
            from Tools import ScriptManager

            if ScriptManager.ScriptManager.checkScriptManager():
                ScriptManager.ScriptManager(getMainWindow())
        elif actionName == "Show Last Actions":
            from Core import RecordsForm

            RecordsForm.RecordsForm(getMainWindow())
        elif actionName == "Remove Sub Files":
            answer = Dialogs.ask(translate("ToolsBar", "All Files Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                fu.removeOnlySubFiles(getMainWindow().FileManager.getCurrentDirectoryPath())
                getMainWindow().setEnabled(True)
                Dialogs.show(translate("ToolsBar", "Removed Only All Files"),
                             str(translate("ToolsBar",
                                           "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                 getMainWindow().FileManager.getCurrentDirectoryPath()))
        elif actionName == "Amarok Embedded Database Configurator":
            import Amarok

            if Amarok.checkAmarok():
                Amarok.openEmbeddedDBConfigurator()
        elif _action.parent().objectName() == "Table Types":
            changeTableType(_action)
        elif _action.parent().objectName() == "File Renamer Types":
            changeReNamerType(_action)
        elif _action.parent().objectName() == "Scripts":
            from Core import Scripts

            Scripts.runScriptFile(fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 23
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if musicFileValuesWithNames is not None:
                        allItemNumber = len(musicFileValuesWithNames)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in musicFileValuesWithNames:
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    if (fu.isFile(musicFileRow["filePath"]) and
                                            fu.isReadableFileOrDir(musicFileRow["filePath"], False, True)):
                                        details = fu.getDetails(musicFileRow["filePath"])
                                        content = {}
                                        if Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Amarok (Smart)":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = fu.getBaseName(
                                                fu.getDirName(musicFileRow["filePath"]))
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(musicFileRow["filePath"])
                                            except:
                                                if tagger.isSupportInfo:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                            else:
                                                if content["artist"].strip() == "":
                                                    content["artist"] = tagger.getArtist()
                                                if content["title"].strip() == "":
                                                    content["title"] = tagger.getTitle()
                                                if content["album"].strip() == "":
                                                    content["album"] = tagger.getAlbum()
                                                if content["albumArtist"].strip() == "":
                                                    content["albumArtist"] = tagger.getAlbumArtist()
                                                if str(content["trackNum"]).strip() == "":
                                                    content["trackNum"] = tagger.getTrackNum()
                                                if str(content["year"]).strip() == "":
                                                    content["year"] = tagger.getYear()
                                                if content["genre"].strip() == "":
                                                    content["genre"] = tagger.getGenre()
                                                if content["firstComment"].strip() == "":
                                                    content["firstComment"] = tagger.getFirstComment()
                                                if content["firstLyrics"].strip() == "":
                                                    content["firstLyrics"] = tagger.getFirstLyrics()
                                                if tagger.isSupportInfo:
                                                    content["length"] = tagger.getLength()
                                                    content["bitrate"] = tagger.getBitrate()
                                                    content["sampleRate"] = tagger.getSampleRate()
                                                    content["mode"] = tagger.getMode()
                                        elif Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Only Amarok":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = ""
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            if tagger.isSupportInfo:
                                                try:
                                                    tagger.loadFile(musicFileRow["filePath"])
                                                except:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                                else:
                                                    content["length"] = tagger.getLength()
                                                    content["bitrate"] = tagger.getBitrate()
                                                    content["sampleRate"] = tagger.getSampleRate()
                                                    content["mode"] = tagger.getMode()
                                        else:
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(musicFileRow["filePath"])
                                            except:
                                                Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                                                  str(translate("FileUtils/Musics",
                                                                                "\"%s\" : this file has the incorrect tag so can't read tags.")
                                                                  ) % Organizer.getLink(musicFileRow["filePath"]))
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = ""
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = tagger.getArtist()
                                            content["title"] = tagger.getTitle()
                                            content["album"] = tagger.getAlbum()
                                            content["albumArtist"] = tagger.getAlbumArtist()
                                            content["trackNum"] = tagger.getTrackNum()
                                            content["year"] = tagger.getYear()
                                            content["genre"] = tagger.getGenre()
                                            content["firstComment"] = tagger.getFirstComment()
                                            content["firstLyrics"] = tagger.getFirstLyrics()
                                            if tagger.isSupportInfo:
                                                content["length"] = tagger.getLength()
                                                content["bitrate"] = tagger.getBitrate()
                                                content["sampleRate"] = tagger.getSampleRate()
                                                content["mode"] = tagger.getMode()
                                        content["size"] = details[stat.ST_SIZE]
                                        content["lastAccessed"] = details[stat.ST_ATIME]
                                        content["lastModified"] = details[stat.ST_MTIME]
                                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                                        self.values.append(content)
                                        newBaseNameOfDirectory = Organizer.emend(
                                            self.values[rowNo]["baseNameOfDirectory"], "directory")
                                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                                        self.values[rowNo]["baseNameOfDirectory"])

                                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                                        self.createItem(rowNo, "albumArtist", newAlbumArtist,
                                                        self.values[rowNo]["albumArtist"])

                                        newTrackNum = str(self.values[rowNo]["trackNum"])
                                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                                        newYear = Organizer.emend(self.values[rowNo]["year"])
                                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                                        self.createItem(rowNo, "firstComment", newFirstComment,
                                                        self.values[rowNo]["firstComment"])

                                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                                        self.createItem(rowNo, "firstLyrics", newFirstLyrics,
                                                        self.values[rowNo]["firstLyrics"])

                                        if Taggers.getTagger().isSupportInfo:
                                            self.createItem(rowNo, "length", content["length"])
                                            self.createItem(rowNo, "bitrate", content["bitrate"])
                                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                                            self.createItem(rowNo, "mode", content["mode"])

                                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                                        self.createItem(rowNo, "lastAccessed",
                                                        Organizer.getCorrectedTime(content["lastAccessed"]))

                                        self.createItem(rowNo, "lastModified",
                                                        Organizer.getCorrectedTime(content["lastModified"]))

                                        self.createItem(rowNo, "lastMetadataChanged",
                                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 24
0
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"),
                          0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(
                            self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory",
                                                 baseNameOfDirectory):
                            baseNameOfDirectory = str(
                                self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName,
                                                 False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()),
                                        baseNameOfDirectory, baseName))
                        if fu.isFile(self.values[rowNo]
                                     ["path"]) and fu.isReadableFileOrDir(
                                         self.values[rowNo]["path"], False,
                                         True):
                            if fu.isWritableFileOrDir(newFilePath, False,
                                                      True):
                                newFilePathCopied = fu.copyOrChange(
                                    self.values[rowNo]["path"], newFilePath)
                                if self.values[rowNo][
                                        "path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(
                                                rowNo, "artist"):
                                            value = str(
                                                self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Artist")),
                                                str(self.values[rowNo]
                                                    ["artist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "title"):
                                            value = str(
                                                self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Title")),
                                                str(self.values[rowNo]
                                                    ["title"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "album"):
                                            value = str(
                                                self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album")),
                                                str(self.values[rowNo]
                                                    ["album"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "albumArtist"):
                                            value = str(
                                                self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album Artist")),
                                                str(self.values[rowNo]
                                                    ["albumArtist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "trackNum"):
                                            value = str(
                                                self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Track No")),
                                                str(self.values[rowNo]
                                                    ["trackNum"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "year"):
                                            value = str(
                                                self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable", "Year")),
                                                str(self.values[rowNo]
                                                    ["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "genre"):
                                            value = str(
                                                self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Genre")),
                                                str(self.values[rowNo]
                                                    ["genre"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstComment"):
                                            value = str(
                                                self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Comment")),
                                                str(self.values[rowNo]
                                                    ["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstLyrics"):
                                            value = str(
                                                self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Lyrics")),
                                                str(self.values[rowNo]
                                                    ["firstLyrics"]), value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(
                                            translate("MusicTable",
                                                      "Tags Cannot Changed"),
                                            str(
                                                translate(
                                                    "MusicTable",
                                                    "\"%s\" : cannot be changed tags."
                                                )) %
                                            Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1,
                allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Exemplo n.º 25
0
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath, dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails", "Close"))
                self.pbtnSave = MPushButton(translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"), self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [translate("MusicDetails", "Directory: "),
                               translate("MusicDetails", "File Name: "),
                               translate("MusicDetails", "Artist: "),
                               translate("MusicDetails", "Title: "),
                               translate("MusicDetails", "Album: "),
                               translate("MusicDetails", "Album Artist: "),
                               translate("MusicDetails", "Track: "),
                               translate("MusicDetails", "Year: "),
                               translate("MusicDetails", "Genre: ")]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(translate("MusicDetails", "File Does Not Exist"),
                              str(translate("MusicDetails",
                                            "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                              ) % Organizer.getLink(str(_filePath)))
            if hasattr(getMainWindow(),
                       "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Exemplo n.º 26
0
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
Exemplo n.º 27
0
 def removeOnlySubFiles(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             answer = Dialogs.ask(translate("QuickMake", "All Files Will Be Removed"),
                                  str(translate("QuickMake",
                                                "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                      _path))
             if answer == Dialogs.Yes:
                 getMainWindow().setEnabled(False)
                 fu.removeOnlySubFiles(_path)
                 getMainWindow().setEnabled(True)
                 Dialogs.show(translate("QuickMake", "Removed Only All Files"),
                              str(translate("QuickMake",
                                            "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                  _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 28
0
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                            baseNameOfDirectory = str(self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName, False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory,
                                        baseName))
                        if fu.isFile(self.values[rowNo]["path"]) and fu.isReadableFileOrDir(
                            self.values[rowNo]["path"], False, True):
                            if fu.isWritableFileOrDir(newFilePath, False, True):
                                newFilePathCopied = fu.copyOrChange(self.values[rowNo]["path"],
                                                                    newFilePath)
                                if self.values[rowNo]["path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(rowNo, "artist"):
                                            value = str(self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(str(translate("MusicTable", "Artist")),
                                                        str(self.values[rowNo]["artist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "title"):
                                            value = str(self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(str(translate("MusicTable", "Title")),
                                                        str(self.values[rowNo]["title"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "album"):
                                            value = str(self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(str(translate("MusicTable", "Album")),
                                                        str(self.values[rowNo]["album"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "albumArtist"):
                                            value = str(self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(str(translate("MusicTable", "Album Artist")),
                                                        str(self.values[rowNo]["albumArtist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "trackNum"):
                                            value = str(self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(str(translate("MusicTable", "Track No")),
                                                        str(self.values[rowNo]["trackNum"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "year"):
                                            value = str(self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(str(translate("MusicTable", "Year")),
                                                        str(self.values[rowNo]["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "genre"):
                                            value = str(self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(str(translate("MusicTable", "Genre")),
                                                        str(self.values[rowNo]["genre"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstComment"):
                                            value = str(self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(str(translate("MusicTable", "Comment")), str(
                                                self.values[rowNo]["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstLyrics"):
                                            value = str(self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(str(translate("MusicTable", "Lyrics")),
                                                        str(self.values[rowNo]["firstLyrics"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(translate("MusicTable", "Tags Cannot Changed"),
                                                          str(translate("MusicTable",
                                                                        "\"%s\" : cannot be changed tags.")
                                                          ) % Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Exemplo n.º 29
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        musicFileNames = fu.readDirectory(_path, "music", uni.getBoolValue("isShowHiddensInMusicTable"))
        isCanNoncompatible = False
        allItemNumber = len(musicFileNames)
        uni.startThreadAction()
        baseNameOfDirectory = fu.getBaseName(_path)
        rowNo = 0
        self.setRowCount(allItemNumber)
        for baseName in musicFileNames:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
                        tagger = Taggers.getTagger()
                        try:
                            tagger.loadFile(fu.joinPath(_path, baseName))
                        except:
                            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                              str(translate("FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                                              ) % Organizer.getLink(fu.joinPath(_path, baseName)))
                        if tagger.isAvailableFile() is False:
                            isCanNoncompatible = True
                        details = fu.getDetails(fu.joinPath(_path, baseName))
                        content = {}
                        content["path"] = fu.joinPath(_path, baseName)
                        content["baseNameOfDirectory"] = baseNameOfDirectory
                        content["baseName"] = baseName
                        content["artist"] = tagger.getArtist()
                        content["title"] = tagger.getTitle()
                        content["album"] = tagger.getAlbum()
                        content["albumArtist"] = tagger.getAlbumArtist()
                        content["trackNum"] = tagger.getTrackNum()
                        content["year"] = tagger.getYear()
                        content["genre"] = tagger.getGenre()
                        content["firstComment"] = tagger.getFirstComment()
                        content["firstLyrics"] = tagger.getFirstLyrics()
                        if tagger.isSupportInfo:
                            content["length"] = tagger.getLength()
                            content["bitrate"] = tagger.getBitrate()
                            content["sampleRate"] = tagger.getSampleRate()
                            content["mode"] = tagger.getMode()
                        content["size"] = details[stat.ST_SIZE]
                        content["lastAccessed"] = details[stat.ST_ATIME]
                        content["lastModified"] = details[stat.ST_MTIME]
                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                        self.values.append(content)
                        newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                        self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"])

                        newTrackNum = str(self.values[rowNo]["trackNum"])
                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                        newYear = Organizer.emend(self.values[rowNo]["year"])
                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                        self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"])

                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                        self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"])

                        if tagger.isSupportInfo:
                            self.createItem(rowNo, "length", content["length"])
                            self.createItem(rowNo, "bitrate", content["bitrate"])
                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                            self.createItem(rowNo, "mode", content["mode"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

                        self.createItem(rowNo, "lastMetadataChanged",
                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
        if isCanNoncompatible:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
Exemplo n.º 30
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(
         translate("FileUtils/Covers", "Writing Cover Informations"), 0,
         allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                           False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover")
                                 or self.isChangeableItem(
                                     rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo][
                                 "destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(
                                     self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(
                                     rowNo, "destinationCover"):
                                 destinationPath = str(
                                     self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath
                                     or sourcePath != destinationPath
                                     or str(self.item(rowNo, 2).text()) !=
                                     destinationPath
                                 ) or (str(self.item(rowNo, 2).text()) !=
                                       self.values[rowNo]["currentCover"]
                                       and
                                       (str(self.item(rowNo, 2).text()) !=
                                        sourcePath
                                        and str(self.item(rowNo, 2).text())
                                        != destinationPath)):
                                 if str(self.item(rowNo,
                                                  3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(
                                         sourcePath,
                                         self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(
                                         sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(
                                                 destinationPath,
                                                 self.values[rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(
                                                     sourcePath,
                                                     destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(
                                             self.values[rowNo]["path"],
                                             destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(
                                         self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo,
                                                  "baseNameOfDirectory",
                                                  baseNameOfDirectory):
                             baseNameOfDirectory = str(
                                 self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(
                                     fu.getDirName(
                                         self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(
                                         rowNo - 1,
                                         0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName",
                                                  baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(
                                 fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(
                             self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(
                                 oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue(
                                         "isClearEmptyDirectoriesWhenFileMove"
                                 ):
                                     fu.checkEmptyDirectories(
                                         oldDirName, True, True,
                                         uni.getBoolValue(
                                             "isAutoCleanSubFolderWhenFileMove"
                                         ))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(
             translate("FileUtils/Covers", "Writing Cover Informations"),
             rowNo + 1, allItemNumber, True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(
             oldAndNewPathValues
     ) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath,
                                           "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(
                 translate("FileUtils/Musics", "There Are More Files"),
                 str(
                     translate(
                         "FileUtils/Musics",
                         "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\""
                     )) % (Organizer.getLink(currentDirectoryPath),
                           Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(
                                 fu.joinPath(currentDirectoryPath,
                                             fileName))
                             newFilePath = fu.getRealPath(
                                 fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths[
                                     "newPath"] = fu.moveOrChange(
                                         oldFilePath, newFilePath,
                                         fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(
                                         oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(
                         translate(
                             "FileUtils/Covers",
                             "Writing Directory And File Informations"),
                         rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(
                         currentDirectoryPath, True, True,
                         uni.getBoolValue(
                             "isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and
                         uni.getBoolValue("isActiveAutoMakeIconToDirectory")
                         and uni.getBoolValue(
                             "isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
Exemplo n.º 31
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        musicFileNames = fu.readDirectoryWithSubDirectoriesThread(_path,
                                                                  int(uni.MySettings["subDirectoryDeep"]), "music",
                                                                  uni.getBoolValue(
                                                                      "isShowHiddensInSubFolderMusicTable"))
        isCanNoncompatible = False
        allItemNumber = len(musicFileNames)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for filePath in musicFileNames:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(filePath, False, True):
                        tagger = Taggers.getTagger()
                        try:
                            tagger.loadFile(filePath)
                        except:
                            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                              str(translate("FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                                              ) % Organizer.getLink(filePath))
                        if tagger.isAvailableFile() is False:
                            isCanNoncompatible = True
                        details = fu.getDetails(filePath)
                        content = {}
                        content["path"] = filePath
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) + str(fu.getDirName(filePath)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(filePath)
                        content["artist"] = tagger.getArtist()
                        content["title"] = tagger.getTitle()
                        content["album"] = tagger.getAlbum()
                        content["albumArtist"] = tagger.getAlbumArtist()
                        content["trackNum"] = tagger.getTrackNum()
                        content["year"] = tagger.getYear()
                        content["genre"] = tagger.getGenre()
                        content["firstComment"] = tagger.getFirstComment()
                        content["firstLyrics"] = tagger.getFirstLyrics()
                        if tagger.isSupportInfo:
                            content["length"] = tagger.getLength()
                            content["bitrate"] = tagger.getBitrate()
                            content["sampleRate"] = tagger.getSampleRate()
                            content["mode"] = tagger.getMode()
                        content["size"] = details[stat.ST_SIZE]
                        content["lastAccessed"] = details[stat.ST_ATIME]
                        content["lastModified"] = details[stat.ST_MTIME]
                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                        self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"])

                        newTrackNum = str(self.values[rowNo]["trackNum"])
                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                        newYear = Organizer.emend(self.values[rowNo]["year"])
                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                        self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"])

                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                        self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"])

                        if tagger.isSupportInfo:
                            self.createItem(rowNo, "length", content["length"])
                            self.createItem(rowNo, "bitrate", content["bitrate"])
                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                            self.createItem(rowNo, "mode", content["mode"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

                        self.createItem(rowNo, "lastMetadataChanged",
                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
        if isCanNoncompatible:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
Exemplo n.º 32
0
    def __init__(self, _artistId, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        if Commands.getArtistName(_artistId) is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.changeArtist(_artistId)
                        dialog.activateWindow()
                        dialog.raise_()
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                MDialog.__init__(self, MApplication.activeWindow())
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.infoLabels = {}
                self.infoValues = {}
                self.artistValues = {}
                self.pbtnClose = MPushButton(translate("AmarokArtistDetails", "Close"))
                self.pbtnSave = MPushButton(translate("AmarokArtistDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"), self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [translate("AmarokArtistDetails", "Current Artist: "),
                               translate("AmarokArtistDetails", "Corrected Artist: ")]
                self.songTableColumns = [translate("AmarokArtistDetails", "File Path"),
                                         translate("AmarokArtistDetails", "Artist"),
                                         translate("AmarokArtistDetails", "Title"),
                                         translate("AmarokArtistDetails", "Album"),
                                         translate("AmarokArtistDetails", "Album Artist"),
                                         translate("AmarokArtistDetails", "Track No"),
                                         translate("AmarokArtistDetails", "Year"),
                                         translate("AmarokArtistDetails", "Genre"),
                                         translate("AmarokArtistDetails", "Comment")]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeArtist(_artistId, True)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.setMinimumWidth(700)
                self.setMinimumHeight(500)
        else:
            Dialogs.showError(translate("AmarokArtistDetails", "Artist Does Not Exist"),
                              str(translate("AmarokArtistDetails",
                                            "\"%s\" does not exist in \"id\" column of \"artist\" table.<br>Table will be refreshed automatically!<br>Please retry.")
                              ) % Organizer.getLink(str(_artistId)))
            if hasattr(getMainWindow(),
                       "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Exemplo n.º 33
0
 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()
Exemplo n.º 34
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(
            translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(
                    translate("AmarokMusicTable",
                              "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if musicFileValuesWithNames is not None:
                        allItemNumber = len(musicFileValuesWithNames)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in musicFileValuesWithNames:
                            isContinueThreadAction = uni.isContinueThreadAction(
                            )
                            if isContinueThreadAction:
                                try:
                                    if (fu.isFile(musicFileRow["filePath"])
                                            and fu.isReadableFileOrDir(
                                                musicFileRow["filePath"],
                                                False, True)):
                                        details = fu.getDetails(
                                            musicFileRow["filePath"])
                                        content = {}
                                        if Amarok.getSelectedTagSourseType(
                                                "AmarokMusicTable"
                                        ) == "Amarok (Smart)":
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content["artist"] = musicFileRow[
                                                "artist"]
                                            content["title"] = musicFileRow[
                                                "title"]
                                            content["album"] = musicFileRow[
                                                "album"]
                                            content[
                                                "albumArtist"] = musicFileRow[
                                                    "albumArtist"]
                                            content["trackNum"] = musicFileRow[
                                                "trackNumber"]
                                            content["year"] = musicFileRow[
                                                "year"]
                                            content["genre"] = musicFileRow[
                                                "genre"]
                                            content[
                                                "firstComment"] = musicFileRow[
                                                    "comment"]
                                            content[
                                                "firstLyrics"] = musicFileRow[
                                                    "lyrics"]
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(
                                                    musicFileRow["filePath"])
                                            except:
                                                if tagger.isSupportInfo:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                            else:
                                                if content["artist"].strip(
                                                ) == "":
                                                    content[
                                                        "artist"] = tagger.getArtist(
                                                        )
                                                if content["title"].strip(
                                                ) == "":
                                                    content[
                                                        "title"] = tagger.getTitle(
                                                        )
                                                if content["album"].strip(
                                                ) == "":
                                                    content[
                                                        "album"] = tagger.getAlbum(
                                                        )
                                                if content[
                                                        "albumArtist"].strip(
                                                        ) == "":
                                                    content[
                                                        "albumArtist"] = tagger.getAlbumArtist(
                                                        )
                                                if str(content["trackNum"]
                                                       ).strip() == "":
                                                    content[
                                                        "trackNum"] = tagger.getTrackNum(
                                                        )
                                                if str(content["year"]).strip(
                                                ) == "":
                                                    content[
                                                        "year"] = tagger.getYear(
                                                        )
                                                if content["genre"].strip(
                                                ) == "":
                                                    content[
                                                        "genre"] = tagger.getGenre(
                                                        )
                                                if content[
                                                        "firstComment"].strip(
                                                        ) == "":
                                                    content[
                                                        "firstComment"] = tagger.getFirstComment(
                                                        )
                                                if content[
                                                        "firstLyrics"].strip(
                                                        ) == "":
                                                    content[
                                                        "firstLyrics"] = tagger.getFirstLyrics(
                                                        )
                                                if tagger.isSupportInfo:
                                                    content[
                                                        "length"] = tagger.getLength(
                                                        )
                                                    content[
                                                        "bitrate"] = tagger.getBitrate(
                                                        )
                                                    content[
                                                        "sampleRate"] = tagger.getSampleRate(
                                                        )
                                                    content[
                                                        "mode"] = tagger.getMode(
                                                        )
                                        elif Amarok.getSelectedTagSourseType(
                                                "AmarokMusicTable"
                                        ) == "Only Amarok":
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content["artist"] = musicFileRow[
                                                "artist"]
                                            content["title"] = musicFileRow[
                                                "title"]
                                            content["album"] = musicFileRow[
                                                "album"]
                                            content[
                                                "albumArtist"] = musicFileRow[
                                                    "albumArtist"]
                                            content["trackNum"] = musicFileRow[
                                                "trackNumber"]
                                            content["year"] = musicFileRow[
                                                "year"]
                                            content["genre"] = musicFileRow[
                                                "genre"]
                                            content[
                                                "firstComment"] = musicFileRow[
                                                    "comment"]
                                            content[
                                                "firstLyrics"] = musicFileRow[
                                                    "lyrics"]
                                            tagger = Taggers.getTagger()
                                            if tagger.isSupportInfo:
                                                try:
                                                    tagger.loadFile(
                                                        musicFileRow[
                                                            "filePath"])
                                                except:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                                else:
                                                    content[
                                                        "length"] = tagger.getLength(
                                                        )
                                                    content[
                                                        "bitrate"] = tagger.getBitrate(
                                                        )
                                                    content[
                                                        "sampleRate"] = tagger.getSampleRate(
                                                        )
                                                    content[
                                                        "mode"] = tagger.getMode(
                                                        )
                                        else:
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(
                                                    musicFileRow["filePath"])
                                            except:
                                                Dialogs.showError(
                                                    translate(
                                                        "FileUtils/Musics",
                                                        "Incorrect Tag"),
                                                    str(
                                                        translate(
                                                            "FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags."
                                                        )) % Organizer.getLink(
                                                            musicFileRow[
                                                                "filePath"]))
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content[
                                                "artist"] = tagger.getArtist()
                                            content["title"] = tagger.getTitle(
                                            )
                                            content["album"] = tagger.getAlbum(
                                            )
                                            content[
                                                "albumArtist"] = tagger.getAlbumArtist(
                                                )
                                            content[
                                                "trackNum"] = tagger.getTrackNum(
                                                )
                                            content["year"] = tagger.getYear()
                                            content["genre"] = tagger.getGenre(
                                            )
                                            content[
                                                "firstComment"] = tagger.getFirstComment(
                                                )
                                            content[
                                                "firstLyrics"] = tagger.getFirstLyrics(
                                                )
                                            if tagger.isSupportInfo:
                                                content[
                                                    "length"] = tagger.getLength(
                                                    )
                                                content[
                                                    "bitrate"] = tagger.getBitrate(
                                                    )
                                                content[
                                                    "sampleRate"] = tagger.getSampleRate(
                                                    )
                                                content[
                                                    "mode"] = tagger.getMode()
                                        content["size"] = details[stat.ST_SIZE]
                                        content["lastAccessed"] = details[
                                            stat.ST_ATIME]
                                        content["lastModified"] = details[
                                            stat.ST_MTIME]
                                        content[
                                            "lastMetadataChanged"] = details[
                                                stat.ST_CTIME]
                                        self.values.append(content)
                                        newBaseNameOfDirectory = Organizer.emend(
                                            self.values[rowNo]
                                            ["baseNameOfDirectory"],
                                            "directory")
                                        self.createItem(
                                            rowNo, "baseNameOfDirectory",
                                            newBaseNameOfDirectory,
                                            self.values[rowNo]
                                            ["baseNameOfDirectory"])

                                        newBaseName = Organizer.emend(
                                            self.values[rowNo]["baseName"],
                                            "file")
                                        self.createItem(
                                            rowNo, "baseName", newBaseName,
                                            self.values[rowNo]["baseName"])

                                        newArtist = Organizer.emend(
                                            self.values[rowNo]["artist"])
                                        self.createItem(
                                            rowNo, "artist", newArtist,
                                            self.values[rowNo]["artist"])

                                        newTitle = Organizer.emend(
                                            self.values[rowNo]["title"])
                                        self.createItem(
                                            rowNo, "title", newTitle,
                                            self.values[rowNo]["title"])

                                        newAlbum = Organizer.emend(
                                            self.values[rowNo]["album"])
                                        self.createItem(
                                            rowNo, "album", newAlbum,
                                            self.values[rowNo]["album"])

                                        newAlbumArtist = Organizer.emend(
                                            self.values[rowNo]["albumArtist"])
                                        self.createItem(
                                            rowNo, "albumArtist",
                                            newAlbumArtist,
                                            self.values[rowNo]["albumArtist"])

                                        newTrackNum = str(
                                            self.values[rowNo]["trackNum"])
                                        self.createItem(
                                            rowNo, "trackNum", newTrackNum,
                                            self.values[rowNo]["trackNum"])

                                        newYear = Organizer.emend(
                                            self.values[rowNo]["year"])
                                        self.createItem(
                                            rowNo, "year", newYear,
                                            self.values[rowNo]["year"])

                                        newGenre = Organizer.emend(
                                            self.values[rowNo]["genre"])
                                        self.createItem(
                                            rowNo, "genre", newGenre,
                                            self.values[rowNo]["genre"])

                                        newFirstComment = Organizer.emend(
                                            self.values[rowNo]["firstComment"])
                                        self.createItem(
                                            rowNo, "firstComment",
                                            newFirstComment,
                                            self.values[rowNo]["firstComment"])

                                        newFirstLyrics = Organizer.emend(
                                            self.values[rowNo]["firstLyrics"])
                                        self.createItem(
                                            rowNo, "firstLyrics",
                                            newFirstLyrics,
                                            self.values[rowNo]["firstLyrics"])

                                        if Taggers.getTagger().isSupportInfo:
                                            self.createItem(
                                                rowNo, "length",
                                                content["length"])
                                            self.createItem(
                                                rowNo, "bitrate",
                                                content["bitrate"])
                                            self.createItem(
                                                rowNo, "sampleRate",
                                                content["sampleRate"])
                                            self.createItem(
                                                rowNo, "mode", content["mode"])

                                        self.createItem(
                                            rowNo, "size",
                                            Organizer.getCorrectedFileSize(
                                                content["size"]))

                                        self.createItem(
                                            rowNo, "lastAccessed",
                                            Organizer.getCorrectedTime(
                                                content["lastAccessed"]))

                                        self.createItem(
                                            rowNo, "lastModified",
                                            Organizer.getCorrectedTime(
                                                content["lastModified"]))

                                        self.createItem(
                                            rowNo, "lastMetadataChanged",
                                            Organizer.getCorrectedTime(
                                                content["lastMetadataChanged"])
                                        )

                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(
                                translate("Tables", "Generating Table..."),
                                rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(
            self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 35
0
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath,
                                           dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails",
                                                       "Close"))
                self.pbtnSave = MPushButton(
                    translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"),
                                self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [
                    translate("MusicDetails", "Directory: "),
                    translate("MusicDetails", "File Name: "),
                    translate("MusicDetails", "Artist: "),
                    translate("MusicDetails", "Title: "),
                    translate("MusicDetails", "Album: "),
                    translate("MusicDetails", "Album Artist: "),
                    translate("MusicDetails", "Track: "),
                    translate("MusicDetails", "Year: "),
                    translate("MusicDetails", "Genre: ")
                ]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(
                translate("MusicDetails", "File Does Not Exist"),
                str(
                    translate(
                        "MusicDetails",
                        "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry."
                    )) % Organizer.getLink(str(_filePath)))
            if hasattr(
                    getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None:
                getMainWindow().FileManager.makeRefresh()
Exemplo n.º 36
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        isNewDirectoriesSame = True
        isMovedToNewDirectory = False
        currentDirectoryPath = ""
        newDirectoryPath = ""
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    changingTag = {"path": self.values[rowNo]["path"]}
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            tagger = Taggers.getTagger()
                            tagger.loadFileForWrite(self.values[rowNo]["path"])
                            isCheckLike = (tagger.isNeedUpdate or
                                           (uni.isActiveAmarok and
                                            uni.getBoolValue("isMusicTableValuesChangeInAmarokDB")))
                            if self.isChangeableItem(rowNo, "artist", self.values[rowNo]["artist"], True, isCheckLike):
                                value = str(self.item(rowNo, 2).text())
                                tagger.setArtist(value)
                                changingTag["artist"] = value
                                Records.add(str(translate("MusicTable", "Artist")),
                                            str(self.values[rowNo]["artist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "title", self.values[rowNo]["title"], True, isCheckLike):
                                value = str(self.item(rowNo, 3).text())
                                tagger.setTitle(value)
                                changingTag["title"] = value
                                Records.add(str(translate("MusicTable", "Title")),
                                            str(self.values[rowNo]["title"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "album", self.values[rowNo]["album"], True, isCheckLike):
                                value = str(self.item(rowNo, 4).text())
                                tagger.setAlbum(value)
                                changingTag["album"] = value
                                Records.add(str(translate("MusicTable", "Album")),
                                            str(self.values[rowNo]["album"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "albumArtist", self.values[rowNo]["albumArtist"], True,
                                                     isCheckLike):
                                value = str(self.item(rowNo, 5).text())
                                tagger.setAlbumArtist(value)
                                changingTag["albumArtist"] = value
                                Records.add(str(translate("MusicTable", "Album Artist")),
                                            str(self.values[rowNo]["albumArtist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "trackNum", self.values[rowNo]["trackNum"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 6).text())
                                tagger.setTrackNum(value)
                                changingTag["trackNum"] = value
                                Records.add(str(translate("MusicTable", "Track No")),
                                            str(self.values[rowNo]["trackNum"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "year", self.values[rowNo]["year"], True, isCheckLike):
                                value = str(self.item(rowNo, 7).text())
                                tagger.setDate(value)
                                changingTag["year"] = value
                                Records.add(str(translate("MusicTable", "Year")),
                                            str(self.values[rowNo]["year"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "genre", self.values[rowNo]["genre"], True, isCheckLike):
                                value = str(self.item(rowNo, 8).text())
                                tagger.setGenre(value)
                                changingTag["genre"] = value
                                Records.add(str(translate("MusicTable", "Genre")),
                                            str(self.values[rowNo]["genre"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstComment", self.values[rowNo]["firstComment"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 9).text())
                                tagger.setFirstComment(value)
                                changingTag["firstComment"] = value
                                Records.add(str(translate("MusicTable", "Comment")),
                                            str(self.values[rowNo]["firstComment"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstLyrics", self.values[rowNo]["firstLyrics"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 10).text())
                                tagger.setFirstLyrics(value)
                                changingTag["firstLyrics"] = value
                                Records.add(str(translate("MusicTable", "Lyrics")),
                                            str(self.values[rowNo]["firstLyrics"]), value)
                                self.changedValueNumber += 1
                            if len(changingTag) > 1:
                                changingTags.append(changingTag)
                            tagger.update()
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                isMovedToNewDirectory = True
                                currentDirectoryPath = fu.getDirName(
                                    self.values[rowNo]["path"])
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                                if rowNo > 0:
                                    if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                        isNewDirectoriesSame = False
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags And Informations"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
            otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
            if len(otherFileNames) > 0:
                answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                     str(translate("FileUtils/Musics",
                                                   "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                         Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
                if answer == Dialogs.Yes:
                    uni.startThreadAction()
                    allItemNumber = len(otherFileNames)
                    for rowNo, fileName in enumerate(otherFileNames):
                        isContinueThreadAction = uni.isContinueThreadAction()
                        if isContinueThreadAction:
                            try:
                                oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                                newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                                if oldFilePath != newFilePath:
                                    oldAndNewPaths = {}
                                    oldAndNewPaths["oldPath"] = oldFilePath
                                    oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                                fu.getObjectType(oldFilePath))
                                    if oldFilePath != oldAndNewPaths["newPath"]:
                                        oldAndNewPathValues.append(oldAndNewPaths)
                            except:
                                ReportBug.ReportBug()
                        else:
                            allItemNumber = rowNo + 1
                        Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                          rowNo + 1, allItemNumber, True)
                        if isContinueThreadAction is False:
                            break
                    uni.finishThreadAction()
                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                        fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                    if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                        fu.checkIcon(newDirectoryPath)
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok
            from Amarok import Operations

            Operations.changeTags(changingTags)
            if len(oldAndNewPathValues) > 0:
                Operations.changePaths(oldAndNewPathValues, "file")
        return True
Exemplo n.º 37
0
 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()