Exemplo n.º 1
0
def stopReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isReadOnlyStarted
    if isReadOnlyStarted is False:
        return True
    isReadOnlyStarted = False
    mysqldPID = getReadOnlyPID()
    if mysqldPID is not None:
        Execute.execute(["kill", "-TERM", str(mysqldPID)])
        Dialogs.sleep(translate("EmbeddedDBCore", "Stopping Embedded Server..."), 3)
    if _isNoAlertIfSuccessfully is False:
        Dialogs.show(translate("EmbeddedDBCore", "Stopped Embedded Server"),
                     translate("EmbeddedDBCore", "Embedded Amarok database server stopped."))
    return True
Exemplo n.º 2
0
def startReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isReadOnlyStarted
    if isReadOnlyStarted:
        return True
    if uni.checkMysqldSafe():
        Execute.executeWithThread(
            [uni.MySettings["pathOfMysqldSafe"], "--defaults-file=" + fu.pathOfSettingsDirectory + "/Amarok/my.cnf"])
        Dialogs.sleep(translate("EmbeddedDBCore", "Starting Embedded Server..."), 3)
        if _isNoAlertIfSuccessfully is False:
            Dialogs.show(translate("EmbeddedDBCore", "Started Embedded Server"),
                         translate("EmbeddedDBCore", "Embedded Amarok database server started."))
        isReadOnlyStarted = True
        return True
    isReadOnlyStarted = False
    return False
Exemplo n.º 3
0
def startEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isStarted
    if isStarted:
        return True
    if uni.checkMysqldSafe():
        Execute.executeWithThread([uni.MySettings["pathOfMysqldSafe"],
                                   "--defaults-file=" + uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf"])
        Dialogs.sleep(translate("EmbeddedDBCore", "Starting Embedded Server..."), 3)
        if _isNoAlertIfSuccessfully is False:
            Dialogs.show(translate("EmbeddedDBCore", "Started Embedded Server"),
                         translate("EmbeddedDBCore", "Embedded Amarok database server started."))
        isStarted = True
        return True
    isStarted = False
    return False
Exemplo n.º 4
0
def stopReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isReadOnlyStarted
    if isReadOnlyStarted is False:
        return True
    isReadOnlyStarted = False
    mysqldPID = getReadOnlyPID()
    if mysqldPID is not None:
        Execute.execute(["kill", "-TERM", str(mysqldPID)])
        Dialogs.sleep(
            translate("EmbeddedDBCore", "Stopping Embedded Server..."), 3)
    if _isNoAlertIfSuccessfully is False:
        Dialogs.show(
            translate("EmbeddedDBCore", "Stopped Embedded Server"),
            translate("EmbeddedDBCore",
                      "Embedded Amarok database server stopped."))
    return True
Exemplo n.º 5
0
def openStateOfSettings(_file):
    from Core import Execute

    for rowNo, row in enumerate(fu.readLinesFromFile(_file)):
        if row[:5] == "Exec=":
            t = Execute.executeStringCommand(row[5:])
            getApplication().closeAllWindows()
            break
Exemplo n.º 6
0
def openStateOfSettings(_file):
    from Core import Execute

    for rowNo, row in enumerate(fu.readLinesFromFile(_file)):
        if row[:5] == "Exec=":
            t = Execute.executeStringCommand(row[5:])
            getApplication().closeAllWindows()
            break
Exemplo n.º 7
0
def saveUniversalSettings():
    from Core import Execute

    mySetting = universalSetting()
    keysOfUniversalSettings = ["HamsiManagerPath"]
    values = [Execute.findExecutablePath("HamsiManager")]
    for x, keyValue in enumerate(keysOfUniversalSettings):
        if trStr(mySetting.value(keyValue)) != values[x]:
            mySetting.setValue(keyValue, trQVariant(values[x]))
Exemplo n.º 8
0
def saveUniversalSettings():
    from Core import Execute

    mySetting = universalSetting()
    keysOfUniversalSettings = ["HamsiManagerPath"]
    values = [Execute.findExecutablePath("HamsiManager")]
    for x, keyValue in enumerate(keysOfUniversalSettings):
        if trStr(mySetting.value(keyValue)) != values[x]:
            mySetting.setValue(keyValue, trQVariant(values[x]))
Exemplo n.º 9
0
def getConfiguredContent(_content, _executeCommandOfHamsiManager=None):
    if _executeCommandOfHamsiManager is None:
        from Core import Execute

        _executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    return _content.replace("~InstallationDirectory~", fu.HamsiManagerDirectory).replace(
        "~ExecuteCommandOfHamsiManager~", _executeCommandOfHamsiManager).replace("~IconPath~",
                                                                                 fu.joinPath(fu.themePath, "Images",
                                                                                             "hamsi.png")).replace(
        "~ThemePath~", fu.themePath)
Exemplo n.º 10
0
def startEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isStarted
    if isStarted:
        return True
    if uni.checkMysqldSafe():
        Execute.executeWithThread([
            uni.MySettings["pathOfMysqldSafe"], "--defaults-file=" +
            uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf"
        ])
        Dialogs.sleep(
            translate("EmbeddedDBCore", "Starting Embedded Server..."), 3)
        if _isNoAlertIfSuccessfully is False:
            Dialogs.show(
                translate("EmbeddedDBCore", "Started Embedded Server"),
                translate("EmbeddedDBCore",
                          "Embedded Amarok database server started."))
        isStarted = True
        return True
    isStarted = False
    return False
Exemplo n.º 11
0
def startReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True):
    global isReadOnlyStarted
    if isReadOnlyStarted:
        return True
    if uni.checkMysqldSafe():
        Execute.executeWithThread([
            uni.MySettings["pathOfMysqldSafe"],
            "--defaults-file=" + fu.pathOfSettingsDirectory + "/Amarok/my.cnf"
        ])
        Dialogs.sleep(
            translate("EmbeddedDBCore", "Starting Embedded Server..."), 3)
        if _isNoAlertIfSuccessfully is False:
            Dialogs.show(
                translate("EmbeddedDBCore", "Started Embedded Server"),
                translate("EmbeddedDBCore",
                          "Embedded Amarok database server started."))
        isReadOnlyStarted = True
        return True
    isReadOnlyStarted = False
    return False
Exemplo n.º 12
0
    def play(self, _filePath):
        from Core import Execute

        if self.popen is not False:
            self.runCommand("quit")
        command = [uni.MySettings["mplayerPath"]]
        command += uni.MySettings["mplayerArgs"].split(" ")
        command += [uni.MySettings["mplayerAudioDevicePointer"],
                    uni.MySettings["mplayerAudioDevice"],
                    str(_filePath)]
        self.popen = Execute.execute(command)
        return True
Exemplo n.º 13
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(translate("Details", "File Is Not Supported"),
                                           str(translate("Details",
                                                         "\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
                                               str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(translate("Details", "Directories Is Not Supported"),
                                       str(translate("Details",
                                                     "\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
                                           str(_filePath)))
             else:
                 Dialogs.showError(translate("Details", "File Is Not Exist"),
                                   str(translate("Details",
                                                 "\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
                                       str(_filePath)))
     except:
         answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
                                     str(translate("Details",
                                                   "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
                                         str(_filePath)),
                                     translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Exemplo n.º 14
0
    def contextMenuEvent(self, _event):
        try:
            currentItem = self.currentItem()
            if currentItem is not None:
                self.mContextMenu.setGeometry(_event.globalX(),
                                              _event.globalY(), 1, 1)
                selectedItem = self.mContextMenu.exec_()
                if selectedItem is not None:
                    selectedKey = selectedItem.objectName()
                    if ((selectedKey in [
                            self.mContextMenuActionNames[0],
                            self.mContextMenuActionNames[2],
                            self.mContextMenuActionNames[3]
                    ]) and self.checkReadOnlyColumn(currentItem.columnKey) is
                            False):
                        return False
                    if selectedKey == self.mContextMenuActionNames[0]:
                        self.createHistoryPoint()
                        MApplication.clipboard().setText(currentItem.text())
                        currentItem.setText("")
                    elif selectedKey == self.mContextMenuActionNames[1]:
                        MApplication.clipboard().setText(currentItem.text())
                    elif selectedKey == self.mContextMenuActionNames[2]:
                        self.createHistoryPoint()
                        currentItem.setText(MApplication.clipboard().text())
                    elif selectedKey == self.mContextMenuActionNames[3]:
                        self.editItem(currentItem)
                    elif selectedKey == self.mContextMenuActionNames[4]:
                        self.createHistoryPoint()
                        for rowNo in self.getSelectedRows():
                            self.hideRow(rowNo)
                    elif selectedKey == "Open Details":
                        self.showDetails()
                    elif selectedKey == self.mContextMenuOpenWithNames[0]:
                        from Core import Execute

                        Execute.openWith([
                            fu.getRealDirName(
                                self.values[currentItem.row()]["path"])
                        ])
                    elif selectedKey == self.mContextMenuOpenWithNames[1]:
                        from Core import Execute

                        Execute.openWith(
                            [self.values[currentItem.row()]["path"]])
                    elif uni.isWindows is False and selectedKey == self.mContextMenuOpenWithNames[
                            2]:
                        from Core import Execute

                        Execute.execute([
                            "konsole", "--workdir",
                            fu.getRealDirName(
                                self.values[currentItem.row()]["path"])
                        ])
        except:
            ReportBug.ReportBug()
Exemplo n.º 15
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()
Exemplo n.º 16
0
def createShortCutFile(_destinationPath, _installationDirectory=fu.HamsiManagerDirectory):
    if fu.isFile(_destinationPath):
        fu.removeFileOrDir(_destinationPath)
    from Core import Execute
    from win32com.client import Dispatch

    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(_destinationPath)
    targetPath = Execute.getExecuteCommandOfHamsiManagerAsList()
    if len(targetPath) > 1:
        shortcut.Targetpath = targetPath[0].replace(fu.HamsiManagerDirectory, _installationDirectory)
        shortcut.Arguments = targetPath[1].replace(fu.HamsiManagerDirectory, _installationDirectory)
    else:
        shortcut.Targetpath = targetPath[0].replace(fu.HamsiManagerDirectory, _installationDirectory)
    shortcut.WorkingDirectory = _installationDirectory
    shortcut.IconLocation = fu.joinPath(fu.themePath.replace(fu.HamsiManagerDirectory, _installationDirectory),
                                        "Images", "hamsi.ico")
    shortcut.save()
Exemplo n.º 17
0
def getLibraryDirectoryPath():
    global libPath
    if libPath is None:
        if isActivePyKDE4:
            from PyKDE4 import pykdeconfig

            libPath = pykdeconfig._pkg_config["kdelibdir"]
        else:
            try:
                from Core import Execute

                libPath = Execute.getCommandResult(["kde4-config", "--path", "lib"]).split(":")[1][:-2]
            except:
                if fu.isDir("/usr/lib64"):
                    libPath = "/usr/lib64"
                else:
                    libPath = "/usr/lib"
    return libPath
Exemplo n.º 18
0
def getKDE4HomePath():
    if isAvailableKDE4():
        try:
            if isActivePyKDE4:
                from PyKDE4.kdecore import KStandardDirs

                kdedirPath = str(KStandardDirs().localkdedir())
                if kdedirPath[-1] == os.sep:
                    kdedirPath = kdedirPath[:-1]
            else:
                from Core import Execute

                kdedirPath = Execute.getCommandResult(["kde4-config", "--localprefix"])[:-2]
            return kdedirPath
        except: pass
    if fu.isDir(fu.joinPath(fu.userDirectoryPath, ".kde4", "share", "config")):
        return fu.joinPath(fu.userDirectoryPath, ".kde4")
    else:
        return fu.joinPath(fu.userDirectoryPath, ".kde")
Exemplo n.º 19
0
def getLibraryDirectoryPath():
    global libPath
    if libPath is None:
        if isActivePyKDE4:
            from PyKDE4 import pykdeconfig

            libPath = pykdeconfig._pkg_config["kdelibdir"]
        else:
            try:
                from Core import Execute

                libPath = Execute.getCommandResult(
                    ["kde4-config", "--path", "lib"]).split(":")[1][:-2]
            except:
                if fu.isDir("/usr/lib64"):
                    libPath = "/usr/lib64"
                else:
                    libPath = "/usr/lib"
    return libPath
Exemplo n.º 20
0
def getKDE4HomePath():
    if isAvailableKDE4():
        try:
            if isActivePyKDE4:
                from PyKDE4.kdecore import KStandardDirs

                kdedirPath = str(KStandardDirs().localkdedir())
                if kdedirPath[-1] == os.sep:
                    kdedirPath = kdedirPath[:-1]
            else:
                from Core import Execute

                kdedirPath = Execute.getCommandResult(
                    ["kde4-config", "--localprefix"])[:-2]
            return kdedirPath
        except:
            pass
    if fu.isDir(fu.joinPath(fu.userDirectoryPath, ".kde4", "share", "config")):
        return fu.joinPath(fu.userDirectoryPath, ".kde4")
    else:
        return fu.joinPath(fu.userDirectoryPath, ".kde")
Exemplo n.º 21
0
        def finish(self):
            try:
                if fu.isFile(fu.joinPath(self.installationDirectory, "HamsiManager.desktop")):
                    MyConfigure.reConfigureFile(fu.joinPath(self.installationDirectory, "HamsiManager.desktop"),
                                                self.installationDirectory)
                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"),
                                                           self.installationDirectory)
                        else:
                            fileContent = MyConfigure.getConfiguredDesktopFileContent(self.installationDirectory)
                            fu.writeToFile(fu.joinPath(desktopPath, "HamsiManager.desktop"), fileContent)
                if self.isCreateExecutableLink is not None:
                    executableLink = str(self.leExecutableLink.text())
                    if self.isCreateExecutableLink.checkState() == Mt.Checked:
                        if executableLink.strip() != "":
                            executableLink = fu.checkNewDestination(executableLink)
                            if executableLink:
                                HamsiManagerFileName = Execute.findExecutableBaseName("HamsiManager")
                                fu.createSymLink(fu.joinPath(self.installationDirectory, HamsiManagerFileName),
                                                 executableLink)
                                Settings.setUniversalSetting("HamsiManagerExecutableLinkPath", executableLink)
                        if fu.isDir("/usr/share/applications/"):
                            fileContent = MyConfigure.getConfiguredDesktopFileContent(self.installationDirectory)
                            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(self.installationDirectory)
                    fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
                                   fileContent)
                self.isInstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
Exemplo n.º 22
0
def getUserDesktopPath():
    desktopPath = None
    if isActivePyKDE4:
        from PyKDE4.kdeui import KGlobalSettings

        desktopPath = str(KGlobalSettings.desktopPath())
    elif isAvailableKDE4():
        from Core import Execute

        desktopPath = Execute.getCommandResult(["kde4-config", "--userpath", "desktop"])[:-2]
    elif isWindows:
        from win32com.shell import shell, shellcon

        desktopPath = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, 0, 0)
    else:
        desktopNames = [str(translate("Variables", "Desktop")), "Desktop"]
        for dirName in desktopNames:
            if fu.isDir(fu.joinPath(fu.userDirectoryPath, dirName)):
                desktopPath = fu.joinPath(fu.userDirectoryPath, dirName)
                break
            else:
                desktopPath = fu.userDirectoryPath
    return desktopPath
Exemplo n.º 23
0
def getUserDesktopPath():
    desktopPath = None
    if isActivePyKDE4:
        from PyKDE4.kdeui import KGlobalSettings

        desktopPath = str(KGlobalSettings.desktopPath())
    elif isAvailableKDE4():
        from Core import Execute

        desktopPath = Execute.getCommandResult(
            ["kde4-config", "--userpath", "desktop"])[:-2]
    elif isWindows:
        from win32com.shell import shell, shellcon

        desktopPath = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, 0, 0)
    else:
        desktopNames = [str(translate("Variables", "Desktop")), "Desktop"]
        for dirName in desktopNames:
            if fu.isDir(fu.joinPath(fu.userDirectoryPath, dirName)):
                desktopPath = fu.joinPath(fu.userDirectoryPath, dirName)
                break
            else:
                desktopPath = fu.userDirectoryPath
    return desktopPath
Exemplo n.º 24
0
def installThisPlugin():
    from Core import Execute

    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "hamsi.png")
    myPluginStrings = [(" <action name=\"hamsimanager_Organize\" >\n" +
                        "  <title>" + str(
        translate("MyPlugins/Krusader", "Organize With Hamsi Manager")) + "</title>\n" +
                        "  <tooltip>" + str(
        translate("MyPlugins/Krusader", "You can organize with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + iconPath + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "You can continue to edit the folder you select with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " -t 1 --directory %aCurrent%</command>\n" +
                        "  <defaultshortcut>Ctrl+O</defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_emendDirectory\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Auto Emend Directory")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Auto emend with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "emendDirectory.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Auto emend with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --emendDirectory %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_emendDirectoryWithContents\" >\n" +
                        "  <title>" + str(
                           translate("MyPlugins/Krusader", "Auto Emend Directory (With Contents)")) + "</title>\n" +
                        "  <tooltip>" + str(translate("MyPlugins/Krusader",
                                                      "Auto emend with Hamsi Manager (With Contents)")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images",
                                                 "emendDirectoryWithContents.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Auto emend with Hamsi Manager (With Contents)")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --emendDirectoryWithContents %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_emendFile\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Auto Emend File")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Auto emend with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "emendFile.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Auto emend with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --emendFile %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_pack\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Pack It")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Pack it with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "pack.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Pack it with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --pack %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_checkIcon\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Check Directory Icon")) + "</title>\n" +
                        "  <tooltip>" + str(translate("MyPlugins/Krusader",
                                                      "Check directory icon with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "checkIcon.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Check directory icon with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --checkIcon %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_clearEmptyDirectories\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Clear Empty Directories")) + "</title>\n" +
                        "  <tooltip>" + str(translate("MyPlugins/Krusader",
                                                      "Clear empty directories with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "clearEmptyDirectories.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Clear empty directories with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --clearEmptyDirectories %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_clearUnneededs\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Clear Unneededs")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Clear unneededs with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "clearUnneededs.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Clear unneededs with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --clearUnneededs %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_clearIgnoreds\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Clear Ignoreds")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Clear ignoreds with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "clearIgnoreds.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Clear ignoreds with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --clearIgnoreds %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_copyPath\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Copy Path To Clipboard")) + "</title>\n" +
                        "  <tooltip>" + str(translate("MyPlugins/Krusader",
                                                      "Copy path to clipboard with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "copyPath.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Copy path to clipboard with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --copyPath %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_fileTree\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Build File Tree")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Build file tree with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "fileTree.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Build file tree with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --fileTree %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_removeOnlySubFiles\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Remove Sub Files")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Remove sub files with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "removeOnlySubFiles.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Remove sub files with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --removeOnlySubFiles %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_pack\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Clear It")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Clear it with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "pack.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Clear it with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --clear %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_hash\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Hash Digest")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Get hash digest with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "hash.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Get hash digest with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --hash %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_textCorrector\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Correct Content")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Correct content with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "textCorrector.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(translate("MyPlugins/Krusader",
                                                          "Correct content with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --textCorrector %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n"),
                       (" <action name=\"hamsimanager_search\" >\n" +
                        "  <title>" + str(translate("MyPlugins/Krusader", "Search")) + "</title>\n" +
                        "  <tooltip>" + str(
                           translate("MyPlugins/Krusader", "Search with Hamsi Manager")) + "</tooltip>\n" +
                        "  <icon>" + fu.joinPath(fu.themePath, "Images", "search.png") + "</icon>\n" +
                        "  <category>Hamsi Manager</category>\n" +
                        "  <description>" + str(
                           translate("MyPlugins/Krusader", "Search with Hamsi Manager")) + ".</description>\n" +
                        "  <command>" + executeCommandOfHamsiManager + " --qm --search %aCurrent%</command>\n" +
                        "  <defaultshortcut></defaultshortcut>\n" +
                        " </action>\n")]
    if uni.isRunningAsRoot():
        destinationPath = "/usr/share/apps/krusader/"
    else:
        destinationPath = uni.getKDE4HomePath() + "/share/apps/krusader/"
    try:
        pluginStrings = fu.readFromFile(destinationPath + "useractions.xml")
    except:
        if fu.isDir(destinationPath) is False:
            fu.makeDirs(destinationPath)
        if fu.isFile("/usr/share/apps/krusader/useraction_examples.xml"):
            pluginStrings = fu.readFromFile("/usr/share/apps/krusader/useraction_examples.xml")
        else:
            pluginStrings = ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
                             "<!DOCTYPE KrusaderUserActions>\n" +
                             "<KrusaderUserActions>\n" +
                             "</KrusaderUserActions>\n")
    pluginString = ""
    for pstr in myPluginStrings:
        if pluginStrings.find(pstr.split("\n")[0]) == -1:
            pluginString += pstr
    pluginStrings = pluginStrings.replace("</KrusaderUserActions>", pluginString + "</KrusaderUserActions>")
    fu.writeToFile(destinationPath + "useractions.xml", pluginStrings)
    if pluginString == "":
        return "AlreadyInstalled"
    return True
Exemplo n.º 25
0
def installThisPlugin():
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

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

    #if isAlreadyInstalled:
    #    return "AlreadyInstalled"
    return True
            SOURCES += fileName.replace(fu.HamsiManagerDirectory + fu.sep, "") + " \\\n         "

    for fileName in ["Languages" + fu.sep + "HamsiManager_tr_TR.ts",
                     "Languages" + fu.sep + "HamsiManager_untranslated.ts"]:
        TRANSLATIONS += fileName + " \\\n         "

    proFileContent = proFileContent.replace("%SOURCES%", SOURCES)
    proFileContent = proFileContent.replace("%TRANSLATIONS%", TRANSLATIONS)

    fu.writeToFile(proFile, proFileContent)

    args = ["pylupdate4"]
    #args.append("-noobsolete") # Uncomment me if you want to remove old translations from .ts files.
    args.append("-verbose")
    args.append(proFile)

    print (Execute.getCommandResult(args, fu.HamsiManagerDirectory))

    proFileContent = proFileContent.replace("Languages" + fu.sep + "HamsiManager_untranslated.ts \\\n         ", "")
    fu.writeToFile(proFile, proFileContent)

    args = ["lrelease"]
    args.append("-compress")
    args.append(proFile)
    print (Execute.getCommandResult(args, fu.HamsiManagerDirectory))

    print ("Translation files have been updated successfully.")



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

                ReportBug.ReportBug()
Exemplo n.º 28
0
    for fileName in [
            "Languages" + fu.sep + "HamsiManager_tr_TR.ts",
            "Languages" + fu.sep + "HamsiManager_untranslated.ts"
    ]:
        TRANSLATIONS += fileName + " \\\n         "

    proFileContent = proFileContent.replace("%SOURCES%", SOURCES)
    proFileContent = proFileContent.replace("%TRANSLATIONS%", TRANSLATIONS)

    fu.writeToFile(proFile, proFileContent)

    args = ["pylupdate4"]
    #args.append("-noobsolete") # Uncomment me if you want to remove old translations from .ts files.
    args.append("-verbose")
    args.append(proFile)

    print(Execute.getCommandResult(args, fu.HamsiManagerDirectory))

    proFileContent = proFileContent.replace(
        "Languages" + fu.sep + "HamsiManager_untranslated.ts \\\n         ",
        "")
    fu.writeToFile(proFile, proFileContent)

    args = ["lrelease"]
    args.append("-compress")
    args.append(proFile)
    print(Execute.getCommandResult(args, fu.HamsiManagerDirectory))

    print("Translation files have been updated successfully.")
Exemplo n.º 29
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()
Exemplo n.º 30
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(translate("MenuBar", "Open State Of Hamsi Manager"),
                                        fu.userDirectoryPath,
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(translate("MenuBar", "Save State Of Hamsi Manager"),
                                        fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(translate("MenuBar", "Current State Saved"),
                             translate("MenuBar",
                                       "Current state saved with preferences.<br>You can continue where you left off."))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree",
                               "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText",
                               "fileTree", "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Scripts.runScriptFile(fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 31
0
def installThisPlugin():
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

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

    #if isAlreadyInstalled:
    #    return "AlreadyInstalled"
    return True
Exemplo n.º 32
0
        def finish(self):
            try:
                if fu.isFile(
                        fu.joinPath(self.installationDirectory,
                                    "HamsiManager.desktop")):
                    MyConfigure.reConfigureFile(
                        fu.joinPath(self.installationDirectory,
                                    "HamsiManager.desktop"),
                        self.installationDirectory)
                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"),
                                self.installationDirectory)
                        else:
                            fileContent = MyConfigure.getConfiguredDesktopFileContent(
                                self.installationDirectory)
                            fu.writeToFile(
                                fu.joinPath(desktopPath,
                                            "HamsiManager.desktop"),
                                fileContent)
                if self.isCreateExecutableLink is not None:
                    executableLink = str(self.leExecutableLink.text())
                    if self.isCreateExecutableLink.checkState() == Mt.Checked:
                        if executableLink.strip() != "":
                            executableLink = fu.checkNewDestination(
                                executableLink)
                            if executableLink:
                                HamsiManagerFileName = Execute.findExecutableBaseName(
                                    "HamsiManager")
                                fu.createSymLink(
                                    fu.joinPath(self.installationDirectory,
                                                HamsiManagerFileName),
                                    executableLink)
                                Settings.setUniversalSetting(
                                    "HamsiManagerExecutableLinkPath",
                                    executableLink)
                        if fu.isDir("/usr/share/applications/"):
                            fileContent = MyConfigure.getConfiguredDesktopFileContent(
                                self.installationDirectory)
                            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(
                        self.installationDirectory)
                    fu.writeToFile(
                        fu.joinPath(fu.userDirectoryPath, ".local",
                                    "applications", "HamsiManager.desktop"),
                        fileContent)
                self.isInstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
Exemplo n.º 33
0
                    fileContent = MyConfigure.getConfiguredDesktopFileContent(self.installationDirectory)
                    fu.writeToFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"),
                                   fileContent)
                self.isInstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()

    if uni.isRunningAsRoot() is False and uni.isRunableAsRoot():
        answer = Dialogs.askSpecial(translate("Install", "Are You Want To Run As Root?"), translate("Install",
                                                                                                    "Hamsi Manager Installer is running with user privileges.<br>Do you want to run Hamsi Manager installer with root rights?<br><b>Note: </b>The other users on your system has to inherit these permissions and install the program to a location other than their /home directories."),
                                    translate("Install", "Yes"), translate("Install", "No (Continue as is)"), None)
        if answer == translate("Install", "Yes"):
            NewApp = Execute.executeAsRootWithThread([], "HamsiManagerInstaller")
            sys.exit()
    try:
        MainWidget = Main()
        MainWidget.setWindowTitle(translate("Install", "Hamsi Manager Installer") + " " + uni.version)
        MainWidget.setGeometry(300, 300, 650, 350)
        MainWidget.show()
        uni.isStartingSuccessfully = True
    except:
        from Core import ReportBug

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

                ReportBug.ReportBug()
Exemplo n.º 35
0
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()

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

        ReportBug.ReportBug()
    sys.exit(HamsiManagerApp.exec_())
else:
Exemplo n.º 36
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(
                translate("MenuBar", "Open State Of Hamsi Manager"),
                fu.userDirectoryPath,
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(
                translate("MenuBar", "Save State Of Hamsi Manager"),
                fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(
                    translate("MenuBar", "Current State Saved"),
                    translate(
                        "MenuBar",
                        "Current state saved with preferences.<br>You can continue where you left off."
                    ))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(
                ["--sDirectoryPath", fu.pathOfSettingsDirectory],
                    "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "html", "fileTree", "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "plainText", "fileTree",
                               "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Scripts.runScriptFile(
                fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 37
0
def uninstallThisPlugin():
    isAlreadyUninstalled = False
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

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

    if isAlreadyUninstalled:
        return "isAlreadyUninstalled"
    return True
Exemplo n.º 38
0
def uninstallThisPlugin():
    isAlreadyUninstalled = False
    if uni.isPython3k:
        import winreg
    else:
        import _winreg as winreg
    executeCommandOfHamsiManager = Execute.getExecuteCommandOfHamsiManager()
    iconPath = fu.joinPath(fu.themePath, "Images", "HamsiManager-16x16-1.ico")

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

    if isAlreadyUninstalled:
        return "isAlreadyUninstalled"
    return True
Exemplo n.º 39
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(
                                 _path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(
                             _path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(
                             translate("Details", "File Is Not Supported"),
                             str(
                                 translate(
                                     "Details",
                                     "\"%s\" couldn't opened. This file is not supported."
                                 )) % Organizer.getLink(str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(
                         translate("Details",
                                   "Directories Is Not Supported"),
                         str(
                             translate(
                                 "Details",
                                 "\"%s\" couldn't opened. Directories is not supported to show details."
                             )) % Organizer.getLink(str(_filePath)))
             else:
                 Dialogs.showError(
                     translate("Details", "File Is Not Exist"),
                     str(
                         translate(
                             "Details",
                             "\"%s\" couldn't opened. This file is not exist."
                         )) % Organizer.getLink(str(_filePath)))
     except:
         answer = Dialogs.askSpecial(
             translate("Details", "File Couldn't Opened"),
             str(
                 translate(
                     "Details",
                     "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us."
                 )) % Organizer.getLink(str(_filePath)),
             translate("QuickMake", "Report This Bug"),
             translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Exemplo n.º 40
0
def checkCommandLineOptions():
    global isQuickMake, QuickMakeParameters, myArgvs, parser, optionList
    myArgvs = sys.argv
    isDontRun = False
    optionList = []
    parser = OptionParser(usage="%prog [options] [<arg1>...]",
                          version="HamsiManager " + uni.version,
                          epilog="""\
Copyright (c) 2010 - 2015 Murat Demir <*****@*****.**> ,
HamsiManager is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.""")
    parser.add_option('-d',
                      '--debug',
                      help='Enable debugging output. '
                      'Chatty',
                      action='store_const',
                      const=logging.DEBUG,
                      dest='loggingLevel')
    optionList.append("d")
    optionList.append("debug")
    parser.add_option('-v',
                      '--verbose',
                      help='Enable informative output',
                      action='store_const',
                      const=logging.INFO,
                      dest='loggingLevel')
    optionList.append("v")
    optionList.append("verbose")
    parser.add_option('--directory',
                      help='The current directory path. '
                      'Example : /home/yourname/someDirectory ')
    optionList.append("directory <directory>")
    parser.add_option(
        '-s',
        '--sFileName',
        help='The setting file name(or path). '
        '"The settings directory path" + "/" + "YourEnteredName" '
        'Example : enteredName.ini ')
    optionList.append("s <settingFile>")
    optionList.append("sFileName <settingFile>")
    parser.add_option('--sDirectoryPath',
                      help='The settings directory path. '
                      'Example : /home/yourname/.HamsiApps/HamsiManager ')
    optionList.append("sDirectoryPath <settingDirectory>")
    parser.add_option('-t',
                      '--tableType',
                      help='Table Type Name. '
                      'Example : "0" for Folder Table '
                      'Example : "1" for File Table '
                      'Example : "2" for Music Table '
                      'Example : "3" for Subfolder Table '
                      'Example : "4" for Cover Table ')
    optionList.append("t <tableTypeNo>")
    optionList.append("tableType <tableTypeNo>")
    parser.add_option('-f',
                      '--fileReNamerType',
                      help='File Renamer Type. '
                      'Example : "Personal Computer" '
                      'Example : "Web Server" '
                      'Example : "Removable Media" ')
    optionList.append("f <fileReNamerTypeNo>")
    optionList.append("fileReNamerType <fileReNamerTypeNo>")
    qmgroup = OptionGroup(parser, "Quick Make Options",
                          "You can make quickly what are you want.")
    qmgroup.add_option('--qmw',
                       help='Are you want to show Quick Make Window. '
                       'Example : "1" or "True" for Yes '
                       'Example : "0" or "False" for No ')
    optionList.append("qmw <o>")
    qmgroup.add_option(
        '--qm',
        help='Are you want to run Quick Make by some parameters?',
        action='store_const',
        const=True)
    optionList.append("qm")
    qmgroup.add_option('--configurator',
                       help='Open Hamsi Manager Configurator',
                       action='store_const',
                       const=True)
    optionList.append("configurator")
    qmgroup.add_option('--plugins',
                       help='Show plugins',
                       action='store_const',
                       const=True)
    optionList.append("plugins")
    qmgroup.add_option('--pack',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("pack <directory>")
    qmgroup.add_option('--hash',
                       help='The file path. '
                       'Example : /home/yourname/someFile')
    optionList.append("hash <file>")
    qmgroup.add_option('--checkIcon',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("checkIcon <directory>")
    qmgroup.add_option('--clearEmptyDirectories',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("clearEmptyDirectories <directory>")
    qmgroup.add_option('--clearUnneededs',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("clearUnneededs <directory>")
    qmgroup.add_option('--clearIgnoreds',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("clearIgnoreds <directory>")
    qmgroup.add_option('--emendFile',
                       help='The file path. '
                       'Example : /home/yourname/someFile')
    optionList.append("emendFile <file>")
    qmgroup.add_option('--emendDirectory',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("emendDirectory <directory>")
    qmgroup.add_option('--emendDirectoryWithContents',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("emendDirectoryWithContents <directory>")
    qmgroup.add_option('--copyPath',
                       help='The file/directory path. '
                       'Example : /home/yourname/somePath')
    optionList.append("copyPath <fileOrDirectory>")
    qmgroup.add_option('--fileTree',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("fileTree <directory>")
    qmgroup.add_option('--removeOnlySubFiles',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("removeOnlySubFiles <directory>")
    qmgroup.add_option('--clear',
                       help='The directory path. '
                       'Example : /home/yourname/someDirectory')
    optionList.append("clear <directory>")
    qmgroup.add_option('--textCorrector',
                       help='The file path. '
                       'Example : /home/yourname/someFile')
    optionList.append("textCorrector <file>")
    qmgroup.add_option('--search',
                       help='The file/directory path. '
                       'Example : /home/yourname/somePath')
    optionList.append("search <fileOrDirectory>")
    dgroup = OptionGroup(
        parser, "Dangerous Options",
        "Caution: use these options at your own risk.  "
        "It is believed that some of them bite.")
    dgroup.add_option('--runAsRoot',
                      help='Are you want to run as root?',
                      action='store_const',
                      const=True)
    optionList.append("runAsRoot")
    optionList.append("+[optionalFileOrDirectory]")
    parser.add_option_group(qmgroup)
    parser.add_option_group(dgroup)
    parser.set_defaults(loggingLevel=logging.WARNING,
                        runAsRoot=False,
                        qm=False,
                        plugins=False)
    options, remainderParameters = parser.parse_args()
    if len(remainderParameters) == 1:
        try:
            uni.setMySetting(
                "lastDirectory",
                uni.trDecode(str(remainderParameters[0]),
                             fu.defaultFileSystemEncoding))
        except:
            uni.setMySetting("lastDirectory", str(remainderParameters[0]))
    if options.directory:
        try:
            uni.setMySetting(
                "lastDirectory",
                uni.trDecode(str(options.directory),
                             fu.defaultFileSystemEncoding))
        except:
            uni.setMySetting("lastDirectory", str(options.directory))
    if options.loggingLevel:
        uni.loggingLevel = options.loggingLevel
    if options.sFileName:
        uni.fileOfSettings = options.sFileName
    if options.sDirectoryPath:
        uni.setPathOfSettingsDirectory(options.sDirectoryPath)
    if options.tableType:
        import Tables

        uni.setMySetting("tableType",
                         Tables.Tables.getThisTableType(options.tableType))
    if options.fileReNamerType:
        uni.setMySetting("fileReNamerType", options.fileReNamerType)
    if options.qm:
        if options.qmw:
            if options.qmw.lower() == "false" or options.qmw == "0":
                uni.setMySetting("isShowQuickMakeWindow", False)
            else:
                uni.setMySetting("isShowQuickMakeWindow", True)
        if options.configurator:
            QuickMakeParameters.append("configurator")
            isQuickMake = True
        elif options.plugins:
            QuickMakeParameters.append("plugins")
            isQuickMake = True
        elif options.pack:
            QuickMakeParameters.append("pack")
            QuickMakeParameters.append(options.pack)
            isQuickMake = True
        elif options.hash:
            QuickMakeParameters.append("hash")
            QuickMakeParameters.append(options.hash)
            isQuickMake = True
        elif options.checkIcon:
            QuickMakeParameters.append("checkIcon")
            QuickMakeParameters.append(options.checkIcon)
            isQuickMake = True
        elif options.clearEmptyDirectories:
            QuickMakeParameters.append("clearEmptyDirectories")
            QuickMakeParameters.append(options.clearEmptyDirectories)
            isQuickMake = True
        elif options.clearUnneededs:
            QuickMakeParameters.append("clearUnneededs")
            QuickMakeParameters.append(options.clearUnneededs)
            isQuickMake = True
        elif options.clearIgnoreds:
            QuickMakeParameters.append("clearIgnoreds")
            QuickMakeParameters.append(options.clearIgnoreds)
            isQuickMake = True
        elif options.emendFile:
            QuickMakeParameters.append("emendFile")
            QuickMakeParameters.append(options.emendFile)
            isQuickMake = True
        elif options.emendDirectory:
            QuickMakeParameters.append("emendDirectory")
            QuickMakeParameters.append(options.emendDirectory)
            isQuickMake = True
        elif options.emendDirectoryWithContents:
            QuickMakeParameters.append("emendDirectoryWithContents")
            QuickMakeParameters.append(options.emendDirectoryWithContents)
            isQuickMake = True
        elif options.copyPath:
            QuickMakeParameters.append("copyPath")
            QuickMakeParameters.append(options.copyPath)
            isQuickMake = True
        elif options.fileTree:
            QuickMakeParameters.append("fileTree")
            QuickMakeParameters.append(options.fileTree)
            isQuickMake = True
        elif options.removeOnlySubFiles:
            QuickMakeParameters.append("removeOnlySubFiles")
            QuickMakeParameters.append(options.removeOnlySubFiles)
            isQuickMake = True
        elif options.clear:
            QuickMakeParameters.append("clear")
            QuickMakeParameters.append(options.clear)
            isQuickMake = True
        elif options.textCorrector:
            QuickMakeParameters.append("textCorrector")
            QuickMakeParameters.append(options.textCorrector)
            isQuickMake = True
        elif options.search:
            QuickMakeParameters.append("search")
            QuickMakeParameters.append(options.search)
            isQuickMake = True
        QuickMakeParameters.append(remainderParameters)
    if options.runAsRoot:
        from Core import Execute

        if uni.isRunningAsRoot() is False:
            strArgvs = []
            for tempArg in sys.argv:
                if (tempArg.find("-runAsRoot") == -1 and tempArg.find(
                        Execute.findExecutablePath("HamsiManager")) == -1
                        and tempArg !=
                        "./" + Execute.findExecutableBaseName("HamsiManager")
                        and tempArg !=
                        Execute.findExecutableBaseName("HamsiManager")):
                    strArgvs.append(tempArg)
            if Execute.executeAsRootWithThread(strArgvs, "HamsiManager"):
                isDontRun = True
    if isDontRun:
        return False
    return True
Exemplo n.º 41
0
def checkCommandLineOptions():
    global isQuickMake, QuickMakeParameters, myArgvs, parser, optionList
    myArgvs = sys.argv
    isDontRun = False
    optionList = []
    parser = OptionParser(
        usage="%prog [options] [<arg1>...]", version="HamsiManager " + uni.version,

        epilog="""\
Copyright (c) 2010 - 2015 Murat Demir <*****@*****.**> ,
HamsiManager is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.""")
    parser.add_option('-d', '--debug', help='Enable debugging output. '
                                            'Chatty', action='store_const', const=logging.DEBUG,
                      dest='loggingLevel')
    optionList.append("d")
    optionList.append("debug")
    parser.add_option('-v', '--verbose', help='Enable informative output',
                      action='store_const', const=logging.INFO,
                      dest='loggingLevel')
    optionList.append("v")
    optionList.append("verbose")
    parser.add_option('--directory',
                      help='The current directory path. '
                           'Example : /home/yourname/someDirectory ')
    optionList.append("directory <directory>")
    parser.add_option('-s', '--sFileName',
                      help='The setting file name(or path). '
                           '"The settings directory path" + "/" + "YourEnteredName" '
                           'Example : enteredName.ini ')
    optionList.append("s <settingFile>")
    optionList.append("sFileName <settingFile>")
    parser.add_option('--sDirectoryPath',
                      help='The settings directory path. '
                           'Example : /home/yourname/.HamsiApps/HamsiManager ')
    optionList.append("sDirectoryPath <settingDirectory>")
    parser.add_option('-t', '--tableType',
                      help='Table Type Name. '
                           'Example : "0" for Folder Table '
                           'Example : "1" for File Table '
                           'Example : "2" for Music Table '
                           'Example : "3" for Subfolder Table '
                           'Example : "4" for Cover Table ')
    optionList.append("t <tableTypeNo>")
    optionList.append("tableType <tableTypeNo>")
    parser.add_option('-f', '--fileReNamerType',
                      help='File Renamer Type. '
                           'Example : "Personal Computer" '
                           'Example : "Web Server" '
                           'Example : "Removable Media" ')
    optionList.append("f <fileReNamerTypeNo>")
    optionList.append("fileReNamerType <fileReNamerTypeNo>")
    qmgroup = OptionGroup(parser, "Quick Make Options",
                          "You can make quickly what are you want.")
    qmgroup.add_option('--qmw',
                       help='Are you want to show Quick Make Window. '
                            'Example : "1" or "True" for Yes '
                            'Example : "0" or "False" for No ')
    optionList.append("qmw <o>")
    qmgroup.add_option('--qm', help='Are you want to run Quick Make by some parameters?',
                       action='store_const', const=True)
    optionList.append("qm")
    qmgroup.add_option('--configurator', help='Open Hamsi Manager Configurator', action='store_const', const=True)
    optionList.append("configurator")
    qmgroup.add_option('--plugins', help='Show plugins', action='store_const', const=True)
    optionList.append("plugins")
    qmgroup.add_option('--pack',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("pack <directory>")
    qmgroup.add_option('--hash',
                       help='The file path. '
                            'Example : /home/yourname/someFile')
    optionList.append("hash <file>")
    qmgroup.add_option('--checkIcon',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("checkIcon <directory>")
    qmgroup.add_option('--clearEmptyDirectories',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("clearEmptyDirectories <directory>")
    qmgroup.add_option('--clearUnneededs',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("clearUnneededs <directory>")
    qmgroup.add_option('--clearIgnoreds',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("clearIgnoreds <directory>")
    qmgroup.add_option('--emendFile',
                       help='The file path. '
                            'Example : /home/yourname/someFile')
    optionList.append("emendFile <file>")
    qmgroup.add_option('--emendDirectory',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("emendDirectory <directory>")
    qmgroup.add_option('--emendDirectoryWithContents',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("emendDirectoryWithContents <directory>")
    qmgroup.add_option('--copyPath',
                       help='The file/directory path. '
                            'Example : /home/yourname/somePath')
    optionList.append("copyPath <fileOrDirectory>")
    qmgroup.add_option('--fileTree',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("fileTree <directory>")
    qmgroup.add_option('--removeOnlySubFiles',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("removeOnlySubFiles <directory>")
    qmgroup.add_option('--clear',
                       help='The directory path. '
                            'Example : /home/yourname/someDirectory')
    optionList.append("clear <directory>")
    qmgroup.add_option('--textCorrector',
                       help='The file path. '
                            'Example : /home/yourname/someFile')
    optionList.append("textCorrector <file>")
    qmgroup.add_option('--search',
                       help='The file/directory path. '
                            'Example : /home/yourname/somePath')
    optionList.append("search <fileOrDirectory>")
    dgroup = OptionGroup(parser, "Dangerous Options",
                         "Caution: use these options at your own risk.  "
                         "It is believed that some of them bite.")
    dgroup.add_option('--runAsRoot', help='Are you want to run as root?',
                      action='store_const', const=True)
    optionList.append("runAsRoot")
    optionList.append("+[optionalFileOrDirectory]")
    parser.add_option_group(qmgroup)
    parser.add_option_group(dgroup)
    parser.set_defaults(loggingLevel=logging.WARNING, runAsRoot=False, qm=False, plugins=False)
    options, remainderParameters = parser.parse_args()
    if len(remainderParameters) == 1:
        try:
            uni.setMySetting("lastDirectory", uni.trDecode(str(remainderParameters[0]), fu.defaultFileSystemEncoding))
        except:
            uni.setMySetting("lastDirectory", str(remainderParameters[0]))
    if options.directory:
        try:
            uni.setMySetting("lastDirectory", uni.trDecode(str(options.directory), fu.defaultFileSystemEncoding))
        except:
            uni.setMySetting("lastDirectory", str(options.directory))
    if options.loggingLevel:
        uni.loggingLevel = options.loggingLevel
    if options.sFileName:
        uni.fileOfSettings = options.sFileName
    if options.sDirectoryPath:
        uni.setPathOfSettingsDirectory(options.sDirectoryPath)
    if options.tableType:
        import Tables

        uni.setMySetting("tableType", Tables.Tables.getThisTableType(options.tableType))
    if options.fileReNamerType:
        uni.setMySetting("fileReNamerType", options.fileReNamerType)
    if options.qm:
        if options.qmw:
            if options.qmw.lower() == "false" or options.qmw == "0":
                uni.setMySetting("isShowQuickMakeWindow", False)
            else:
                uni.setMySetting("isShowQuickMakeWindow", True)
        if options.configurator:
            QuickMakeParameters.append("configurator")
            isQuickMake = True
        elif options.plugins:
            QuickMakeParameters.append("plugins")
            isQuickMake = True
        elif options.pack:
            QuickMakeParameters.append("pack")
            QuickMakeParameters.append(options.pack)
            isQuickMake = True
        elif options.hash:
            QuickMakeParameters.append("hash")
            QuickMakeParameters.append(options.hash)
            isQuickMake = True
        elif options.checkIcon:
            QuickMakeParameters.append("checkIcon")
            QuickMakeParameters.append(options.checkIcon)
            isQuickMake = True
        elif options.clearEmptyDirectories:
            QuickMakeParameters.append("clearEmptyDirectories")
            QuickMakeParameters.append(options.clearEmptyDirectories)
            isQuickMake = True
        elif options.clearUnneededs:
            QuickMakeParameters.append("clearUnneededs")
            QuickMakeParameters.append(options.clearUnneededs)
            isQuickMake = True
        elif options.clearIgnoreds:
            QuickMakeParameters.append("clearIgnoreds")
            QuickMakeParameters.append(options.clearIgnoreds)
            isQuickMake = True
        elif options.emendFile:
            QuickMakeParameters.append("emendFile")
            QuickMakeParameters.append(options.emendFile)
            isQuickMake = True
        elif options.emendDirectory:
            QuickMakeParameters.append("emendDirectory")
            QuickMakeParameters.append(options.emendDirectory)
            isQuickMake = True
        elif options.emendDirectoryWithContents:
            QuickMakeParameters.append("emendDirectoryWithContents")
            QuickMakeParameters.append(options.emendDirectoryWithContents)
            isQuickMake = True
        elif options.copyPath:
            QuickMakeParameters.append("copyPath")
            QuickMakeParameters.append(options.copyPath)
            isQuickMake = True
        elif options.fileTree:
            QuickMakeParameters.append("fileTree")
            QuickMakeParameters.append(options.fileTree)
            isQuickMake = True
        elif options.removeOnlySubFiles:
            QuickMakeParameters.append("removeOnlySubFiles")
            QuickMakeParameters.append(options.removeOnlySubFiles)
            isQuickMake = True
        elif options.clear:
            QuickMakeParameters.append("clear")
            QuickMakeParameters.append(options.clear)
            isQuickMake = True
        elif options.textCorrector:
            QuickMakeParameters.append("textCorrector")
            QuickMakeParameters.append(options.textCorrector)
            isQuickMake = True
        elif options.search:
            QuickMakeParameters.append("search")
            QuickMakeParameters.append(options.search)
            isQuickMake = True
        QuickMakeParameters.append(remainderParameters)
    if options.runAsRoot:
        from Core import Execute

        if uni.isRunningAsRoot() is False:
            strArgvs = []
            for tempArg in sys.argv:
                if (tempArg.find("-runAsRoot") == -1 and
                    tempArg.find(Execute.findExecutablePath("HamsiManager")) == -1 and
                    tempArg != "./" + Execute.findExecutableBaseName("HamsiManager") and
                    tempArg != Execute.findExecutableBaseName("HamsiManager")):
                    strArgvs.append(tempArg)
            if Execute.executeAsRootWithThread(strArgvs, "HamsiManager"):
                isDontRun = True
    if isDontRun:
        return False
    return True