コード例 #1
0
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
コード例 #2
0
ファイル: __init__.py プロジェクト: supermurat/hamsi-manager
def checkEmbeddedDB():
    global isAskEmbeddedDBConfiguration
    if uni.getBoolValue("isReadOnlyAmarokDB"):
        if (fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok") and
                fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/mysql") and
                fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/my.cnf")):
            return startReadOnlyEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
                                     translate("Amarok",
                                               "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
                if answer == Dialogs.Yes:
                    ReadOnlyEmbeddedDBConfigurator()
            else:
                return False
    else:
        if (fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysql/db.frm") and
                fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf")):
            return startEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
                                     translate("Amarok",
                                               "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
                if answer == Dialogs.Yes:
                    EmbeddedDBConfigurator()
            else:
                return False
    return checkEmbeddedDB()
コード例 #3
0
 def closeEvent(self, _event):
     if self.isInstallFinished is False:
         answer = Dialogs.ask(translate("Reconfigure", "Finalizing Configuration"),
                              translate("Reconfigure", "Are You Sure You Want To Quit?"))
         if answer != Dialogs.Yes:
             _event.ignore()
     MApplication.setQuitOnLastWindowClosed(True)
コード例 #4
0
 def closeEvent(self, _event):
     if self.isInstallFinished is False:
         currentAnswer = Dialogs.ask(
             translate("Install", "Finalizing Installation"),
             translate("Install", "Are You Sure You Want To Quit?"))
         if currentAnswer != Dialogs.Yes:
             _event.ignore()
コード例 #5
0
ファイル: __init__.py プロジェクト: sahwar/hamsi-manager
 def checkUnSavedValues(self, _isForceToCheck=False):
     if uni.getBoolValue("isCheckUnSavedValues") or _isForceToCheck:
         isClose = True
         for rowNo in range(self.rowCount()):
             if isClose is False:
                 break
             if self.isRowHidden(rowNo):
                 isClose = False
                 break
             for columnNo in range(len(self.tableColumns)):
                 if self.isColumnHidden(columnNo) is False:
                     if self.item(rowNo, columnNo) is not None:
                         if self.item(rowNo,
                                      columnNo).background() == MBrush(
                                          MColor(142, 199, 255)):
                             isClose = False
                             break
                     else:
                         break
         if isClose is False:
             answer = Dialogs.ask(
                 translate("Tables", "There Are Unsaved Values"),
                 translate(
                     "Tables",
                     "Do you want to save these values?<br>If you click to Yes : Table will be saved without any other question or option.<br>If you click to No : Application will be closed without doing any process.<br>If you click to Cancel : Application won't be closed."
                 ), True)
             if answer == Dialogs.Yes:
                 self.save()
             elif answer == Dialogs.Cancel:
                 return False
     return True
コード例 #6
0
def checkAmarok(_isAlertIfNotAvailable=True, _isUseReadOnly=True):
    global isAskEmbeddedDBConfiguration
    if isLoadedMysql and uni.isAvailableKDE4():
        if uni.getBoolValue("amarokIsUseHost"):
            if _isUseReadOnly or uni.getBoolValue(
                    "isReadOnlyAmarokDBHost") is False:
                return True
            else:
                if _isAlertIfNotAvailable:
                    answer = Dialogs.ask(
                        translate("Amarok", "This Feature Is Not Usable"),
                        translate(
                            "Amarok",
                            "This feature is not usable with read only Amarok database. <br>Are you want to give permission to read and write for Amarok database?"
                        ))
                    if answer == Dialogs.Yes:
                        uni.setMySetting("isReadOnlyAmarokDBHost", False)
                        return True
        else:
            isAskEmbeddedDBConfiguration = True
            return checkEmbeddedDB()
    else:
        if _isAlertIfNotAvailable:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok", "Please run Amarok once."))
        return False
    return False
コード例 #7
0
ファイル: FileManager.py プロジェクト: sahwar/hamsi-manager
 def triggered(self, _action):
     try:
         if _action.objectName() == "Edit Bookmarks":
             getMainWindow().FileManager.bookmarks.makeRefresh()
             getMainWindow().FileManager.bookmarks.show()
             return
         for info in BookmarksOfDirectories.fetchAll():
             if info[1] == str(_action.objectName()):
                 if fu.isDir(str(info[2])):
                     getMainWindow().FileManager.goTo(str(info[2]))
                     return
                 else:
                     answer = Dialogs.ask(
                         translate("BookmarksMenu", "Cannot Find Folder"),
                         str(
                             translate(
                                 "BookmarksMenu",
                                 "\"%s\" cannot be found.<br>Delete this folder from the bookmarks?"
                             )) % Organizer.getLink(info[1]))
                     if answer == Dialogs.Yes:
                         BookmarksOfDirectories.delete(str(info[0]))
                         self.makeRefresh()
                         getMainWindow().FileManager.bookmarks.makeRefresh()
         getMainWindow().FileManager.makeRefreshOnlyFileList()
         getMainWindow().FileManager.makeRefreshOnlyFileListByTree()
     except:
         ReportBug.ReportBug()
コード例 #8
0
def cancelThreadAction():
    global threadActionState
    from Core import Dialogs

    answer = Dialogs.ask(translate("Universals", "Are You Sure?"),
                         translate("Universals", "Are you want to cancel these transactions?"))
    if answer == Dialogs.Yes:
        threadActionState = False
コード例 #9
0
ファイル: Configurator.py プロジェクト: sahwar/hamsi-manager
 def closeEvent(self, _event):
     if self.isInstallFinished is False:
         answer = Dialogs.ask(
             translate("Reconfigure", "Finalizing Configuration"),
             translate("Reconfigure", "Are You Sure You Want To Quit?"))
         if answer != Dialogs.Yes:
             _event.ignore()
     MApplication.setQuitOnLastWindowClosed(True)
コード例 #10
0
def cancelThreadAction():
    global threadActionState
    from Core import Dialogs

    answer = Dialogs.ask(
        translate("Universals", "Are You Sure?"),
        translate("Universals", "Are you want to cancel these transactions?"))
    if answer == Dialogs.Yes:
        threadActionState = False
コード例 #11
0
ファイル: ScriptManager.py プロジェクト: sahwar/hamsi-manager
 def clear(self):
     try:
         answer = Dialogs.ask(translate("ScriptManager", "Your Codes Will Be Deleted!.."),
                              translate("ScriptManager",
                                        "Your codes will be deleted and the default codes will be installed. Do you wish to clear the current codes?"))
         if answer == Dialogs.Yes:
             Scripts.clearScript(fu.joinPath(Scripts.pathOfScripsDirectory, self.currentScriptFileName))
     except:
         ReportBug.ReportBug()
コード例 #12
0
ファイル: ScriptManager.py プロジェクト: sahwar/hamsi-manager
 def delete(self):
     try:
         answer = Dialogs.ask(translate("ScriptManager", "Your Script Will Be Deleted!.."),
                              translate("ScriptManager",
                                        "Your script will be deleted. Are you sure you want to delete current script?"))
         if answer == Dialogs.Yes:
             fu.removeFile(fu.joinPath(Scripts.pathOfScripsDirectory, self.currentScriptFileName))
             self.refreshScriptList()
     except:
         ReportBug.ReportBug()
コード例 #13
0
ファイル: __init__.py プロジェクト: supermurat/hamsi-manager
 def restore(self):
     answer = Dialogs.ask(translate("Amarok", "Restore Amarok Database"),
                          translate("Amarok", "Are you want to restore backup database?"))
     if answer == Dialogs.Yes:
         if isRunning():
             self.stopEmbeddedDB(True)
         Dialogs.show(translate("EmbeddedDBConfigurator", "Close Amarok"),
                      translate("EmbeddedDBConfigurator", "Please close Amarok if it is running."))
         restoreEmbeddedDB()
         Dialogs.show(translate("EmbeddedDBConfigurator", "Restore Completed"), translate("EmbeddedDBConfigurator",
                                                                                          "Restore successfully completed.<br> You can run Amarok now if you want."))
         self.checkRunState()
コード例 #14
0
def checkEmbeddedDB():
    global isAskEmbeddedDBConfiguration
    if uni.getBoolValue("isReadOnlyAmarokDB"):
        if (fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok") and
                fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/mysql")
                and fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/my.cnf")):
            return startReadOnlyEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(
                    translate("Amarok", "Amarok Database Must Be Configure"),
                    translate(
                        "Amarok",
                        "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"
                    ))
                if answer == Dialogs.Yes:
                    ReadOnlyEmbeddedDBConfigurator()
            else:
                return False
    else:
        if (fu.isFile(uni.getKDE4HomePath() +
                      "/share/apps/amarok/mysqle/mysql/db.frm")
                and fu.isFile(uni.getKDE4HomePath() +
                              "/share/apps/amarok/mysqle/my.cnf")):
            return startEmbeddedDB()
        else:
            if isAskEmbeddedDBConfiguration:
                isAskEmbeddedDBConfiguration = False
                answer = Dialogs.ask(
                    translate("Amarok", "Amarok Database Must Be Configure"),
                    translate(
                        "Amarok",
                        "Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"
                    ))
                if answer == Dialogs.Yes:
                    EmbeddedDBConfigurator()
            else:
                return False
    return checkEmbeddedDB()
コード例 #15
0
    def doAfterRunProcessesStep1(self):
        if str(fu.defaultFileSystemEncoding) != str(uni.MySettings["fileSystemEncoding"]):
            answer = Dialogs.ask(
                translate("HamsiManager", "Your System's \"File System Encoding\" Type Different"),
                translate("HamsiManager",
                          "Your system's \"File System Encoding\" type different from the settings you select. Are you sure you want to continue?If you are not sure press the \"No\"."),
                False, "Your System's \"File System Encoding\" Type Different")
            if answer == Dialogs.No:
                OptionsForm.OptionsForm(self, _focusTo="fileSystemEncoding")
        if uni.getBoolValue("isMakeAutoDesign"):
            self.TableToolsBar.setVisible(False)
            self.ToolsBar.setVisible(False)
            if isActivePyKDE4:
                self.Browser.setVisible(False)
                self.TreeBrowser.setVisible(False)
                self.FileManager.urlNavigator.setMinimumWidth(150)
                self.FileManager.tbarBrowserToolsFull.setVisible(False)
                self.tabifyDockWidget(self.Browser, self.Places)
                self.tabifyDockWidget(self.Browser, self.TreeBrowser)
                self.tabifyDockWidget(self.Browser, self.DirOperator)
            geometries = uni.getListValue("MainWindowGeometries")
            self.setGeometry(int(geometries[0]), int(geometries[1]), 900, 600)
            uni.setMySetting("isMakeAutoDesign", "False")
        if uni.isShowVerifySettings and (uni.changedDefaultValuesKeys != [] or uni.newSettingsKeys != []):
            answer = Dialogs.ask(translate("HamsiManager", "Added New Options And New Features"),
                                 translate("HamsiManager",
                                           "New options and new features added to Hamsi Manager. Are you want to change or verify new options?"),
                                 False, "Added New Options And New Features")
            if answer == Dialogs.Yes:
                newOrChangedKeys = uni.newSettingsKeys + uni.changedDefaultValuesKeys
                OptionsForm.OptionsForm(self, "Normal", None, newOrChangedKeys)
        elif uni.getBoolValue("isShowReconfigureWizard") and uni.isBuilt() is False:
            from Tools import Configurator

            Configurator.Configurator()
            uni.setMySetting("isShowReconfigureWizard", "False")
コード例 #16
0
 def reConfigure(self):
     try:
         oldPathOfExecutableHamsi = Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
             if fu.isWritableFileOrDir(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop")):
                 MyConfigure.reConfigureFile(fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.desktop"))
         if self.isCreateDesktopShortcut is not None:
             if self.isCreateDesktopShortcut.checkState() == Mt.Checked:
                 desktopPath = uni.getUserDesktopPath()
                 if uni.isWindows:
                     MyConfigure.createShortCutFile(fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                 else:
                     fileContent = MyConfigure.getConfiguredDesktopFileContent()
                     fu.writeToFile(fu.joinPath(desktopPath, "HamsiManager.desktop"), fileContent)
         if uni.isRunningAsRoot():
             executableLink = str(self.leExecutableLink.text())
             if self.isCreateExecutableLink is not None:
                 if self.isCreateExecutableLink.checkState() == Mt.Checked:
                     if executableLink.strip() != "":
                         HamsiManagerFileName = Execute.findExecutableBaseName("HamsiManager")
                         if fu.isFile(executableLink):
                             fu.removeFileOrDir(executableLink)
                         fu.createSymLink(fu.joinPath(fu.HamsiManagerDirectory, HamsiManagerFileName),
                                          executableLink)
                         Settings.setUniversalSetting("HamsiManagerExecutableLinkPath", executableLink)
                         if oldPathOfExecutableHamsi != executableLink:
                             if fu.isFile(oldPathOfExecutableHamsi):
                                 answer = Dialogs.ask(translate("Reconfigure", "Other Hamsi Manager Was Detected"),
                                                      str(translate("Reconfigure",
                                                                    "Other Hamsi Manager executable file was detected. Are you want to delete old executable file? You can delete this old executable file : \"%s\"")) % (
                                                          oldPathOfExecutableHamsi))
                                 if answer != Dialogs.Yes:
                                     fu.removeFile(oldPathOfExecutableHamsi)
                     if fu.isDir("/usr/share/applications/"):
                         fileContent = MyConfigure.getConfiguredDesktopFileContent()
                         fu.writeToFile("/usr/share/applications/HamsiManager.desktop", fileContent)
         if uni.isRunningAsRoot() is False:
             if fu.isDir(fu.joinPath(fu.userDirectoryPath, ".local", "applications")) is False:
                 fu.makeDirs(fu.joinPath(fu.userDirectoryPath, ".local", "applications"))
             fileContent = MyConfigure.getConfiguredDesktopFileContent()
             fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
                            fileContent)
         MyConfigure.installKDE4Languages()
         self.isInstallFinished = True
     except:
         ReportBug.ReportBug()
コード例 #17
0
def checkMysqldSafe(_isAskIfNotFound=True):
    from Core import Dialogs

    if fu.isFile(MySettings["pathOfMysqldSafe"]) is False and fu.isFile(
            "/usr/bin/" + MySettings["pathOfMysqldSafe"]) is False:
        if _isAskIfNotFound:
            answer = Dialogs.ask(translate("EmbeddedDBCore", "\"mysqld_safe\" Not Found"),
                                 translate("EmbeddedDBCore",
                                           "Executable \"mysqld_safe\" file is not found. Are you want to set path of this file?<br><b>Note :</b> \"mysql-common\" must be installed on your system."))
            if answer == Dialogs.Yes:
                from Options import OptionsForm

                OptionsForm.OptionsForm(getMainWindow(), _focusTo="pathOfMysqldSafe")
        else:
            return False
    else:
        return True
コード例 #18
0
 def restore(self):
     answer = Dialogs.ask(
         translate("Amarok", "Restore Amarok Database"),
         translate("Amarok", "Are you want to restore backup database?"))
     if answer == Dialogs.Yes:
         if isRunning():
             self.stopEmbeddedDB(True)
         Dialogs.show(
             translate("EmbeddedDBConfigurator", "Close Amarok"),
             translate("EmbeddedDBConfigurator",
                       "Please close Amarok if it is running."))
         restoreEmbeddedDB()
         Dialogs.show(
             translate("EmbeddedDBConfigurator", "Restore Completed"),
             translate(
                 "EmbeddedDBConfigurator",
                 "Restore successfully completed.<br> You can run Amarok now if you want."
             ))
         self.checkRunState()
コード例 #19
0
ファイル: Cleaner.py プロジェクト: sahwar/hamsi-manager
 def Clear(self):
     try:
         uni.isCanBeShowOnMainWindow = False
         answer = Dialogs.ask(translate("Cleaner", "Your Files Will Be Removed"),
                              str(translate("Cleaner",
                                            "The files in the \"%s\" folder will be cleared according to the criteria you set.<br>" +
                                            "This action will delete the files completely, without any chance to recover.<br>" +
                                            "Are you sure you want to perform the action?")) % Organizer.getLink(
                                  Organizer.getLink(str(self.lePathOfProject.text()))))
         if answer == Dialogs.Yes:
             if fu.isWritableFileOrDir(str(self.lePathOfProject.text())):
                 if fu.clearCleaningDirectory(str(self.lePathOfProject.text()), True, True):
                     Dialogs.show(translate("Cleaner", "Directory Is Cleared"),
                                  str(translate("Cleaner",
                                                "This directory is cleared : \"%s\"")) % Organizer.getLink(
                                      str(self.lePathOfProject.text())))
         uni.isCanBeShowOnMainWindow = True
     except:
         ReportBug.ReportBug()
コード例 #20
0
 def removeOnlySubFiles(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             answer = Dialogs.ask(translate("QuickMake", "All Files Will Be Removed"),
                                  str(translate("QuickMake",
                                                "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                      _path))
             if answer == Dialogs.Yes:
                 getMainWindow().setEnabled(False)
                 fu.removeOnlySubFiles(_path)
                 getMainWindow().setEnabled(True)
                 Dialogs.show(translate("QuickMake", "Removed Only All Files"),
                              str(translate("QuickMake",
                                            "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                  _path))
         self.close()
     except:
         ReportBug.ReportBug()
コード例 #21
0
ファイル: ScriptManager.py プロジェクト: sahwar/hamsi-manager
 def checkForSave(self):
     try:
         if self.currentScriptFileName is not None:
             if fu.isFile(fu.joinPath(Scripts.pathOfScripsDirectory, self.currentScriptFileName)):
                 codes = Scripts.getScript(fu.joinPath(Scripts.pathOfScripsDirectory, self.currentScriptFileName))
                 if str(codes) != str(self.sciCommand.text()):
                     if self.cckbIsAutoSaveScripts.checkState() == Mt.Checked:
                         self.save()
                     else:
                         answer = Dialogs.ask(translate("ScriptManager", "Do You Wish To Save Your Codes?"),
                                              translate("ScriptManager",
                                                        "Do you wish to save your codes so that you can continue later?"),
                                              True)
                         if answer == Dialogs.Yes:
                             self.save()
                         elif answer == Dialogs.Cancel:
                             return False
         return True
     except:
         ReportBug.ReportBug()
コード例 #22
0
def checkMysqldSafe(_isAskIfNotFound=True):
    from Core import Dialogs

    if fu.isFile(MySettings["pathOfMysqldSafe"]) is False and fu.isFile(
            "/usr/bin/" + MySettings["pathOfMysqldSafe"]) is False:
        if _isAskIfNotFound:
            answer = Dialogs.ask(
                translate("EmbeddedDBCore", "\"mysqld_safe\" Not Found"),
                translate(
                    "EmbeddedDBCore",
                    "Executable \"mysqld_safe\" file is not found. Are you want to set path of this file?<br><b>Note :</b> \"mysql-common\" must be installed on your system."
                ))
            if answer == Dialogs.Yes:
                from Options import OptionsForm

                OptionsForm.OptionsForm(getMainWindow(),
                                        _focusTo="pathOfMysqldSafe")
        else:
            return False
    else:
        return True
コード例 #23
0
ファイル: __init__.py プロジェクト: supermurat/hamsi-manager
def checkAmarok(_isAlertIfNotAvailable=True, _isUseReadOnly=True):
    global isAskEmbeddedDBConfiguration
    if isLoadedMysql and uni.isAvailableKDE4():
        if uni.getBoolValue("amarokIsUseHost"):
            if _isUseReadOnly or uni.getBoolValue("isReadOnlyAmarokDBHost") is False:
                return True
            else:
                if _isAlertIfNotAvailable:
                    answer = Dialogs.ask(translate("Amarok", "This Feature Is Not Usable"),
                                         translate("Amarok",
                                                   "This feature is not usable with read only Amarok database. <br>Are you want to give permission to read and write for Amarok database?"))
                    if answer == Dialogs.Yes:
                        uni.setMySetting("isReadOnlyAmarokDBHost", False)
                        return True
        else:
            isAskEmbeddedDBConfiguration = True
            return checkEmbeddedDB()
    else:
        if _isAlertIfNotAvailable:
            Dialogs.showError(translate("Amarok", "Amarok Module Is Not Usable"),
                              translate("Amarok", "Please run Amarok once."))
        return False
    return False
コード例 #24
0
ファイル: RecordsForm.py プロジェクト: sahwar/hamsi-manager
 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()
コード例 #25
0
 def triggered(self, _action):
     try:
         if _action.objectName() == "Edit Bookmarks":
             getMainWindow().FileManager.bookmarks.makeRefresh()
             getMainWindow().FileManager.bookmarks.show()
             return
         for info in BookmarksOfDirectories.fetchAll():
             if info[1] == str(_action.objectName()):
                 if fu.isDir(str(info[2])):
                     getMainWindow().FileManager.goTo(str(info[2]))
                     return
                 else:
                     answer = Dialogs.ask(translate("BookmarksMenu", "Cannot Find Folder"),
                                 str(translate("BookmarksMenu",
                                     "\"%s\" cannot be found.<br>Delete this folder from the bookmarks?")) %
                                 Organizer.getLink(info[1]))
                     if answer == Dialogs.Yes:
                         BookmarksOfDirectories.delete(str(info[0]))
                         self.makeRefresh()
                         getMainWindow().FileManager.bookmarks.makeRefresh()
         getMainWindow().FileManager.makeRefreshOnlyFileList()
         getMainWindow().FileManager.makeRefreshOnlyFileListByTree()
     except:
         ReportBug.ReportBug()
コード例 #26
0
ファイル: __init__.py プロジェクト: sahwar/hamsi-manager
 def askHiddenColumn(self, _columnKey, _isYesToAll=True):
     if _isYesToAll is False:
         self.isAskShowHiddenColumn = True
     if self.isAskShowHiddenColumn:
         if _isYesToAll:
             answer = Dialogs.askSpecial(
                 translate("Tables", "Hidden Field"),
                 str(
                     translate(
                         "Tables",
                         "\"%s\": you have hidden this field in the table.<br>Do you want to activate this field and perform the action?"
                     )) % (self.getColumnNameFromKey(_columnKey)),
                 translate("Dialogs", "Yes"), translate("Dialogs", "No"),
                 translate("Dialogs", "Yes To All"))
         else:
             answer = Dialogs.ask(
                 translate("Tables", "Hidden Field"),
                 str(
                     translate(
                         "Tables",
                         "\"%s\": you have hidden this field in the table.<br>Do you want to activate this field and perform the action?"
                     )) % (self.getColumnNameFromKey(_columnKey)))
         if answer == Dialogs.No or answer == translate("Dialogs", "No"):
             Dialogs.showError(
                 translate("Tables", "Action Cancelled"),
                 translate(
                     "Tables",
                     "You have cancelled the action.<br>You can make the necessary changes and reperform the action."
                 ))
             return False
         elif answer == translate("Dialogs", "Yes To All"):
             self.isAskShowHiddenColumn = False
     self.mContextMenuColumnsActions[self.getColumnNoFromKey(
         _columnKey)].setChecked(True)
     self.refreshShowedAndHiddenColumns()
     return True
コード例 #27
0
ファイル: install.py プロジェクト: supermurat/hamsi-manager
 def closeEvent(self, _event):
     if self.isInstallFinished is False:
         currentAnswer = Dialogs.ask(translate("Install", "Finalizing Installation"),
                              translate("Install", "Are You Sure You Want To Quit?"))
         if currentAnswer != Dialogs.Yes:
             _event.ignore()
コード例 #28
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
コード例 #29
0
ファイル: Configurator.py プロジェクト: sahwar/hamsi-manager
 def reConfigure(self):
     try:
         oldPathOfExecutableHamsi = Settings.getUniversalSetting(
             "HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")
         if fu.isFile(
                 fu.joinPath(fu.HamsiManagerDirectory,
                             "HamsiManager.desktop")):
             if fu.isWritableFileOrDir(
                     fu.joinPath(fu.HamsiManagerDirectory,
                                 "HamsiManager.desktop")):
                 MyConfigure.reConfigureFile(
                     fu.joinPath(fu.HamsiManagerDirectory,
                                 "HamsiManager.desktop"))
         if self.isCreateDesktopShortcut is not None:
             if self.isCreateDesktopShortcut.checkState() == Mt.Checked:
                 desktopPath = uni.getUserDesktopPath()
                 if uni.isWindows:
                     MyConfigure.createShortCutFile(
                         fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                 else:
                     fileContent = MyConfigure.getConfiguredDesktopFileContent(
                     )
                     fu.writeToFile(
                         fu.joinPath(desktopPath, "HamsiManager.desktop"),
                         fileContent)
         if uni.isRunningAsRoot():
             executableLink = str(self.leExecutableLink.text())
             if self.isCreateExecutableLink is not None:
                 if self.isCreateExecutableLink.checkState() == Mt.Checked:
                     if executableLink.strip() != "":
                         HamsiManagerFileName = Execute.findExecutableBaseName(
                             "HamsiManager")
                         if fu.isFile(executableLink):
                             fu.removeFileOrDir(executableLink)
                         fu.createSymLink(
                             fu.joinPath(fu.HamsiManagerDirectory,
                                         HamsiManagerFileName),
                             executableLink)
                         Settings.setUniversalSetting(
                             "HamsiManagerExecutableLinkPath",
                             executableLink)
                         if oldPathOfExecutableHamsi != executableLink:
                             if fu.isFile(oldPathOfExecutableHamsi):
                                 answer = Dialogs.ask(
                                     translate(
                                         "Reconfigure",
                                         "Other Hamsi Manager Was Detected"
                                     ),
                                     str(
                                         translate(
                                             "Reconfigure",
                                             "Other Hamsi Manager executable file was detected. Are you want to delete old executable file? You can delete this old executable file : \"%s\""
                                         )) % (oldPathOfExecutableHamsi))
                                 if answer != Dialogs.Yes:
                                     fu.removeFile(oldPathOfExecutableHamsi)
                     if fu.isDir("/usr/share/applications/"):
                         fileContent = MyConfigure.getConfiguredDesktopFileContent(
                         )
                         fu.writeToFile(
                             "/usr/share/applications/HamsiManager.desktop",
                             fileContent)
         if uni.isRunningAsRoot() is False:
             if fu.isDir(
                     fu.joinPath(fu.userDirectoryPath, ".local",
                                 "applications")) is False:
                 fu.makeDirs(
                     fu.joinPath(fu.userDirectoryPath, ".local",
                                 "applications"))
             fileContent = MyConfigure.getConfiguredDesktopFileContent()
             fu.writeToFile(
                 fu.joinPath(fu.userDirectoryPath, ".local", "applications",
                             "HamsiManager.desktop"), fileContent)
         MyConfigure.installKDE4Languages()
         self.isInstallFinished = True
     except:
         ReportBug.ReportBug()
コード例 #30
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(
         translate("FileUtils/Covers", "Writing Cover Informations"), 0,
         allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                           False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover")
                                 or self.isChangeableItem(
                                     rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo][
                                 "destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(
                                     self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(
                                     rowNo, "destinationCover"):
                                 destinationPath = str(
                                     self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath
                                     or sourcePath != destinationPath
                                     or str(self.item(rowNo, 2).text()) !=
                                     destinationPath
                                 ) or (str(self.item(rowNo, 2).text()) !=
                                       self.values[rowNo]["currentCover"]
                                       and
                                       (str(self.item(rowNo, 2).text()) !=
                                        sourcePath
                                        and str(self.item(rowNo, 2).text())
                                        != destinationPath)):
                                 if str(self.item(rowNo,
                                                  3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(
                                         sourcePath,
                                         self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(
                                         sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(
                                                 destinationPath,
                                                 self.values[rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(
                                                     sourcePath,
                                                     destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(
                                             self.values[rowNo]["path"],
                                             destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(
                                         self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo,
                                                  "baseNameOfDirectory",
                                                  baseNameOfDirectory):
                             baseNameOfDirectory = str(
                                 self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(
                                     fu.getDirName(
                                         self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(
                                         rowNo - 1,
                                         0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName",
                                                  baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(
                                 fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(
                             self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(
                                 oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue(
                                         "isClearEmptyDirectoriesWhenFileMove"
                                 ):
                                     fu.checkEmptyDirectories(
                                         oldDirName, True, True,
                                         uni.getBoolValue(
                                             "isAutoCleanSubFolderWhenFileMove"
                                         ))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(
             translate("FileUtils/Covers", "Writing Cover Informations"),
             rowNo + 1, allItemNumber, True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(
             oldAndNewPathValues
     ) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath,
                                           "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(
                 translate("FileUtils/Musics", "There Are More Files"),
                 str(
                     translate(
                         "FileUtils/Musics",
                         "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\""
                     )) % (Organizer.getLink(currentDirectoryPath),
                           Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(
                                 fu.joinPath(currentDirectoryPath,
                                             fileName))
                             newFilePath = fu.getRealPath(
                                 fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths[
                                     "newPath"] = fu.moveOrChange(
                                         oldFilePath, newFilePath,
                                         fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(
                                         oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(
                         translate(
                             "FileUtils/Covers",
                             "Writing Directory And File Informations"),
                         rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(
                         currentDirectoryPath, True, True,
                         uni.getBoolValue(
                             "isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and
                         uni.getBoolValue("isActiveAutoMakeIconToDirectory")
                         and uni.getBoolValue(
                             "isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
コード例 #31
0
ファイル: __init__.py プロジェクト: supermurat/hamsi-manager
def checkAndGetDB(_isNoAlertIfSuccessfully=True, _isReCheck=False):
    global isCheckAgain
    if _isReCheck:
        isCheckAgain = True
    if checkAmarok():
        try:
            db = connectAndGetDB()
            if db is not None:
                if isCheckAgain:
                    db.query("SELECT version FROM admin WHERE component='DB_VERSION'")
                    rows = db.store_result().fetch_row(1)
                    dbVersion = int(rows[0][0])
                    if dbVersion not in availableDBVersions:
                        answer = Dialogs.ask(translate("Amarok", "Your Amarok DB Version Is Not Tested"),
                                             str(translate("Amarok",
                                                       "Your Amarok DB version is not tested. We don`t suggest but you can use at your own risk. Are you sure you want to use?"
                                                       "<br>Your Amarok DB Version:%s"
                                                       "<br>Tested Amarok DB Versions:%s")) % (str(dbVersion), str(
                                                 availableDBVersions)))
                        if answer is not Dialogs.Yes:
                            return None
                    if _isNoAlertIfSuccessfully is False:
                        Dialogs.show(translate("Amarok", "Connected To Database"),
                                     str(translate("Amarok", "Connected successfully to \"%s\"")) % uni.MySettings[
                                         "amarokDBDB"])
                isCheckAgain = False
                return db
            else:
                Dialogs.showError(translate("Amarok", "Amarok Database Is Not Usable"),
                                  translate("Amarok", "Amarok database is not accessible."))
            return None
        except:
            cla, currentError, trbk = sys.exc_info()
            if str(currentError).find("Unknown MySQL server host") != -1:
                Dialogs.showError(translate("Amarok", "Not Connected To Database"), str(
                    translate("Amarok", "Unknown MySQL server host \"%s\" <br><b>Details</b> : %s")) % (
                                      uni.MySettings["amarokDBHost"], str(currentError)))
            elif str(currentError).find("Access denied for user") != -1:
                Dialogs.showError(translate("Amarok", "Not Connected To Database"),
                                  str(translate("Amarok", "Access denied for user \"%s\" <br><b>Details</b> : %s")) % (
                                      uni.MySettings["amarokDBUser"], str(currentError)))
            elif str(currentError).find("Unknown database") != -1:
                Dialogs.showError(translate("Amarok", "Not Connected To Database"),
                                  str(translate("Amarok", "Unknown database \"%s\" <br><b>Details</b> : %s")) % (
                                      uni.MySettings["amarokDBDB"], str(currentError)))
            elif str(currentError).find("Can't connect to local MySQL server through socket") != -1:
                Dialogs.showError(translate("Amarok", "Not Connected To Database"), str(translate("Amarok",
                                                                                                  "Can't connect to local MySQL server through socket \"%s\" <br><b>Details</b> : %s")) % (
                                      str(currentError).replace(
                                          "(2002, \"Can't connect to local MySQL server through socket '",
                                          "").replace("' (2)\")", ""), str(currentError)))
            else:
                ReportBug.ReportBug()
            return None
    else:
        if isLoadedMysql is False:
            Dialogs.showError(translate("Amarok", "Amarok Module Is Not Usable"), translate("Amarok",
                                                                                            "\"python-mysql\" (MySQLdb / _mysql) named module is not installed on your system. Please install this module and try again."))
        elif uni.isAvailableKDE4() is False:
            Dialogs.showError(translate("Amarok", "Amarok Module Is Not Usable"),
                              translate("Amarok", "Please open user session with KDE4 once."))
        else:
            Dialogs.showError(translate("Amarok", "Amarok Module Is Not Usable"),
                              translate("Amarok", "Please run Amarok once."))
        return None
コード例 #32
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        isNewDirectoriesSame = True
        isMovedToNewDirectory = False
        currentDirectoryPath = ""
        newDirectoryPath = ""
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok

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

            Operations.changeTags(changingTags)
            if len(oldAndNewPathValues) > 0:
                Operations.changePaths(oldAndNewPathValues, "file")
        return True
コード例 #33
0
ファイル: __init__.py プロジェクト: supermurat/hamsi-manager
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()
コード例 #34
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(
                translate("MenuBar", "Open State Of Hamsi Manager"),
                fu.userDirectoryPath,
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(
                translate("MenuBar", "Save State Of Hamsi Manager"),
                fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(
                    translate("MenuBar", "Current State Saved"),
                    translate(
                        "MenuBar",
                        "Current state saved with preferences.<br>You can continue where you left off."
                    ))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(
                ["--sDirectoryPath", fu.pathOfSettingsDirectory],
                    "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "html", "fileTree", "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "plainText", "fileTree",
                               "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Scripts.runScriptFile(
                fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
コード例 #35
0
def checkAndGetDB(_isNoAlertIfSuccessfully=True, _isReCheck=False):
    global isCheckAgain
    if _isReCheck:
        isCheckAgain = True
    if checkAmarok():
        try:
            db = connectAndGetDB()
            if db is not None:
                if isCheckAgain:
                    db.query(
                        "SELECT version FROM admin WHERE component='DB_VERSION'"
                    )
                    rows = db.store_result().fetch_row(1)
                    dbVersion = int(rows[0][0])
                    if dbVersion not in availableDBVersions:
                        answer = Dialogs.ask(
                            translate("Amarok",
                                      "Your Amarok DB Version Is Not Tested"),
                            str(
                                translate(
                                    "Amarok",
                                    "Your Amarok DB version is not tested. We don`t suggest but you can use at your own risk. Are you sure you want to use?"
                                    "<br>Your Amarok DB Version:%s"
                                    "<br>Tested Amarok DB Versions:%s")) %
                            (str(dbVersion), str(availableDBVersions)))
                        if answer is not Dialogs.Yes:
                            return None
                    if _isNoAlertIfSuccessfully is False:
                        Dialogs.show(
                            translate("Amarok", "Connected To Database"),
                            str(
                                translate("Amarok",
                                          "Connected successfully to \"%s\""))
                            % uni.MySettings["amarokDBDB"])
                isCheckAgain = False
                return db
            else:
                Dialogs.showError(
                    translate("Amarok", "Amarok Database Is Not Usable"),
                    translate("Amarok", "Amarok database is not accessible."))
            return None
        except:
            cla, currentError, trbk = sys.exc_info()
            if str(currentError).find("Unknown MySQL server host") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Unknown MySQL server host \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (uni.MySettings["amarokDBHost"], str(currentError)))
            elif str(currentError).find("Access denied for user") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Access denied for user \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (uni.MySettings["amarokDBUser"], str(currentError)))
            elif str(currentError).find("Unknown database") != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Unknown database \"%s\" <br><b>Details</b> : %s"))
                    % (uni.MySettings["amarokDBDB"], str(currentError)))
            elif str(currentError).find(
                    "Can't connect to local MySQL server through socket"
            ) != -1:
                Dialogs.showError(
                    translate("Amarok", "Not Connected To Database"),
                    str(
                        translate(
                            "Amarok",
                            "Can't connect to local MySQL server through socket \"%s\" <br><b>Details</b> : %s"
                        )) %
                    (str(currentError).replace(
                        "(2002, \"Can't connect to local MySQL server through socket '",
                        "").replace("' (2)\")", ""), str(currentError)))
            else:
                ReportBug.ReportBug()
            return None
    else:
        if isLoadedMysql is False:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate(
                    "Amarok",
                    "\"python-mysql\" (MySQLdb / _mysql) named module is not installed on your system. Please install this module and try again."
                ))
        elif uni.isAvailableKDE4() is False:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok",
                          "Please open user session with KDE4 once."))
        else:
            Dialogs.showError(
                translate("Amarok", "Amarok Module Is Not Usable"),
                translate("Amarok", "Please run Amarok once."))
        return None