예제 #1
0
 def uninstallPlugin(self, _pluginName, _isQuiet=False):
     isUninstalled = False
     pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
                               ["pluginName", "pluginFiles", "pluginDirectory", "uninstallThisPlugin",
                                "setupDirectory", "pluginVersion"], 0)
     if pluginModule.uninstallThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             for pluginFile in pluginModule.pluginFiles:
                 if fu.isFile(fu.joinPath(pluginModule.setupDirectory, pluginFile)):
                     fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isUninstalled = True
         else:
             if fu.isDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory)):
                 fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory))
             isUninstalled = True
     else:
         isUninstalled = pluginModule.uninstallThisPlugin()
     if isUninstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(""))
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Uninstallation Is Complete"),
                          str(translate("MyPlugins", "\"%s\" is uninstalled on your system.")) % (
                              pluginModule.pluginName))
     elif isUninstalled == "AlreadyUninstalled":
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Already Uninstalled"),
                          str(translate("MyPlugins", "\"%s\" already uninstalled on your system.")) % (
                              pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(translate("MyPlugins", "Plug-in Uninstallation Failed"),
                               str(translate("MyPlugins", "\"%s\" failed to uninstall on your system.")) % (
                                   pluginModule.pluginName))
예제 #2
0
 def hash(self):
     sourceFile = str(self.lePathOfPackage.text())
     sourceFile = fu.checkSource(sourceFile, "file")
     if sourceFile is not None:
         hashType = str(self.cbHash.currentText())
         if hashType is not None:
             hashDigestContent = fu.getHashDigest(sourceFile, hashType)
             if hashDigestContent is not False:
                 self.teHashDigest.setText(str(hashDigestContent))
                 if self.cbHashOutput.currentIndex() == 1:
                     if fu.createHashDigestFile(sourceFile, str(self.leHashDigestFile.text()), hashType, False,
                                                hashDigestContent):
                         Dialogs.show(translate("Hasher", "Hash Digest File Created"),
                                      str(translate("Hasher", "Hash digest writed into %s")) % str(
                                          self.leHashDigestFile.text()))
                     else:
                         Dialogs.showError(translate("Hasher", "Hash Digest File Is Not Created"),
                                           translate("Hasher", "Hash digest file not cteated."))
                 elif self.cbHashOutput.currentIndex() == 2:
                     MApplication.clipboard().setText(str(hashDigestContent))
                     Dialogs.show(translate("Hasher", "Hash Digest Copied To Clipboard"),
                                  str(translate("Hasher",
                                                "Hash digest copied to clipboard.Hash digest is : <br>%s")) % hashDigestContent)
             else:
                 Dialogs.showError(translate("Hasher", "Hash Digest Is Not Created"),
                                   translate("Hasher", "Hash digest not cteated."))
예제 #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()
예제 #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()
예제 #5
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
예제 #6
0
def checkAmarok(_isAlertIfNotAvailable=True, _isUseReadOnly=True):
    global isAskEmbeddedDBConfiguration
    if isLoadedMysql and uni.isAvailableKDE4():
        if uni.getBoolValue("amarokIsUseHost"):
            if _isUseReadOnly or uni.getBoolValue(
                    "isReadOnlyAmarokDBHost") is False:
                return True
            else:
                if _isAlertIfNotAvailable:
                    answer = Dialogs.ask(
                        translate("Amarok", "This Feature Is Not Usable"),
                        translate(
                            "Amarok",
                            "This feature is not usable with read only Amarok database. <br>Are you want to give permission to read and write for Amarok database?"
                        ))
                    if answer == Dialogs.Yes:
                        uni.setMySetting("isReadOnlyAmarokDBHost", False)
                        return True
        else:
            isAskEmbeddedDBConfiguration = True
            return checkEmbeddedDB()
    else:
        if _isAlertIfNotAvailable:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok", "Please run Amarok once."))
        return False
    return False
예제 #7
0
 def errorOccurred(self):
     self.isFileExist = False
     Dialogs.showError(
         translate("UpdateControl", "Cannot Read Source."),
         translate("UpdateControl",
                   "Cannot read source package. Please retry later."))
     self.close()
예제 #8
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()
예제 #9
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()
예제 #10
0
def whatDoesSpecialCommandDo(_actionCommand, _isShowAlert=False, _isReturnDetails=False):
    splitterIndex = _actionCommand.index("~||~")
    leftKeys = _actionCommand[:splitterIndex]
    rightKeys = _actionCommand[splitterIndex + 1:]
    if len(leftKeys) > 0 and len(rightKeys) > 0:
        details = ""
        leftNames = ""
        rightNames = ""
        for objectNameAndPoint in leftKeys:
            objectNameAndPointList = objectNameAndPoint.split("~|~")
            objectName = objectNameAndPointList[0]
            point = ""
            if len(objectNameAndPointList) > 1:
                point = objectNameAndPointList[1]
            if objectName.find("Concatenate") == -1:
                leftNames += getMainTable().getColumnNameFromKey(objectName)
            else:
                leftNames += translate("Organizer", "Concatenate")
            if point != "":
                if objectName.find("Concatenate") == -1:
                    leftNames += " " + (str(translate("Organizer", "(can be separated by \"%s\")")) % (point))
                else:
                    leftNames += " " + (str(translate("Organizer", "(can be concatenated by \"%s\")")) % (point))
            if leftKeys[-1] != objectNameAndPoint:
                leftNames += " ,"
        for objectNameAndPoint in rightKeys:
            objectNameAndPointList = objectNameAndPoint.split("~|~")
            objectName = objectNameAndPointList[0]
            point = ""
            if len(objectNameAndPointList) > 1:
                point = objectNameAndPointList[1]
            if objectName.find("Concatenate") == -1:
                rightNames += getMainTable().getColumnNameFromKey(objectName)
            else:
                rightNames += translate("Organizer", "Concatenate")
            if point != "":
                if objectName.find("Concatenate") == -1:
                    rightNames += " " + (str(translate("Organizer", "(can be separated by \"%s\")")) % (point))
                else:
                    rightNames += " " + (str(translate("Organizer", "(can be concatenated by \"%s\")")) % (point))
            if rightKeys[-1] != objectNameAndPoint:
                rightNames += " ,"

        details = str(translate("Organizer",
                                "\"%s\" will be concatenated and/or separated then it will be set as \"%s\" respectively.")) % (
                      leftNames, rightNames)

        if _isShowAlert:
            Dialogs.show(translate("Organizer", "What Does This Command Do?"), str(details))
        if _isReturnDetails is False:
            return True
        else:
            return details
    else:
        Dialogs.showError(translate("Organizer", "Missing Command"),
                          translate("Organizer", "You have to add at least a \"Column\"!.."))
        return False
예제 #11
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"]))
예제 #12
0
 def sourceCharSetChanged(self):
     try:
         self.fileValues = fu.readTextFile(self.fileValues["path"], str(self.sourceCharSet.currentText()))
         self.infoValues["content"].setPlainText(
             str(Organizer.emend(self.fileValues["content"], "text", False, True)))
     except:
         Dialogs.showError(translate("TextDetails", "Incorrect File Encoding"),
                           str(translate("TextDetails",
                                         "File can not decode by \"%s\" codec.<br>Please select another file encoding type.")
                           ) % str(self.sourceCharSet.currentText()))
예제 #13
0
 def sourceCharSetChanged(self):
     try:
         if self.isChangeSourceCharSetChanged:
             self.fillValues()
     except:
         self.pbtnSave.setEnabled(False)
         Dialogs.showError(translate("TextCorrector", "Incorrect File Encoding"),
                           str(translate("TextCorrector",
                                         "File can not decode by \"%s\" codec.<br>Please select another file encoding type.")
                           ) % str(self.sourceCharSet.currentText()))
예제 #14
0
 def uninstallPlugin(self, _pluginName, _isQuiet=False):
     isUninstalled = False
     pluginModule = __import__(
         "MyPlugins." + _pluginName, globals(), locals(), [
             "pluginName", "pluginFiles", "pluginDirectory",
             "uninstallThisPlugin", "setupDirectory", "pluginVersion"
         ], 0)
     if pluginModule.uninstallThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             for pluginFile in pluginModule.pluginFiles:
                 if fu.isFile(
                         fu.joinPath(pluginModule.setupDirectory,
                                     pluginFile)):
                     fu.removeFileOrDir(
                         fu.joinPath(pluginModule.setupDirectory,
                                     pluginFile))
             isUninstalled = True
         else:
             if fu.isDir(
                     fu.joinPath(pluginModule.setupDirectory,
                                 pluginModule.pluginDirectory)):
                 fu.removeFileOrDir(
                     fu.joinPath(pluginModule.setupDirectory,
                                 pluginModule.pluginDirectory))
             isUninstalled = True
     else:
         isUninstalled = pluginModule.uninstallThisPlugin()
     if isUninstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(""))
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins",
                           "Plug-in Uninstallation Is Complete"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" is uninstalled on your system.")) %
                 (pluginModule.pluginName))
     elif isUninstalled == "AlreadyUninstalled":
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins", "Plug-in Already Uninstalled"),
                 str(
                     translate(
                         "MyPlugins",
                         "\"%s\" already uninstalled on your system.")) %
                 (pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(
                 translate("MyPlugins", "Plug-in Uninstallation Failed"),
                 str(
                     translate(
                         "MyPlugins",
                         "\"%s\" failed to uninstall on your system.")) %
                 (pluginModule.pluginName))
예제 #15
0
    def checkScriptManager(_isAlertIfNotAvailable=True):
        try:
            from PyQt4.Qsci import QsciScintilla

            return True
        except:
            if _isAlertIfNotAvailable:
                Dialogs.showError(translate("MenuBar", "Qsci Is Not Installed"),
                                  translate("MenuBar",
                                            "Qsci is not installed on your systems.<br>Please install Qsci on your system and try again."))
            return False
예제 #16
0
def findExecutablePath(_executableName, _isAlertIfNotFound=True):
    executableBaseName = findExecutableBaseName(_executableName)
    if executableBaseName is not None:
        return fu.joinPath(fu.HamsiManagerDirectory, executableBaseName)
    if _isAlertIfNotFound:
        from Core import Dialogs

        Dialogs.showError(translate("Execute", "Cannot Find Executable File"),
                          str(translate("Execute",
                                        "\"%s\" : cannot find an executable file matched this name in directory of Hamsi Manager.<br>Please make sure that it exists and retry.")) % _executableName)
    return None
예제 #17
0
 def sourceCharSetChanged(self):
     try:
         if self.isChangeSourceCharSetChanged:
             self.fillValues()
     except:
         self.pbtnSave.setEnabled(False)
         Dialogs.showError(
             translate("TextCorrector", "Incorrect File Encoding"),
             str(
                 translate(
                     "TextCorrector",
                     "File can not decode by \"%s\" codec.<br>Please select another file encoding type."
                 )) % str(self.sourceCharSet.currentText()))
예제 #18
0
def findExecutablePath(_executableName, _isAlertIfNotFound=True):
    executableBaseName = findExecutableBaseName(_executableName)
    if executableBaseName is not None:
        return fu.joinPath(fu.HamsiManagerDirectory, executableBaseName)
    if _isAlertIfNotFound:
        from Core import Dialogs

        Dialogs.showError(
            translate("Execute", "Cannot Find Executable File"),
            str(
                translate(
                    "Execute",
                    "\"%s\" : cannot find an executable file matched this name in directory of Hamsi Manager.<br>Please make sure that it exists and retry."
                )) % _executableName)
    return None
예제 #19
0
 def play(self, _filePath):
     if self.m_media is not None:
         self.stop()
     try:
         from PySide.phonon import Phonon
     except:
         Dialogs.showError(translate("Player", "Phonon Is Not Installed On Your System."),
                           translate("Player",
                                     "We could not find the Phonon(PySide) module installed on your system.<br>Please choose another player from the options or <br>check your Phonon installation."))
         return False
     if not self.m_media:
         self.m_media = Phonon.MediaObject()
         self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory)
         Phonon.createPath(self.m_media, self.audioOutput)
     self.m_media.setCurrentSource(Phonon.MediaSource(str(_filePath)))
     self.m_media.play()
     self.paused = False
     return True
예제 #20
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()
예제 #21
0
 def hash(self):
     sourceFile = str(self.lePathOfPackage.text())
     sourceFile = fu.checkSource(sourceFile, "file")
     if sourceFile is not None:
         hashType = str(self.cbHash.currentText())
         if hashType is not None:
             hashDigestContent = fu.getHashDigest(sourceFile, hashType)
             if hashDigestContent is not False:
                 self.teHashDigest.setText(str(hashDigestContent))
                 if self.cbHashOutput.currentIndex() == 1:
                     if fu.createHashDigestFile(
                             sourceFile, str(self.leHashDigestFile.text()),
                             hashType, False, hashDigestContent):
                         Dialogs.show(
                             translate("Hasher",
                                       "Hash Digest File Created"),
                             str(
                                 translate("Hasher",
                                           "Hash digest writed into %s")) %
                             str(self.leHashDigestFile.text()))
                     else:
                         Dialogs.showError(
                             translate("Hasher",
                                       "Hash Digest File Is Not Created"),
                             translate("Hasher",
                                       "Hash digest file not cteated."))
                 elif self.cbHashOutput.currentIndex() == 2:
                     MApplication.clipboard().setText(
                         str(hashDigestContent))
                     Dialogs.show(
                         translate("Hasher",
                                   "Hash Digest Copied To Clipboard"),
                         str(
                             translate(
                                 "Hasher",
                                 "Hash digest copied to clipboard.Hash digest is : <br>%s"
                             )) % hashDigestContent)
             else:
                 Dialogs.showError(
                     translate("Hasher", "Hash Digest Is Not Created"),
                     translate("Hasher", "Hash digest not cteated."))
예제 #22
0
 def installPlugin(self, _pluginName, _isQuiet=False):
     isInstalled = False
     pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
                               ["pluginName", "pluginFiles", "pluginDirectory", "installThisPlugin",
                                "setupDirectory", "pluginVersion"], 0)
     if pluginModule.installThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             try: fu.makeDirs(pluginModule.setupDirectory)
             except: pass
             for pluginFile in pluginModule.pluginFiles:
                 fu.copyOrChange(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginFile),
                                 fu.joinPath(pluginModule.setupDirectory, pluginFile), "file", "only", True)
                 MyConfigure.reConfigureFile(fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isInstalled = True
         else:
             oldFilePath = fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName,
                                       pluginModule.pluginDirectory)
             newFilePath = fu.copyOrChange(oldFilePath,
                                           fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory),
                                           "directory", "only", True)
             if newFilePath != oldFilePath:
                 isInstalled = True
     else:
         isInstalled = pluginModule.installThisPlugin()
     if isInstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(pluginModule.pluginVersion))
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Installation Is Complete"),
                          str(translate("MyPlugins", "\"%s\" is installed on your system.")) % (
                              pluginModule.pluginName))
     elif isInstalled == "AlreadyInstalled":
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Already Installed"),
                          str(translate("MyPlugins", "\"%s\" already installed on your system.")) % (
                              pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(translate("MyPlugins", "Plug-in Installation Failed"),
                               str(translate("MyPlugins", "\"%s\" failed to install on your system.")) % (
                                   pluginModule.pluginName))
예제 #23
0
        def uninstall(self):
            try:
                MApplication.processEvents()
                self.UninstallationDirectory = str(self.leUninstallationDirectory.text())
                if len(self.UninstallationDirectory) > 0:
                    if self.UninstallationDirectory[-1] == fu.sep:
                        self.UninstallationDirectory = self.UninstallationDirectory[:-1]
                    if self.UninstallationDirectory == fu.HamsiManagerDirectory:
                        self.pageNo -= 1
                        Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
                                          translate("Uninstall",
                                                    "The selected path is Hamsi Manager source directory.<br>Please choose a valid uninstallation path."))
                    elif fu.isDir(self.UninstallationDirectory):
                        fu.removeFileOrDir(self.UninstallationDirectory)
                    else:
                        self.pageNo -= 1
                        Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
                                          translate("Uninstall",
                                                    "The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."))
                else:
                    self.pageNo -= 1
                    Dialogs.showError(translate("Uninstall", "The path you selected is not valid."),
                                      translate("Uninstall",
                                                "The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."))
                self.pageChanged(True)
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
예제 #24
0
def runScript(_content, _isShowAlertIsSuccessfully=True):
    try:
        try:
            if _content is not None:
                exec(_content)
                if _isShowAlertIsSuccessfully:
                    Dialogs.show(
                        translate("ScriptManager",
                                  "Script Has Run Successfully"),
                        translate(
                            "ScriptManager",
                            "Script which you selected has run successfully."))
                return True
            else:
                Dialogs.showError(
                    translate("ScriptManager", "Script Is Not Available"),
                    translate(
                        "ScriptManager",
                        "Script content is not available or Script file couldn`t read."
                    ))
        except Exception as error:
            import traceback

            cla, error, trbk = sys.exc_info()
            errorName = cla.__name__
            try:
                excArgs = error.__dict__["args"]
            except KeyError:
                excArgs = "<no args>"
            errorDetail = traceback.format_tb(trbk, 5)
            errorDetails = str(errorName) + "\n" + str(error) + "\n" + str(
                excArgs) + "\n" + str(errorDetail[0])
            Dialogs.showError(
                translate("ScriptManager", "Error: Failed To Run The Query"),
                str(translate("ScriptManager", "Error details: <br> \"%s\"")) %
                (errorDetails))
            return False
    except:
        ReportBug.ReportBug()
예제 #25
0
def checkAmarok(_isAlertIfNotAvailable=True, _isUseReadOnly=True):
    global isAskEmbeddedDBConfiguration
    if isLoadedMysql and uni.isAvailableKDE4():
        if uni.getBoolValue("amarokIsUseHost"):
            if _isUseReadOnly or uni.getBoolValue("isReadOnlyAmarokDBHost") is False:
                return True
            else:
                if _isAlertIfNotAvailable:
                    answer = Dialogs.ask(translate("Amarok", "This Feature Is Not Usable"),
                                         translate("Amarok",
                                                   "This feature is not usable with read only Amarok database. <br>Are you want to give permission to read and write for Amarok database?"))
                    if answer == Dialogs.Yes:
                        uni.setMySetting("isReadOnlyAmarokDBHost", False)
                        return True
        else:
            isAskEmbeddedDBConfiguration = True
            return checkEmbeddedDB()
    else:
        if _isAlertIfNotAvailable:
            Dialogs.showError(translate("Amarok", "Amarok Module Is Not Usable"),
                              translate("Amarok", "Please run Amarok once."))
        return False
    return False
예제 #26
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()
예제 #27
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()
예제 #28
0
 def askHiddenColumn(self, _columnKey, _isYesToAll=True):
     if _isYesToAll is False:
         self.isAskShowHiddenColumn = True
     if self.isAskShowHiddenColumn:
         if _isYesToAll:
             answer = Dialogs.askSpecial(
                 translate("Tables", "Hidden Field"),
                 str(
                     translate(
                         "Tables",
                         "\"%s\": you have hidden this field in the table.<br>Do you want to activate this field and perform the action?"
                     )) % (self.getColumnNameFromKey(_columnKey)),
                 translate("Dialogs", "Yes"), translate("Dialogs", "No"),
                 translate("Dialogs", "Yes To All"))
         else:
             answer = Dialogs.ask(
                 translate("Tables", "Hidden Field"),
                 str(
                     translate(
                         "Tables",
                         "\"%s\": you have hidden this field in the table.<br>Do you want to activate this field and perform the action?"
                     )) % (self.getColumnNameFromKey(_columnKey)))
         if answer == Dialogs.No or answer == translate("Dialogs", "No"):
             Dialogs.showError(
                 translate("Tables", "Action Cancelled"),
                 translate(
                     "Tables",
                     "You have cancelled the action.<br>You can make the necessary changes and reperform the action."
                 ))
             return False
         elif answer == translate("Dialogs", "Yes To All"):
             self.isAskShowHiddenColumn = False
     self.mContextMenuColumnsActions[self.getColumnNoFromKey(
         _columnKey)].setChecked(True)
     self.refreshShowedAndHiddenColumns()
     return True
예제 #29
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()
예제 #30
0
        def uninstall(self):
            try:
                MApplication.processEvents()
                self.UninstallationDirectory = str(
                    self.leUninstallationDirectory.text())
                if len(self.UninstallationDirectory) > 0:
                    if self.UninstallationDirectory[-1] == fu.sep:
                        self.UninstallationDirectory = self.UninstallationDirectory[:
                                                                                    -1]
                    if self.UninstallationDirectory == fu.HamsiManagerDirectory:
                        self.pageNo -= 1
                        Dialogs.showError(
                            translate("Uninstall",
                                      "The path you selected is not valid."),
                            translate(
                                "Uninstall",
                                "The selected path is Hamsi Manager source directory.<br>Please choose a valid uninstallation path."
                            ))
                    elif fu.isDir(self.UninstallationDirectory):
                        fu.removeFileOrDir(self.UninstallationDirectory)
                    else:
                        self.pageNo -= 1
                        Dialogs.showError(
                            translate("Uninstall",
                                      "The path you selected is not valid."),
                            translate(
                                "Uninstall",
                                "The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."
                            ))
                else:
                    self.pageNo -= 1
                    Dialogs.showError(
                        translate("Uninstall",
                                  "The path you selected is not valid."),
                        translate(
                            "Uninstall",
                            "The selected path points to a file not a folder.<br>Please choose a valid Uninstallation path."
                        ))
                self.pageChanged(True)
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
    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()
예제 #32
0
    def setTable(self, _parent):
        if uni.tableType == "0":
            from Tables import FolderTable

            self.Table = FolderTable.FolderTable(_parent)
        elif uni.tableType == "1":
            from Tables import FileTable

            self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "2":
            import Taggers

            if Taggers.getTagger(True) is not None:
                from Tables import MusicTable

                self.Table = MusicTable.MusicTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "3":
            from Tables import SubFolderTable

            self.Table = SubFolderTable.SubFolderTable(_parent)
        elif uni.tableType == "4":
            if uni.isActiveDirectoryCover:
                from Tables import CoverTable

                self.Table = CoverTable.CoverTable(_parent)
            else:
                Dialogs.showError(
                    translate("Tables", "Directory Cover Not Usable"),
                    translate(
                        "Tables",
                        "Any icon can not set to any directory. This feature is not usable in your system."
                    ))
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "5":
            import Amarok

            if Amarok.checkAmarok(True, False):
                uni.tableType = "5"
                import AmarokCoverTable

                self.Table = AmarokCoverTable.AmarokCoverTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "6":
            import Taggers
            import Amarok

            if Taggers.getTagger(True) is not None and Amarok.checkAmarok(
                    True, False):
                import AmarokMusicTable

                self.Table = AmarokMusicTable.AmarokMusicTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "7":
            import Amarok

            if Amarok.checkAmarok(True, False):
                import AmarokArtistTable

                self.Table = AmarokArtistTable.AmarokArtistTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "8":
            import Taggers
            import Amarok

            if Taggers.getTagger(True) is not None and Amarok.checkAmarok(
                    True, False):
                import AmarokCopyTable

                self.Table = AmarokCopyTable.AmarokCopyTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
        elif uni.tableType == "9":
            import Taggers

            if Taggers.getTagger(True) is not None:
                from Tables import SubFolderMusicTable

                self.Table = SubFolderMusicTable.SubFolderMusicTable(_parent)
            else:
                uni.tableType = "1"
                from Tables import FileTable

                self.Table = FileTable.FileTable(_parent)
예제 #33
0
def uninstallThisPlugin():
    isAlreadyUninstalled = False
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

    actionsValues = [{
        "regObject":
        "*",
        "key":
        "HamsiManager",
        "actions": [{
            "key": "copyPath"
        }, {
            "key": "emendFile"
        }, {
            "key": "hash"
        }, {
            "key": "textCorrector"
        }, {
            "key": "search"
        }]
    }, {
        "regObject":
        "Directory",
        "key":
        "HamsiManager",
        "actions": [{
            "key": "copyPath"
        }, {
            "key": "emendDirectory"
        }, {
            "key": "emendDirectoryWithContents"
        }, {
            "key": "pack"
        }, {
            "key": "checkIcon"
        }, {
            "key": "clearEmptyDirectories"
        }, {
            "key": "clearUnneededs"
        }, {
            "key": "clearIgnoreds"
        }, {
            "key": "fileTree"
        }, {
            "key": "removeOnlySubFiles"
        }, {
            "key": "clear"
        }, {
            "key": "search"
        }]
    }, {
        "regObject":
        "Directory\\Background",
        "key":
        "HamsiManager",
        "actions": [{
            "key": "copyPath"
        }, {
            "key": "emendDirectory"
        }, {
            "key": "emendDirectoryWithContents"
        }, {
            "key": "pack"
        }, {
            "key": "checkIcon"
        }, {
            "key": "clearEmptyDirectories"
        }, {
            "key": "clearUnneededs"
        }, {
            "key": "clearIgnoreds"
        }, {
            "key": "fileTree"
        }, {
            "key": "removeOnlySubFiles"
        }, {
            "key": "clear"
        }, {
            "key": "search"
        }]
    }, {
        "regObject":
        "*",
        "key":
        "HamsiManagerManage",
        "actions": [{
            "key": "Organize"
        }, {
            "key": "Organize0"
        }, {
            "key": "Organize1"
        }, {
            "key": "Organize2"
        }, {
            "key": "Organize3"
        }, {
            "key": "Organize9"
        }]
    }, {
        "regObject":
        "Directory",
        "key":
        "HamsiManagerManage",
        "actions": [{
            "key": "Organize"
        }, {
            "key": "Organize0"
        }, {
            "key": "Organize1"
        }, {
            "key": "Organize2"
        }, {
            "key": "Organize3"
        }, {
            "key": "Organize9"
        }]
    }, {
        "regObject":
        "Directory\\Background",
        "key":
        "HamsiManagerManage",
        "actions": [{
            "key": "Organize"
        }, {
            "key": "Organize0"
        }, {
            "key": "Organize1"
        }, {
            "key": "Organize2"
        }, {
            "key": "Organize3"
        }, {
            "key": "Organize9"
        }]
    }]
    rootReg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT)
    try:
        for regObject in actionsValues:
            mainKey = winreg.OpenKey(rootReg,
                                     regObject["regObject"] + "\\shell", 0,
                                     winreg.KEY_WRITE)
            try:
                winreg.DeleteKey(mainKey, regObject["key"])
            except:
                pass
            winreg.CloseKey(mainKey)
            mainContextMenusKey = winreg.OpenKey(
                rootReg, regObject["regObject"] + "\\ContextMenus", 0,
                winreg.KEY_WRITE)
            for action in regObject["actions"]:
                try:
                    actionKey = winreg.OpenKey(
                        mainContextMenusKey,
                        regObject["key"] + "\\Shell\\" + action["key"], 0,
                        winreg.KEY_WRITE)
                    try:
                        winreg.DeleteKey(actionKey, "command")
                    except:
                        pass
                    winreg.CloseKey(actionKey)
                    shellKey = winreg.OpenKey(mainContextMenusKey,
                                              regObject["key"] + "\\Shell", 0,
                                              winreg.KEY_WRITE)
                    try:
                        winreg.DeleteKey(shellKey, action["key"])
                    except:
                        pass
                    winreg.CloseKey(shellKey)
                except:
                    pass
            objectKey = winreg.OpenKey(mainContextMenusKey, regObject["key"],
                                       0, winreg.KEY_WRITE)
            try:
                winreg.DeleteKey(objectKey, "Shell")
            except:
                pass
            winreg.CloseKey(objectKey)
            try:
                winreg.DeleteKey(mainContextMenusKey, regObject["key"])
            except:
                pass
            winreg.CloseKey(mainContextMenusKey)
    except WindowsError:
        winreg.CloseKey(rootReg)
        cla, error, trbk = sys.exc_info()
        if str(error).find("[Error 5]") != -1:
            Dialogs.showError(
                translate("MyPlugins/Explorer_CM", "Access Denied"),
                translate(
                    "MyPlugins/Explorer_CM",
                    "Please run Hamsi Manager as Administrator and try again.")
            )
        elif str(error).find("[Error 2]") != -1:
            isAlreadyUninstalled = True  #Error : The system cannot find the file specified. Cause : Already Uninstalled
        else:
            ReportBug.ReportBug()
        return False
    winreg.CloseKey(rootReg)

    if isAlreadyUninstalled:
        return "isAlreadyUninstalled"
    return True
예제 #34
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()
예제 #35
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
예제 #36
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()
예제 #37
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
예제 #38
0
        def install(self):
            try:
                MApplication.processEvents()
                self.installationDirectory = str(
                    self.leInstallationDirectory.text())
                if len(self.installationDirectory) > 0:
                    if self.installationDirectory[-1] == fu.sep:
                        self.installationDirectory = self.installationDirectory[:
                                                                                -1]
                    if self.installationDirectory == fu.HamsiManagerDirectory:
                        self.pageNo -= 1
                        self.lblActions.setText("")
                        Dialogs.showError(
                            translate("Install",
                                      "The path you selected is not valid."),
                            translate(
                                "Install",
                                "The selected path is Hamsi Manager source directory.<br>Please choose a valid installation path."
                            ))
                    elif fu.isFile(self.installationDirectory) is False:
                        isMakeInstall = True
                        if fu.isDir(self.installationDirectory) is False:
                            self.lblActions.setText(
                                translate("Install",
                                          "Creating Installation Folder..."))
                            fu.makeDirs(self.installationDirectory)
                        elif len(fu.listDir(self.installationDirectory)) > 0:
                            currenctAnswer = Dialogs.askSpecial(
                                translate(
                                    "Install",
                                    "The Installation Path You Selected Is Not Empty."
                                ),
                                translate(
                                    "Install",
                                    "If the path you selected is an \"Hamsi Manager\" installation path, <b>I recommend you to delete the older files.</b><br>Do you want me to clear the installation path/folder for you?<br><b>Note: </b> Your personal settings are <b>never deleted</b>."
                                ), translate("Install", "Yes (Recommended)"),
                                translate("Install", "No (Overwrite)"),
                                translate("Install", "Cancel"))
                            if currenctAnswer == translate(
                                    "Install", "Yes (Recommended)"):
                                self.lblActions.setText(
                                    translate("Install",
                                              "Clearing Installation Path..."))
                                try:
                                    fu.removeFileOrDir(
                                        self.installationDirectory)
                                except:
                                    pass
                                fu.makeDirs(self.installationDirectory)
                                isMakeInstall = True
                            elif currenctAnswer == translate(
                                    "Install", "No (Overwrite)"):
                                isMakeInstall = True
                            else:
                                isMakeInstall = False
                        if isMakeInstall:
                            Settings.setUniversalSetting(
                                "pathOfInstallationDirectory",
                                self.installationDirectory)
                            directoriesAndFiles = fu.readDirectoryWithSubDirectories(
                                fu.HamsiManagerDirectory)
                            self.prgbState.setRange(0,
                                                    len(directoriesAndFiles))
                            self.lblActions.setText(
                                translate("Install",
                                          "Copying Files And Folders..."))
                            installFileName = Execute.findExecutableBaseName(
                                "HamsiManagerInstaller")
                            for fileNo, fileName in enumerate(
                                    directoriesAndFiles):
                                MApplication.processEvents()
                                newFileName = self.installationDirectory + fileName.replace(
                                    fu.HamsiManagerDirectory, "")
                                if fu.isDir(fileName) and fileName.find(
                                        ".svn") == -1:
                                    try:
                                        fu.makeDirs(newFileName)
                                    except:
                                        pass
                                elif (fu.isFile(fileName) and
                                      fu.getBaseName(fileName) != "install.py"
                                      and fu.getBaseName(fileName) !=
                                      installFileName
                                      and fileName.find(".svn") == -1):
                                    try:
                                        fu.copyFileOrDir(fileName, newFileName)
                                    except:
                                        fileContent = fu.readFromBinaryFile(
                                            fileName)
                                        fu.writeToBinaryFile(
                                            newFileName, fileContent)
                                self.prgbState.setValue(fileNo + 1)
                            self.pageNo += 1
                            MyConfigure.installKDE4Languages()
                        else:
                            self.pageNo -= 1
                    else:
                        self.pageNo -= 1
                        self.lblActions.setText("")
                        Dialogs.showError(
                            translate("Install",
                                      "The path you selected is not valid."),
                            translate(
                                "Install",
                                "The selected path points to a file not a folder.<br>Please choose a valid installation path."
                            ))
                else:
                    self.pageNo -= 1
                    self.lblActions.setText("")
                    Dialogs.showError(
                        translate("Install",
                                  "The path you selected is not valid."),
                        translate(
                            "Install",
                            "The selected path points to a file not a folder.<br>Please choose a valid installation path."
                        ))
                self.pageChanged(True)
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
예제 #39
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()
예제 #40
0
 def loadFinished(self, _bitti):
     try:
         if (_bitti):
             if self.isDownloading is False:
                 self.setFixedHeight(170)
                 self.prgbState.setVisible(False)
                 self.lblInfo.setVisible(True)
                 self.updateInformations = str(
                     self.wvWeb.page().mainFrame().toPlainText()).split(
                         "\n")
                 if len(self.updateInformations) != 0:
                     if self.updateInformations[0][0] == "V":
                         self.pbtnRemindMeLater.setVisible(False)
                         self.cbRemindMeLater.setVisible(False)
                         self.pbtnDownloadAndInstall.setVisible(False)
                         self.pbtnCheckForDeveloperVersion.setVisible(False)
                         uni.setMySetting("remindMeLaterForUpdate", "-1")
                         uni.setMySetting(
                             "remindMeLaterShowDateForUpdate",
                             datetime.now().strftime("%Y %m %d %H %M %S"))
                         uni.saveSettings()
                         try:
                             lastVersion = int(
                                 self.updateInformations[0].replace(
                                     "V", "").replace(".", ""))
                         except:
                             lastVersion = uni.intversion - 1
                         if lastVersion > uni.intversion:
                             self.pbtnDownloadAndInstall.setVisible(True)
                             self.pbtnRemindMeLater.setVisible(True)
                             self.cbRemindMeLater.setVisible(True)
                             details = ""
                             for detail in self.updateInformations[4:]:
                                 details += detail + "<br>"
                             self.lblInfo.setText(
                                 str(
                                     translate(
                                         "UpdateControl",
                                         "Version %s is available. Please download and install the new release.<br>"
                                         +
                                         "%s For detailed information: <a href='%s' target='_blank'>Hamsi Manager</a><br>You can download from <a href='%s' target='_blank'>Hamsi Manager %s</a>"
                                     )) %
                                 (self.updateInformations[0] +
                                  self.updateInformations[3], details,
                                  self.updateInformations[2],
                                  self.updateInformations[1],
                                  self.updateInformations[0]))
                             self.setFixedHeight(330)
                         elif lastVersion < uni.intversion:
                             self.pbtnDownloadAndInstall.setVisible(True)
                             if self.isNotInstall is False:
                                 self.pbtnDownloadAndInstall.setText(
                                     translate("UpdateControl",
                                               "Download and Install") +
                                     " (!)")
                             else:
                                 self.pbtnDownloadAndInstall.setText(
                                     translate("UpdateControl", "Download")
                                     + " (!)")
                             self.pbtnRemindMeLater.setVisible(True)
                             self.cbRemindMeLater.setVisible(True)
                             details = ""
                             for detail in self.updateInformations[4:]:
                                 details += detail + "<br>"
                             self.lblInfo.setText(
                                 str(
                                     str(
                                         translate(
                                             "UpdateControl",
                                             "Lastest stable version is %s. You currently are using the version for developers.You can continue to use the current version.<br>If you want a more accurate version, please download and install this version.<br>%s For detailed information: <a href='%s' target='_blank'>Hamsi Manager</a><br>You can download from <a href='%s' target='_blank'>Hamsi Manager %s</a>"
                                         )) %
                                     (self.updateInformations[0] +
                                      self.updateInformations[3], details,
                                      self.updateInformations[2],
                                      self.updateInformations[1],
                                      self.updateInformations[0])))
                             self.pbtnCancel.setText(
                                 translate("UpdateControl", "Ok"))
                             self.pbtnCheckForDeveloperVersion.setVisible(
                                 True)
                             self.setFixedHeight(330)
                         else:
                             self.lblInfo.setText(
                                 str(
                                     translate(
                                         "UpdateControl",
                                         "You are already using the latest release.<br>For detailed information: <a href='%s' target='_blank'>Hamsi Manager</a>"
                                     )) % (self.updateInformations[2]))
                             self.pbtnCancel.setText(
                                 translate("UpdateControl", "Ok"))
                         uni.setMySetting(
                             "lastUpdateControlDate",
                             datetime.now().strftime("%Y %m %d %H %M %S"))
                     else:
                         uni.setMySetting(
                             "lastUpdateControlDate",
                             datetime.now().strftime("%Y %m %d %H %M %S"))
                         Dialogs.showError(
                             translate("UpdateControl",
                                       "Cannot Fetch Release Information"),
                             translate(
                                 "UpdateControl",
                                 "Cannot fetch release information. Please retry later.<br>If you are constantly receiving this error, please visit \"http://hamsiapps.com/HamsiManager\"."
                             ))
                         self.close()
                 else:
                     uni.setMySetting(
                         "lastUpdateControlDate",
                         datetime.now().strftime("%Y %m %d %H %M %S"))
                     Dialogs.showError(
                         translate("UpdateControl",
                                   "Cannot Fetch Release Information"),
                         translate(
                             "UpdateControl",
                             "Cannot fetch release information. Please retry later.<br>If you are constantly receiving this error, please visit \"http://hamsiapps.com/HamsiManager\"."
                         ))
                     self.close()
             else:
                 self.lblInfo.setText(
                     translate("UpdateControl", "Download complete."))
         else:
             uni.setMySetting("lastUpdateControlDate",
                              datetime.now().strftime("%Y %m %d %H %M %S"))
             Dialogs.showError(
                 translate("UpdateControl",
                           "Cannot Fetch Release Information"),
                 translate(
                     "UpdateControl",
                     "Cannot fetch release information. Please retry later.<br>If you are constantly receiving this error, please visit \"http://hamsiapps.com/HamsiManager\"."
                 ))
             self.close()
     except:
         ReportBug.ReportBug()
예제 #41
0
def installThisPlugin():
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

    actionsValues = [{
        "regObject":
        "*",
        "key":
        "HamsiManager",
        "title":
        "Hamsi Manager",
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "copyPath",
            "title":
            translate("MyPlugins/Explorer_CM", "Copy Path To Clipboard"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "copyPath.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --copyPath \"%1\""
        }, {
            "key":
            "emendFile",
            "title":
            translate("MyPlugins/Explorer_CM", "Auto Emend File"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "emendFile.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --emendFile \"%1\""
        }, {
            "key":
            "hash",
            "title":
            translate("MyPlugins/Explorer_CM", "Hash Digest"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "hash.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --hash \"%1\""
        }, {
            "key":
            "textCorrector",
            "title":
            translate("MyPlugins/Explorer_CM", "Correct Content"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "textCorrector.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --textCorrector \"%1\""
        }, {
            "key":
            "search",
            "title":
            translate("MyPlugins/Explorer_CM", "Search"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "search.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --search \"%1\""
        }]
    }, {
        "regObject":
        "Directory",
        "key":
        "HamsiManager",
        "title":
        "Hamsi Manager",
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "copyPath",
            "title":
            translate("MyPlugins/Explorer_CM", "Copy Path To Clipboard"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "copyPath.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --copyPath \"%1\""
        }, {
            "key":
            "emendDirectory",
            "title":
            translate("MyPlugins/Explorer_CM", "Auto Emend Directory"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "emendDirectory.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --emendDirectory \"%1\""
        }, {
            "key":
            "emendDirectoryWithContents",
            "title":
            translate("MyPlugins/Explorer_CM",
                      "Auto Emend Directory (With Contents)"),
            "icon":
            fu.joinPath(fu.themePath, "Images",
                        "emendDirectoryWithContents.ico"),
            "command":
            executeCommandOfHamsiManager +
            " --qm --emendDirectoryWithContents \"%1\""
        }, {
            "key":
            "pack",
            "title":
            translate("MyPlugins/Explorer_CM", "Pack It"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "pack.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --pack \"%1\""
        }, {
            "key":
            "checkIcon",
            "title":
            translate("MyPlugins/Explorer_CM", "Check Directory Icon"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "checkIcon.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --checkIcon \"%1\""
        }, {
            "key":
            "clearEmptyDirectories",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Empty Directories"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearEmptyDirectories.ico"),
            "command":
            executeCommandOfHamsiManager +
            " --qm --clearEmptyDirectories \"%1\""
        }, {
            "key":
            "clearUnneededs",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Unneededs"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearUnneededs.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clearUnneededs \"%1\""
        }, {
            "key":
            "clearIgnoreds",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Ignoreds"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearIgnoreds.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clearIgnoreds \"%1\""
        }, {
            "key":
            "fileTree",
            "title":
            translate("MyPlugins/Explorer_CM", "Build File Tree"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "fileTree.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --fileTree \"%1\""
        }, {
            "key":
            "removeOnlySubFiles",
            "title":
            translate("MyPlugins/Explorer_CM", "Remove Sub Files"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "removeOnlySubFiles.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --removeOnlySubFiles \"%1\""
        }, {
            "key":
            "clear",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear It"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clear.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clear \"%1\""
        }, {
            "key":
            "search",
            "title":
            translate("MyPlugins/Explorer_CM", "Search"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "search.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --search \"%1\""
        }]
    }, {
        "regObject":
        "Directory\\Background",
        "key":
        "HamsiManager",
        "title":
        "Hamsi Manager",
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "copyPath",
            "title":
            translate("MyPlugins/Explorer_CM", "Copy Path To Clipboard"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "copyPath.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --copyPath \"%V\""
        }, {
            "key":
            "emendDirectory",
            "title":
            translate("MyPlugins/Explorer_CM", "Auto Emend Directory"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "emendDirectory.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --emendDirectory \"%V\""
        }, {
            "key":
            "emendDirectoryWithContents",
            "title":
            translate("MyPlugins/Explorer_CM",
                      "Auto Emend Directory (With Contents)"),
            "icon":
            fu.joinPath(fu.themePath, "Images",
                        "emendDirectoryWithContents.ico"),
            "command":
            executeCommandOfHamsiManager +
            " --qm --emendDirectoryWithContents \"%V\""
        }, {
            "key":
            "pack",
            "title":
            translate("MyPlugins/Explorer_CM", "Pack It"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "pack.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --pack \"%V\""
        }, {
            "key":
            "checkIcon",
            "title":
            translate("MyPlugins/Explorer_CM", "Check Directory Icon"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "checkIcon.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --checkIcon \"%V\""
        }, {
            "key":
            "clearEmptyDirectories",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Empty Directories"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearEmptyDirectories.ico"),
            "command":
            executeCommandOfHamsiManager +
            " --qm --clearEmptyDirectories \"%V\""
        }, {
            "key":
            "clearUnneededs",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Unneededs"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearUnneededs.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clearUnneededs \"%V\""
        }, {
            "key":
            "clearIgnoreds",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear Ignoreds"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clearIgnoreds.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clearIgnoreds \"%V\""
        }, {
            "key":
            "fileTree",
            "title":
            translate("MyPlugins/Explorer_CM", "Build File Tree"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "fileTree.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --fileTree \"%V\""
        }, {
            "key":
            "removeOnlySubFiles",
            "title":
            translate("MyPlugins/Explorer_CM", "Remove Sub Files"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "removeOnlySubFiles.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --removeOnlySubFiles \"%V\""
        }, {
            "key":
            "clear",
            "title":
            translate("MyPlugins/Explorer_CM", "Clear It"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "clear.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --clear \"%V\""
        }, {
            "key":
            "search",
            "title":
            translate("MyPlugins/Explorer_CM", "Search"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "search.ico"),
            "command":
            executeCommandOfHamsiManager + " --qm --search \"%V\""
        }]
    }, {
        "regObject":
        "*",
        "key":
        "HamsiManagerManage",
        "title":
        translate("MyPlugins/Explorer_CM", "Hamsi Manager ( Manage )"),
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "Organize",
            "title":
            translate("MyPlugins/Explorer_CM", "As Last Selected Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
            "command":
            executeCommandOfHamsiManager + " \"%1\""
        }, {
            "key":
            "Organize0",
            "title":
            translate("MyPlugins/Explorer_CM", "As Folder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "folderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 0 \"%1\""
        }, {
            "key":
            "Organize1",
            "title":
            translate("MyPlugins/Explorer_CM", "As File Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "fileTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 1 \"%1\""
        }, {
            "key":
            "Organize2",
            "title":
            translate("MyPlugins/Explorer_CM", "As Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "musicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 2 \"%1\""
        }, {
            "key":
            "Organize3",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 3 \"%1\""
        }, {
            "key":
            "Organize9",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderMusicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 9 \"%1\""
        }]
    }, {
        "regObject":
        "Directory",
        "key":
        "HamsiManagerManage",
        "title":
        translate("MyPlugins/Explorer_CM", "Hamsi Manager ( Manage )"),
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "Organize",
            "title":
            translate("MyPlugins/Explorer_CM", "As Last Selected Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
            "command":
            executeCommandOfHamsiManager + " \"%1\""
        }, {
            "key":
            "Organize0",
            "title":
            translate("MyPlugins/Explorer_CM", "As Folder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "folderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 0 \"%1\""
        }, {
            "key":
            "Organize1",
            "title":
            translate("MyPlugins/Explorer_CM", "As File Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "fileTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 1 \"%1\""
        }, {
            "key":
            "Organize2",
            "title":
            translate("MyPlugins/Explorer_CM", "As Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "musicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 2 \"%1\""
        }, {
            "key":
            "Organize3",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 3 \"%1\""
        }, {
            "key":
            "Organize9",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderMusicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 9 \"%1\""
        }]
    }, {
        "regObject":
        "Directory\\Background",
        "key":
        "HamsiManagerManage",
        "title":
        translate("MyPlugins/Explorer_CM", "Hamsi Manager ( Manage )"),
        "icon":
        fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
        "actions": [{
            "key":
            "Organize",
            "title":
            translate("MyPlugins/Explorer_CM", "As Last Selected Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico"),
            "command":
            executeCommandOfHamsiManager + " \"%1\""
        }, {
            "key":
            "Organize0",
            "title":
            translate("MyPlugins/Explorer_CM", "As Folder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "folderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 0 \"%1\""
        }, {
            "key":
            "Organize1",
            "title":
            translate("MyPlugins/Explorer_CM", "As File Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "fileTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 1 \"%1\""
        }, {
            "key":
            "Organize2",
            "title":
            translate("MyPlugins/Explorer_CM", "As Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "musicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 2 \"%1\""
        }, {
            "key":
            "Organize3",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 3 \"%1\""
        }, {
            "key":
            "Organize9",
            "title":
            translate("MyPlugins/Explorer_CM", "As Subfolder Music Table"),
            "icon":
            fu.joinPath(fu.themePath, "Images", "subFolderMusicTable.ico"),
            "command":
            executeCommandOfHamsiManager + " -t 9 \"%1\""
        }]
    }]
    rootReg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT)
    try:
        for regObject in actionsValues:
            mainKey = winreg.OpenKey(rootReg,
                                     regObject["regObject"] + "\\shell", 0,
                                     winreg.KEY_WRITE)
            winreg.CreateKey(mainKey, regObject["key"])
            hamsiKey = winreg.OpenKey(mainKey, regObject["key"], 0,
                                      winreg.KEY_WRITE)
            winreg.SetValueEx(
                hamsiKey, "MUIVerb", 0, winreg.REG_SZ,
                uni.trEncode(str(regObject["title"]),
                             fu.defaultFileSystemEncoding))
            winreg.SetValueEx(
                hamsiKey, "ExtendedSubCommandsKey", 0, winreg.REG_SZ,
                regObject["regObject"] + "\\ContextMenus\\" + regObject["key"])
            try:
                winreg.SetValueEx(
                    hamsiKey, "Icon", 0, winreg.REG_SZ,
                    uni.trEncode(str(regObject["icon"]),
                                 fu.defaultFileSystemEncoding))
            except:
                winreg.SetValueEx(hamsiKey, "Icon", 0, winreg.REG_SZ,
                                  str(regObject["icon"]))
            winreg.CreateKey(rootReg,
                             regObject["regObject"] + "\\ContextMenus")
            mainContextMenusKey = winreg.OpenKey(
                rootReg, regObject["regObject"] + "\\ContextMenus", 0,
                winreg.KEY_WRITE)
            for action in regObject["actions"]:
                if action["key"] == "checkIcon":
                    if uni.isActiveDirectoryCover is False:
                        continue
                winreg.CreateKey(
                    mainContextMenusKey,
                    regObject["key"] + "\\Shell\\" + action["key"])
                actionKey = winreg.OpenKey(
                    mainContextMenusKey,
                    regObject["key"] + "\\Shell\\" + action["key"], 0,
                    winreg.KEY_WRITE)
                try:
                    winreg.SetValueEx(
                        actionKey, "MUIVerb", 0, winreg.REG_SZ,
                        uni.trEncode(str(action["title"]),
                                     fu.defaultFileSystemEncoding))
                except:
                    winreg.SetValueEx(actionKey, "MUIVerb", 0, winreg.REG_SZ,
                                      str(action["title"]))
                try:
                    winreg.SetValueEx(
                        actionKey, "Icon", 0, winreg.REG_SZ,
                        uni.trEncode(str(action["icon"]),
                                     fu.defaultFileSystemEncoding))
                except:
                    winreg.SetValueEx(actionKey, "Icon", 0, winreg.REG_SZ,
                                      str(action["icon"]))
                winreg.CreateKey(
                    mainContextMenusKey, regObject["key"] + "\\Shell\\" +
                    action["key"] + "\\command")
                actionCommandKey = winreg.OpenKey(
                    mainContextMenusKey, regObject["key"] + "\\Shell\\" +
                    action["key"] + "\\command", 0, winreg.KEY_WRITE)
                try:
                    winreg.SetValueEx(
                        actionCommandKey, "", 0, winreg.REG_SZ,
                        uni.trEncode(str(action["command"]),
                                     fu.defaultFileSystemEncoding))
                except:
                    winreg.SetValueEx(actionCommandKey, "", 0, winreg.REG_SZ,
                                      str(action["command"]))
                winreg.CloseKey(actionCommandKey)
                winreg.CloseKey(actionKey)
            winreg.CloseKey(mainContextMenusKey)
            winreg.CloseKey(hamsiKey)
            winreg.CloseKey(mainKey)
    except WindowsError:
        winreg.CloseKey(rootReg)
        cla, error, trbk = sys.exc_info()
        if str(error).find("[Error 5]") != -1:
            Dialogs.showError(
                translate("MyPlugins/Explorer_CM", "Access Denied"),
                translate(
                    "MyPlugins/Explorer_CM",
                    "Please run Hamsi Manager as Administrator and try again.")
            )
        else:
            ReportBug.ReportBug()
        return False
    winreg.CloseKey(rootReg)

    #if isAlreadyInstalled:
    #    return "AlreadyInstalled"
    return True
예제 #42
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()
예제 #43
0
 def installPlugin(self, _pluginName, _isQuiet=False):
     isInstalled = False
     pluginModule = __import__(
         "MyPlugins." + _pluginName, globals(), locals(), [
             "pluginName", "pluginFiles", "pluginDirectory",
             "installThisPlugin", "setupDirectory", "pluginVersion"
         ], 0)
     if pluginModule.installThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             try:
                 fu.makeDirs(pluginModule.setupDirectory)
             except:
                 pass
             for pluginFile in pluginModule.pluginFiles:
                 fu.copyOrChange(
                     fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins",
                                 _pluginName, pluginFile),
                     fu.joinPath(pluginModule.setupDirectory, pluginFile),
                     "file", "only", True)
                 MyConfigure.reConfigureFile(
                     fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isInstalled = True
         else:
             oldFilePath = fu.joinPath(fu.HamsiManagerDirectory,
                                       "MyPlugins", _pluginName,
                                       pluginModule.pluginDirectory)
             newFilePath = fu.copyOrChange(
                 oldFilePath,
                 fu.joinPath(pluginModule.setupDirectory,
                             pluginModule.pluginDirectory), "directory",
                 "only", True)
             if newFilePath != oldFilePath:
                 isInstalled = True
     else:
         isInstalled = pluginModule.installThisPlugin()
     if isInstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName),
                                      str(pluginModule.pluginVersion))
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins", "Plug-in Installation Is Complete"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" is installed on your system.")) %
                 (pluginModule.pluginName))
     elif isInstalled == "AlreadyInstalled":
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins", "Plug-in Already Installed"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" already installed on your system."))
                 % (pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(
                 translate("MyPlugins", "Plug-in Installation Failed"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" failed to install on your system."))
                 % (pluginModule.pluginName))
예제 #44
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
예제 #45
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."))
예제 #46
0
def checkAndGetDB(_isNoAlertIfSuccessfully=True, _isReCheck=False):
    global isCheckAgain
    if _isReCheck:
        isCheckAgain = True
    if checkAmarok():
        try:
            db = connectAndGetDB()
            if db is not None:
                if isCheckAgain:
                    db.query(
                        "SELECT version FROM admin WHERE component='DB_VERSION'"
                    )
                    rows = db.store_result().fetch_row(1)
                    dbVersion = int(rows[0][0])
                    if dbVersion not in availableDBVersions:
                        answer = Dialogs.ask(
                            translate("Amarok",
                                      "Your Amarok DB Version Is Not Tested"),
                            str(
                                translate(
                                    "Amarok",
                                    "Your Amarok DB version is not tested. We don`t suggest but you can use at your own risk. Are you sure you want to use?"
                                    "<br>Your Amarok DB Version:%s"
                                    "<br>Tested Amarok DB Versions:%s")) %
                            (str(dbVersion), str(availableDBVersions)))
                        if answer is not Dialogs.Yes:
                            return None
                    if _isNoAlertIfSuccessfully is False:
                        Dialogs.show(
                            translate("Amarok", "Connected To Database"),
                            str(
                                translate("Amarok",
                                          "Connected successfully to \"%s\""))
                            % uni.MySettings["amarokDBDB"])
                isCheckAgain = False
                return db
            else:
                Dialogs.showError(
                    translate("Amarok", "Amarok Database Is Not Usable"),
                    translate("Amarok", "Amarok database is not accessible."))
            return None
        except:
            cla, currentError, trbk = sys.exc_info()
            if str(currentError).find("Unknown MySQL server host") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Unknown MySQL server host \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (uni.MySettings["amarokDBHost"], str(currentError)))
            elif str(currentError).find("Access denied for user") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Access denied for user \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (uni.MySettings["amarokDBUser"], str(currentError)))
            elif str(currentError).find("Unknown database") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Unknown database \"%s\" <br><b>Details</b> : %s"))
                    % (uni.MySettings["amarokDBDB"], str(currentError)))
            elif str(currentError).find(
                    "Can't connect to local MySQL server through socket"
            ) != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Can't connect to local MySQL server through socket \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (str(currentError).replace(
                        "(2002, \"Can't connect to local MySQL server through socket '",
                        "").replace("' (2)\")", ""), str(currentError)))
            else:
                ReportBug.ReportBug()
            return None
    else:
        if isLoadedMysql is False:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate(
                    "Amarok",
                    "\"python-mysql\" (MySQLdb / _mysql) named module is not installed on your system. Please install this module and try again."
                ))
        elif uni.isAvailableKDE4() is False:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok",
                          "Please open user session with KDE4 once."))
        else:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok", "Please run Amarok once."))
        return None