Example #1
0
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(
                     ";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(
                     pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[
                         pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(
                                     pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[
                                     pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(
                                     pathToSearch, -1, "return",
                                     "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[
                                     pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
Example #2
0
 def isSendMySettings(self):
     try:
         currentText = str(self.teIdea.toHtml())
         if self.cckbIsSendMySettings.checkState() == Mt.Checked:
             settingText = "<br><br>"
             for keyName in uni.MySettings:
                 if uni.willNotReportSettings.count(keyName) == 0:
                     settingText += "<b>" + str(keyName) + " :</b> " + str(
                         uni.MySettings[keyName]) + "<br>"
             self.teIdea.setHtml(
                 str(currentText +
                     "<br>----------------------////////----------------------<br><br><b>"
                     + str(
                         translate(
                             "SuggestIdea",
                             "Note : You can check and delete your personal informations."
                         )) + "</b>" + settingText))
         else:
             currentText = currentText.split(
                 "----------------------////////----------------------")[0]
             self.teIdea.setHtml(str(currentText))
     except:
         ReportBug.ReportBug()
Example #3
0
 def clear(self):
     try:
         answer = Dialogs.ask(
             translate("RecordsForm", "Are You Sure?"),
             translate("RecordsForm",
                       "Are you sure you want to remove this record file?"))
         if answer == Dialogs.Yes:
             if self.cbRecordsList.currentIndex() == 0:
                 Records.clearRecords()
             else:
                 recordFilePath = self.recordsList[
                     self.cbRecordsList.currentIndex()]
                 fu.removeFile(
                     fu.joinPath(fu.oldRecordsDirectoryPath,
                                 recordFilePath))
                 self.recordsList = [
                     translate("RecordsForm", "Current Records")
                 ] + Records.getBackupRecordsList()
                 self.cbRecordsList.clear()
                 self.cbRecordsList.addItems(self.recordsList)
             self.setRecordsFile()
     except:
         ReportBug.ReportBug()
Example #4
0
    def willDownload(self, _request):
        try:
            defaultFileName = str(
                MFileInfo(str(trStr(_request.url()))).fileName())
            fileDialogTitle = translate(
                "UpdateControl",
                "You Can Click Cancel To Update Without Saving The Package.")
            if self.isNotInstall:
                fileDialogTitle = translate(
                    "UpdateControl", "Save New Version Of Hamsi Manager")
            fileName = Dialogs.getSaveFileName(
                fileDialogTitle,
                fu.joinPath(fu.getDirName(fu.HamsiManagerDirectory),
                            defaultFileName))
            if self.isNotInstall is False or fileName is not None:
                if fileName is None:
                    import random

                    fileName = fu.joinPath(
                        fu.getTempDir(), defaultFileName[:-7] + "-" +
                        str(random.randrange(0, 1000000)) +
                        defaultFileName[-7:])
                self.pbtnDownloadAndInstall.setEnabled(False)
                newRequest = _request
                newRequest.setAttribute(MNetworkRequest.User,
                                        trQVariant(fileName))
                networkManager = self.wvWeb.page().networkAccessManager()
                reply = networkManager.get(newRequest)
                self.isFileExist = True
                self.connect(reply, SIGNAL("downloadProgress(qint64,qint64)"),
                             self.downloading)
                self.connect(reply, SIGNAL("finished()"), self.downloaded)
                self.connect(reply,
                             SIGNAL("error(QNetworkReply::NetworkError)"),
                             self.errorOccurred)
        except:
            ReportBug.ReportBug()
Example #5
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()
Example #6
0
        def finish(self):
            try:
                if uni.isRunningAsRoot():
                    executableLink = Settings.getUniversalSetting(
                        "HamsiManagerExecutableLinkPath",
                        str("/usr/bin/hamsi"))
                    if fu.isFile(executableLink) or fu.isLink(executableLink):
                        fu.removeFileOrDir(executableLink)
                else:
                    desktopPath = uni.getUserDesktopPath()
                    if uni.isWindows:
                        if fu.isFile(
                                fu.joinPath(desktopPath, "Hamsi Manager.lnk")):
                            fu.removeFileOrDir(
                                fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                    else:
                        if fu.isFile(
                                fu.joinPath(desktopPath,
                                            "HamsiManager.desktop")):
                            fu.removeFileOrDir(
                                fu.joinPath(desktopPath,
                                            "HamsiManager.desktop"))
                    if fu.isFile(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop")):
                        fu.removeFileOrDir(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop"))
                self.isUninstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
Example #7
0
def changePaths(_values, _type="auto"):
    uni.startThreadAction()
    allItemNumber = len(_values)
    for valueNo, value in enumerate(_values):
        isContinueThreadAction = uni.isContinueThreadAction()
        if isContinueThreadAction:
            try:
                if _type == "file" or (_type == "auto"
                                       and fu.isFile(value["newPath"])):
                    Commands.changeFilePath(value["oldPath"], value["newPath"])
                else:
                    Commands.changeDirectoryPath(value["oldPath"],
                                                 value["newPath"])
            except:
                ReportBug.ReportBug()
        else:
            allItemNumber = valueNo + 1
        Dialogs.showState(
            translate("Amarok/Operations",
                      "Changing Paths In Amarok Database"), valueNo + 1,
            allItemNumber, True)
        if isContinueThreadAction is False:
            break
    uni.finishThreadAction()
Example #8
0
 def correct(self):
     try:
         self.correctTable()
     except:
         ReportBug.ReportBug()
Example #9
0
    def refreshTable(self, _path):
        self.values = []
        allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(
            _path, int(uni.MySettings["CoversSubDirectoryDeep"]), "directory",
            uni.getBoolValue("isShowHiddensInCoverTable"))
        allItemNumber = len(allFilesAndDirectories)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for dirName in allFilesAndDirectories:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(
                            dirName, False, True) and fu.isReadableFileOrDir(
                                fu.joinPath(dirName, ".directory"), False,
                                True):
                        content = {}
                        content["path"] = dirName
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) +
                            str(fu.getDirName(dirName)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(dirName)

                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(
                            dirName)
                        selectedName = None
                        if isCorrectedFileContent and currentCover is not None:
                            selectedName = fu.getBaseName(currentCover)
                        sourceCover = fu.getFirstImageInDirectory(
                            dirName, selectedName, False, False)
                        if currentCover is None:
                            currentCover = ""
                        if sourceCover is None:
                            sourceCover = ""
                        else:
                            sourceCover = fu.joinPath(dirName, sourceCover)
                        content["currentCover"] = (currentCover)
                        content["sourceCover"] = (sourceCover)
                        content["destinationCover"] = (sourceCover)
                        content["isCorrectedFileContent"] = (
                            isCorrectedFileContent)
                        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"], "directory")
                        self.createItem(rowNo, "baseName", newBaseName,
                                        self.values[rowNo]["baseName"])

                        newCurrentCover = str(
                            self.values[rowNo]["currentCover"])
                        newCurrentCover = newCurrentCover.replace(
                            self.values[rowNo]["path"], ".")
                        itemCurrentCover = self.createItem(
                            rowNo, "currentCover", newCurrentCover,
                            newCurrentCover, True)
                        if self.values[rowNo][
                                "isCorrectedFileContent"] is False:
                            itemCurrentCover.setBackground(
                                MBrush(MColor(255, 163, 163)))

                        newSourceCover = str(self.values[rowNo]["sourceCover"])
                        newSourceCover = newSourceCover.replace(
                            self.values[rowNo]["path"], ".")
                        oldSourceCover = self.values[rowNo]["currentCover"]
                        oldSourceCover = oldSourceCover.replace(
                            self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "sourceCover", newSourceCover,
                                        oldSourceCover)

                        newDestinationCover = self.values[rowNo][
                            "destinationCover"]
                        newDestinationCover = newDestinationCover.replace(
                            self.values[rowNo]["path"], ".")
                        newDestinationCover = Organizer.emend(
                            newDestinationCover, "file")
                        oldDestinationCover = self.values[rowNo][
                            "currentCover"]
                        oldDestinationCover = oldDestinationCover.replace(
                            self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "destinationCover",
                                        newDestinationCover,
                                        oldDestinationCover)
                        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
Example #10
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(
         translate("FileUtils/Covers", "Writing Cover Informations"), 0,
         allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                           False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover")
                                 or self.isChangeableItem(
                                     rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo][
                                 "destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(
                                     self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(
                                     rowNo, "destinationCover"):
                                 destinationPath = str(
                                     self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath
                                     or sourcePath != destinationPath
                                     or str(self.item(rowNo, 2).text()) !=
                                     destinationPath
                                 ) or (str(self.item(rowNo, 2).text()) !=
                                       self.values[rowNo]["currentCover"]
                                       and
                                       (str(self.item(rowNo, 2).text()) !=
                                        sourcePath
                                        and str(self.item(rowNo, 2).text())
                                        != destinationPath)):
                                 if str(self.item(rowNo,
                                                  3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(
                                         sourcePath,
                                         self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(
                                         sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(
                                                 destinationPath,
                                                 self.values[rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(
                                                     sourcePath,
                                                     destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(
                                             self.values[rowNo]["path"],
                                             destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(
                                         self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo,
                                                  "baseNameOfDirectory",
                                                  baseNameOfDirectory):
                             baseNameOfDirectory = str(
                                 self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(
                                     fu.getDirName(
                                         self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(
                                         rowNo - 1,
                                         0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName",
                                                  baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(
                                 fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(
                             self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(
                                 oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue(
                                         "isClearEmptyDirectoriesWhenFileMove"
                                 ):
                                     fu.checkEmptyDirectories(
                                         oldDirName, True, True,
                                         uni.getBoolValue(
                                             "isAutoCleanSubFolderWhenFileMove"
                                         ))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(
             translate("FileUtils/Covers", "Writing Cover Informations"),
             rowNo + 1, allItemNumber, True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(
             oldAndNewPathValues
     ) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath,
                                           "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(
                 translate("FileUtils/Musics", "There Are More Files"),
                 str(
                     translate(
                         "FileUtils/Musics",
                         "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\""
                     )) % (Organizer.getLink(currentDirectoryPath),
                           Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(
                                 fu.joinPath(currentDirectoryPath,
                                             fileName))
                             newFilePath = fu.getRealPath(
                                 fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths[
                                     "newPath"] = fu.moveOrChange(
                                         oldFilePath, newFilePath,
                                         fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(
                                         oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(
                         translate(
                             "FileUtils/Covers",
                             "Writing Directory And File Informations"),
                         rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(
                         currentDirectoryPath, True, True,
                         uni.getBoolValue(
                             "isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and
                         uni.getBoolValue("isActiveAutoMakeIconToDirectory")
                         and uni.getBoolValue(
                             "isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
Example #11
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
Example #12
0
 def goUp(self):
     try:
         self.goTo(str(fu.getDirName(self.currentDirectory)))
     except:
         ReportBug.ReportBug()
Example #13
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        if uni.isActiveAmarok and uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(str(self.values[rowNo]["path"]).replace(
                                fu.joinPath(str(self.values[rowNo]["baseNameOfDirectory"]),
                                            str(self.values[rowNo]["baseName"])), ""),
                                                      baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                                    if (uni.isActiveDirectoryCover and
                                            uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                                        fu.checkIcon(oldDirName)
                                        fu.checkIcon(fu.getDirName(oldAndNewPaths["newPath"]))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), rowNo + 1, allItemNumber,
                              True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if (uni.isActiveAmarok and
                uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB") and
                len(oldAndNewPathValues) > 0):
            import Amarok
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues, "file")
        return True
Example #14
0
    def refreshTable(self, _path):
        self.values = []
        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

                directoriesAndValues = Operations.getDirectoriesAndValues(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(
                    translate("AmarokMusicTable",
                              "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if directoriesAndValues is not None:
                        allItemNumber = len(directoriesAndValues)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for dirPath, dirRow in directoriesAndValues.items():
                            isContinueThreadAction = uni.isContinueThreadAction(
                            )
                            if isContinueThreadAction:
                                try:
                                    if fu.isReadableFileOrDir(
                                            dirPath, False,
                                            True) and fu.isReadableFileOrDir(
                                                fu.joinPath(
                                                    dirPath, ".directory"),
                                                False, True):
                                        content = {}
                                        content["path"] = dirPath
                                        content[
                                            "pathOfParentDirectory"] = fu.getDirName(
                                                dirPath)
                                        content["baseName"] = fu.getBaseName(
                                            dirPath)
                                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(
                                            dirPath)
                                        if currentCover is None:
                                            currentCover = ""
                                        content["currentCover"] = (
                                            currentCover)
                                        content["sourceCover"] = (
                                            dirRow["coverPath"][0].replace(
                                                dirPath, "."))
                                        content["destinationCover"] = (
                                            "./" + Organizer.getIconName(
                                                dirRow["artist"][0],
                                                dirRow["album"][0],
                                                dirRow["genre"][0],
                                                dirRow["year"][0]))
                                        content["flagColor"] = {}
                                        if isCorrectedFileContent is False:
                                            content["flagColor"][
                                                "currentCover"] = 255, 163, 163
                                        if fu.isFile(content["sourceCover"]
                                                     ) is False:
                                            content["flagColor"][
                                                "sourceCover"] = 255, 163, 163
                                        self.values.append(content)

                                        newPathOfParentDirectory = Organizer.emend(
                                            self.values[rowNo]
                                            ["pathOfParentDirectory"],
                                            "directory")
                                        self.createItem(
                                            rowNo, "pathOfParentDirectory",
                                            newPathOfParentDirectory,
                                            self.values[rowNo]
                                            ["pathOfParentDirectory"])

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

                                        newCurrentCover = fu.getShortPath(
                                            self.values[rowNo]["currentCover"],
                                            self.values[rowNo]["path"])
                                        itemCurrentCover = self.createItem(
                                            rowNo, "currentCover",
                                            newCurrentCover, newCurrentCover,
                                            True)
                                        self.setItemColor(
                                            itemCurrentCover, rowNo, 2,
                                            "currentCover")

                                        newSourceCover = fu.getShortPath(
                                            self.values[rowNo]["sourceCover"],
                                            self.values[rowNo]["path"])
                                        itemSourceCover = self.createItem(
                                            rowNo, "sourceCover",
                                            newSourceCover,
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["currentCover"],
                                                self.values[rowNo]["path"]))
                                        self.setItemColor(
                                            itemSourceCover, rowNo, 3,
                                            "sourceCover")

                                        newDestinationCover = Organizer.emend(
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["destinationCover"],
                                                self.values[rowNo]["path"]),
                                            "file")
                                        itemDestinationCover = self.createItem(
                                            rowNo, "destinationCover",
                                            newDestinationCover,
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["currentCover"],
                                                self.values[rowNo]["path"]))
                                        self.setItemColor(
                                            itemDestinationCover, rowNo, 4,
                                            "destinationCover")
                                        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
Example #15
0
                ReportBug.ReportBug()

    if uni.isRunningAsRoot() is False and uni.isRunableAsRoot():
        answer = Dialogs.askSpecial(
            translate("Uninstall", "Are You Want To Run As Root?"),
            translate(
                "Uninstall",
                "Hamsi Manager Uninstaller is running with user privileges.<br>Do you want to run Hamsi Manager Uninstaller with root rights?"
            ), translate("Uninstall", "Yes"),
            translate("Uninstall", "No (Continue as is)"), None)
        if answer == translate("Uninstall", "Yes"):
            NewApp = Execute.executeAsRootWithThread([],
                                                     "HamsiManagerUninstaller")
            sys.exit()
    try:
        MainWidget = Main()
        MainWidget.setWindowTitle(
            translate("Uninstall", "Hamsi Manager Uninstaller") + " " +
            uni.version)
        MainWidget.setGeometry(300, 300, 650, 350)
        MainWidget.show()
        uni.isStartingSuccessfully = True
    except:
        from Core import ReportBug

        ReportBug.ReportBug()
    sys.exit(HamsiManagerApp.exec_())
else:
    sys.exit()
Example #16
0
    def closeEvent(self, _event):
        try:
            if uni.isRaisedAnError is False:
                if uni.isContinueThreadAction():
                    uni.cancelThreadAction()
                    _event.ignore()
            uni.isStartedCloseProcess = True
            uni.printForDevelopers("Started closeEvent")
            MApplication.setQuitOnLastWindowClosed(True)
            try:
                self.PlayerBar.MusicPlayer.stop()
            except:
                pass
            Details.closeAllDialogs()
            uni.printForDevelopers("Closed Dialogs")
            if uni.isRaisedAnError is False:
                if self.Table.checkUnSavedValues() is False:
                    uni.isStartedCloseProcess = False
                    uni.printForDevelopers("Close ignored")
                    _event.ignore()
            uni.printForDevelopers("Before self.doBeforeCloseProcesses")
            if self.doBeforeCloseProcesses() is False:
                _event.ignore()
                return None
            uni.printForDevelopers("After self.doBeforeCloseProcesses")
            if isActivePyKDE4:
                uni.printForDevelopers("Before Save KDE Configs")
                kconf = MGlobal.config()
                kconfGroup = MConfigGroup(kconf, "DirectoryOperator")
                self.FileManager.dirOperator.writeConfig(kconfGroup)
                self.FileManager.actCollection.writeSettings(kconfGroup)
                uni.printForDevelopers("After Save KDE Configs")
            uni.printForDevelopers("Before Save Configs")
            uni.setMySetting(self.Table.hiddenTableColumnsSettingKey,
                             self.Table.hiddenTableColumns)
            Bars.setAllBarsStyleToMySettings()
            Records.setRecordType(1)
            fu.writeToBinaryFile(
                fu.joinPath(fu.pathOfSettingsDirectory, "LastState"), self.saveState())
            Records.restoreRecordType()
            geometry = [self.geometry().x(), self.geometry().y(), self.geometry().width(),
                        self.geometry().height()]
            uni.setMySetting("MainWindowGeometries", geometry)
            uni.setMySetting("lastDirectory", self.FileManager.currentDirectory)
            uni.setMySetting("isMainWindowMaximized", self.isMaximized())
            uni.setMySetting("isShowAdvancedSelections", self.SpecialTools.isShowAdvancedSelections)
            uni.setMySetting("tableType", uni.tableType)
            uni.setMySetting("activeTabNoOfSpecialTools", self.SpecialTools.tabwTabs.currentIndex())
            uni.saveSettings()
            Settings.saveUniversalSettings()
            if uni.isActiveAmarok and uni.getBoolValue("amarokIsUseHost") is False:
                import Amarok

                uni.printForDevelopers("Before Amarok.stopEmbeddedDB")
                Amarok.stopEmbeddedDB()
                uni.printForDevelopers("After Amarok.stopEmbeddedDB")
            uni.printForDevelopers("After Save Configs")
            uni.printForDevelopers("Before self.doAfterCloseProcesses")
            self.doAfterCloseProcesses()
            uni.printForDevelopers("After self.doAfterCloseProcesses")
        except:
            if ReportBug.isClose is False:
                ReportBug.ReportBug()
                _event.ignore()
Example #17
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        startRowNo, rowStep = 0, 1
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(
            translate("FileUtils/Covers", "Writing Cover Informations"), 0,
            allItemNumber, True)
        for rowNo in range(startRowNo, self.rowCount(), rowStep):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                              False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            pathOfParentDirectory = str(
                                self.values[rowNo]["pathOfParentDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(
                                    rowNo,
                                    "sourceCover") or self.isChangeableItem(
                                        rowNo, "destinationCover"):
                                sourcePath = self.values[rowNo]["sourceCover"]
                                destinationPath = self.values[rowNo][
                                    "destinationCover"]
                                if self.isChangeableItem(rowNo, "sourceCover"):
                                    sourcePath = str(
                                        self.item(rowNo, 3).text()).strip()
                                if self.isChangeableItem(
                                        rowNo, "destinationCover"):
                                    destinationPath = str(
                                        self.item(rowNo, 4).text()).strip()
                                if (str(self.item(rowNo,
                                                  2).text()) != sourcePath
                                        or sourcePath != destinationPath
                                        or str(self.item(rowNo, 2).text()) !=
                                        destinationPath
                                    ) or (str(self.item(rowNo, 2).text()) !=
                                          self.values[rowNo]["currentCover"]
                                          and
                                          (str(self.item(rowNo, 2).text()) !=
                                           sourcePath
                                           and str(self.item(rowNo, 2).text())
                                           != destinationPath)):
                                    if str(self.item(rowNo,
                                                     3).text()).strip() != "":
                                        sourcePath = fu.getRealPath(
                                            sourcePath,
                                            self.values[rowNo]["path"])
                                        sourcePath = fu.checkSource(
                                            sourcePath, "file")
                                        if sourcePath is not None:
                                            if destinationPath != "":
                                                destinationPath = fu.getRealPath(
                                                    destinationPath,
                                                    self.values[rowNo]["path"])
                                                if sourcePath != destinationPath:
                                                    destinationPath = fu.moveOrChange(
                                                        sourcePath,
                                                        destinationPath)
                                            else:
                                                destinationPath = sourcePath
                                            fu.setIconToDirectory(
                                                self.values[rowNo]["path"],
                                                destinationPath)
                                            self.changedValueNumber += 1
                                    else:
                                        fu.setIconToDirectory(
                                            self.values[rowNo]["path"], "")
                                        self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo,
                                                     "baseNameOfDirectory",
                                                     pathOfParentDirectory):
                                pathOfParentDirectory = 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.joinPath(pathOfParentDirectory,
                                                      baseName)
                            oldFilePath = fu.getRealPath(
                                self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(
                                    oldFilePath, newFilePath, "directory")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue(
                                            "isClearEmptyDirectoriesWhenFileMove"
                                    ):
                                        fu.checkEmptyDirectories(
                                            oldDirName, True, True,
                                            uni.getBoolValue(
                                                "isAutoCleanSubFolderWhenFileMove"
                                            ))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Covers", "Writing Cover Informations"),
                rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if len(oldAndNewPathValues) > 0:
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues)
        return True
Example #18
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        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):
                        isWritableFileOrDir = fu.isFile(
                            self.values[rowNo]
                            ["path"]) and fu.isWritableFileOrDir(
                                self.values[rowNo]["path"], False, True)
                        if isWritableFileOrDir:
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                    else:
                        changingTag = {"path": self.values[rowNo]["path"]}
                        isWritableFileOrDir = fu.isFile(
                            self.values[rowNo]
                            ["path"]) and fu.isWritableFileOrDir(
                                self.values[rowNo]["path"], False, True)
                        isSetTagOfFile = False
                        if isWritableFileOrDir:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if Amarok.getSelectedTagTargetType(
                                    "AmarokMusicTable").find("To File") > -1:
                                isSetTagOfFile = True
                                tagger = Taggers.getTagger()
                                tagger.loadFileForWrite(
                                    self.values[rowNo]["path"])
                        if self.isChangeableItem(rowNo, "artist"):
                            value = str(self.item(rowNo, 2).text())
                            if isSetTagOfFile: tagger.setArtist(value)
                            changingTag["artist"] = value
                            Records.add(str(translate("MusicTable", "Artist")),
                                        str(self.values[rowNo]["artist"]),
                                        value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "title"):
                            value = str(self.item(rowNo, 3).text())
                            if isSetTagOfFile: tagger.setTitle(value)
                            changingTag["title"] = value
                            Records.add(str(translate("MusicTable", "Title")),
                                        str(self.values[rowNo]["title"]),
                                        value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "album"):
                            value = str(self.item(rowNo, 4).text())
                            if isSetTagOfFile: tagger.setAlbum(value)
                            changingTag["album"] = value
                            Records.add(str(translate("MusicTable", "Album")),
                                        str(self.values[rowNo]["album"]),
                                        value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "albumArtist"):
                            value = str(self.item(rowNo, 5).text())
                            if isSetTagOfFile: tagger.setAlbumArtist(value)
                            changingTag["albumArtist"] = value
                            Records.add(
                                str(translate("MusicTable", "Album Artist")),
                                str(self.values[rowNo]["albumArtist"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "trackNum"):
                            value = str(self.item(rowNo, 6).text())
                            if isSetTagOfFile: tagger.setTrackNum(value)
                            changingTag["trackNum"] = value
                            Records.add(
                                str(translate("MusicTable", "Track No")),
                                str(self.values[rowNo]["trackNum"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "year"):
                            value = str(self.item(rowNo, 7).text())
                            if isSetTagOfFile: tagger.setDate(value)
                            changingTag["year"] = value
                            Records.add(str(translate("MusicTable", "Year")),
                                        str(self.values[rowNo]["year"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "genre"):
                            value = str(self.item(rowNo, 8).text())
                            if isSetTagOfFile: tagger.setGenre(value)
                            changingTag["genre"] = value
                            Records.add(str(translate("MusicTable", "Genre")),
                                        str(self.values[rowNo]["genre"]),
                                        value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "firstComment"):
                            value = str(self.item(rowNo, 9).text())
                            if isSetTagOfFile: tagger.setFirstComment(value)
                            changingTag["firstComment"] = value
                            Records.add(
                                str(translate("MusicTable", "Comment")),
                                str(self.values[rowNo]["firstComment"]), value)
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "firstLyrics"):
                            value = str(self.item(rowNo, 10).text())
                            if isSetTagOfFile: tagger.setFirstLyrics(value)
                            changingTag["firstLyrics"] = value
                            Records.add(str(translate("MusicTable", "Lyrics")),
                                        str(self.values[rowNo]["firstLyrics"]),
                                        value)
                            self.changedValueNumber += 1
                        if len(changingTag) > 1:
                            changingTags.append(changingTag)
                        if isWritableFileOrDir:
                            if isSetTagOfFile:
                                tagger.update()
                            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.joinPath(
                                fu.getDirName(
                                    fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(
                                self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(
                                    oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue(
                                            "isClearEmptyDirectoriesWhenFileMove"
                                    ):
                                        fu.checkEmptyDirectories(
                                            oldDirName, True, True,
                                            uni.getBoolValue(
                                                "isAutoCleanSubFolderWhenFileMove"
                                            ))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Musics",
                          "Writing Music Tags And Informations"), rowNo + 1,
                allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        from Amarok import Operations

        if Amarok.getSelectedTagTargetType("AmarokMusicTable").find(
                "Amarok") > -1:
            Operations.changeTags(changingTags)
        if len(oldAndNewPathValues) > 0:
            Operations.changePaths(oldAndNewPathValues, "file")
        return True
Example #19
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
Example #20
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()
Example #21
0
 def cellClicked(self, _rowNo, _columnNo):
     try:
         self.cellClickedTable(_rowNo, _columnNo)
         # self.editItem(self.item(_row, _column)) # TODO: make this an option
     except:
         ReportBug.ReportBug()
Example #22
0
 def stopReadOnlyEmbeddedDB(self):
     try:
         stopReadOnlyEmbeddedDB(False)
         self.checkRunState()
     except:
         ReportBug.ReportBug()
Example #23
0
 def cellDoubleClicked(self, _rowNo, _columnNo):
     try:
         self.cellDoubleClickedTable(_rowNo, _columnNo)
     except:
         ReportBug.ReportBug()
Example #24
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()
Example #25
0
def changeArtistValues(_values):
    uni.startThreadAction()
    allItemNumber = len(_values)
    Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"), 0,
                      allItemNumber, True)
    for x, value in enumerate(_values):
        isContinueThreadAction = uni.isContinueThreadAction()
        if isContinueThreadAction:
            try:
                musicFilePathAndArtist = Commands.changeArtistValue(value)
                if musicFilePathAndArtist is not None:
                    artistName = musicFilePathAndArtist[0]
                    for musicFilePath in musicFilePathAndArtist[1]:
                        if fu.isWritableFileOrDir(musicFilePath, False, True):
                            Records.add(
                                str(
                                    translate("Amarok/Operations",
                                              "File will be updated")),
                                str(musicFilePath))
                            currentArtistName = ""
                            tagger = Taggers.getTagger()
                            if tagger is not None:
                                try:
                                    tagger.loadFileForWrite(musicFilePath)
                                    currentArtistName = tagger.getArtist()
                                except:
                                    tagger.loadFileForWrite(musicFilePath)
                                tagger.setArtist(artistName)
                                tagger.update()
                                Records.add(
                                    str(
                                        translate("Amarok/Operations",
                                                  "Artist")),
                                    str(currentArtistName), artistName)
                    for musicFilePath in musicFilePathAndArtist[2]:
                        if fu.isWritableFileOrDir(musicFilePath, False, True):
                            Records.add(
                                str(
                                    translate("Amarok/Operations",
                                              "File will be updated")),
                                str(musicFilePath))
                            currentArtistName = ""
                            tagger = Taggers.getTagger()
                            if tagger is not None:
                                try:
                                    tagger.loadFileForWrite(musicFilePath)
                                    currentArtistName = tagger.getAlbumArtist()
                                except:
                                    tagger.loadFileForWrite(musicFilePath)
                                tagger.setAlbumArtist(artistName)
                                tagger.update()
                                Records.add(
                                    str(
                                        translate("Amarok/Operations",
                                                  "albumArtist")),
                                    str(currentArtistName), artistName)
            except:
                ReportBug.ReportBug()
        else:
            allItemNumber = x + 1
        Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"),
                          x + 1, allItemNumber, True)
        if isContinueThreadAction is False:
            break
    uni.finishThreadAction()
Example #26
0
 def runScriptAndClose(self):
     try:
         if self.runScript():
             self.close()
     except:
         ReportBug.ReportBug()
Example #27
0
    def refreshTable(self, _path):
        self.values = []
        allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(_path,
                                                                          int(uni.MySettings["subDirectoryDeep"]),
                                                                          "file", uni.getBoolValue(
                "isShowHiddensInSubFolderTable"))
        allItemNumber = len(allFilesAndDirectories)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for baseName in allFilesAndDirectories:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(baseName, False, True):
                        details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
                        content = {}
                        content["path"] = baseName
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) + str(fu.getDirName(baseName)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(baseName)
                        content.update(details)
                        self.values.append(content)

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

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

                        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"]))

                        if not uni.isWindows:
                            self.createItem(rowNo, "accessRights", content["accessRights"])

                            self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"])

                            self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"])

                            self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"])

                        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
Example #28
0
 def runScript(self):
     try:
         return Scripts.runScript(str(self.sciCommand.text()))
     except:
         ReportBug.ReportBug()
Example #29
0
 def goHome(self):
     try:
         self.goTo(MDir.homePath())
     except:
         ReportBug.ReportBug()
Example #30
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