예제 #1
0
 def __init__(self, _parent):
     MStatusBar.__init__(self, _parent)
     if uni.isRunningAsRoot():
         lblInfo = MLabel(str("<span style=\"color: #FF0000\">" + translate("StatusBar",
                                                                            "Hamsi Manager running as root") + "</span>"))
         self.addWidget(lblInfo)
     self.tableInfo = ""
     self.connectionToCancel = None
     self.lblInfo = MLabel("")
     self.hideInfo()
     self.addWidget(self.lblInfo)
     self.prgbState = MProgressBar()
     self.prgbState.setMinimumWidth(200)
     self.pbtnCancel = MPushButton(translate("StatusBar", "Cancel"))
     self.prgbState.setVisible(False)
     self.pbtnCancel.setVisible(False)
     self.addWidget(self.prgbState)
     self.addWidget(self.pbtnCancel)
     self.addWidget(MLabel(""), 100)
     self.lblTableInfo = MLabel("")
     self.lblImportantInfo = MLabel("")
     self.lblSelectionInfo = MLabel("")
     self.addWidget(self.lblTableInfo)
     self.addWidget(self.lblImportantInfo)
     self.addWidget(self.lblSelectionInfo)
     self.fillSelectionInfo()
예제 #2
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()
예제 #3
0
def installKDE4Language(_language="tr_TR"):
    if uni.isAvailableKDE4():
        KDELocalateDir = fu.joinPath(uni.getKDE4HomePath(), "share", "locale", str(_language[:2]), "LC_MESSAGES")
        if uni.isRunningAsRoot():
            KDELocalateDir = fu.joinPath("/usr", "share", "locale", str(_language[:2]), "LC_MESSAGES")
        KDELocalateDir = str(KDELocalateDir)
        langFile = fu.joinPath(fu.HamsiManagerDirectory, "Languages", "DontTranslate", str(_language),
                               "HamsiManager.mo")
        if fu.isFile(fu.joinPath(KDELocalateDir, "HamsiManager.mo")) is False:
            if fu.isFile(langFile):
                if fu.isDir(KDELocalateDir) is False:
                    fu.makeDirs(KDELocalateDir)
                fu.copyFileOrDir(langFile, fu.joinPath(KDELocalateDir, "HamsiManager.mo"))
        return True
    return False
예제 #4
0
def uninstallThisPlugin():
    isAlreadyuninstalled = True
    if uni.isRunningAsRoot():
        destinationPath = "/usr/share/apps/krusader/"
    else:
        destinationPath = uni.getKDE4HomePath() + "/share/apps/krusader/"
    if fu.isFile(fu.joinPath(destinationPath, "useractions.xml")):
        import xml.etree.ElementTree as ET

        doc = ET.parse(fu.joinPath(destinationPath, "useractions.xml"))
        KrusaderUserActions = doc.getroot()
        actions = doc.findall("action")
        for act in doc.findall("action"):
            if act.get("name").find("hamsimanager") != -1:
                KrusaderUserActions.remove(act)
                isAlreadyuninstalled = False
        actions = doc.findall("action")
        doc.write(fu.joinPath(destinationPath, "useractions.xml"))
    if isAlreadyuninstalled:
        return "AlreadyUninstalled"
    return True
예제 #5
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()
예제 #6
0
        def finish(self):
            try:
                if uni.isRunningAsRoot():
                    executableLink = Settings.getUniversalSetting("HamsiManagerExecutableLinkPath",
                                                                  str("/usr/bin/hamsi"))
                    if fu.isFile(executableLink) or fu.isLink(executableLink):
                        fu.removeFileOrDir(executableLink)
                else:
                    desktopPath = uni.getUserDesktopPath()
                    if uni.isWindows:
                        if fu.isFile(fu.joinPath(desktopPath, "Hamsi Manager.lnk")):
                            fu.removeFileOrDir(fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                    else:
                        if fu.isFile(fu.joinPath(desktopPath, "HamsiManager.desktop")):
                            fu.removeFileOrDir(fu.joinPath(desktopPath, "HamsiManager.desktop"))
                    if fu.isFile(fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop")):
                        fu.removeFileOrDir(
                            fu.joinPath(fu.userDirectoryPath, ".local", "applications", "HamsiManager.desktop"))
                self.isUninstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
예제 #7
0
        def finish(self):
            try:
                if uni.isRunningAsRoot():
                    executableLink = Settings.getUniversalSetting(
                        "HamsiManagerExecutableLinkPath",
                        str("/usr/bin/hamsi"))
                    if fu.isFile(executableLink) or fu.isLink(executableLink):
                        fu.removeFileOrDir(executableLink)
                else:
                    desktopPath = uni.getUserDesktopPath()
                    if uni.isWindows:
                        if fu.isFile(
                                fu.joinPath(desktopPath, "Hamsi Manager.lnk")):
                            fu.removeFileOrDir(
                                fu.joinPath(desktopPath, "Hamsi Manager.lnk"))
                    else:
                        if fu.isFile(
                                fu.joinPath(desktopPath,
                                            "HamsiManager.desktop")):
                            fu.removeFileOrDir(
                                fu.joinPath(desktopPath,
                                            "HamsiManager.desktop"))
                    if fu.isFile(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop")):
                        fu.removeFileOrDir(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop"))
                self.isUninstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()
예제 #8
0
 def createPage(self, _pageNo):
     pnlPage = MWidget()
     HBox = MHBoxLayout()
     pnlPage.setLayout(HBox)
     if _pageNo == 0:
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode)):
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode), "utf-8")
         else:
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_en_GB"), "utf-8")
         lblAbout = MLabel(str(aboutFileContent))
         lblAbout.setWordWrap(True)
         HBox.addWidget(lblAbout)
     elif _pageNo == 1:
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode)):
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode), "utf-8")
         else:
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_en_GB"), "utf-8")
         teCopying = MTextEdit()
         teCopying.setPlainText(str(licenceFileContent))
         HBox.addWidget(teCopying)
     elif _pageNo == 2:
         lblPleaseSelect = MLabel(translate("Install", "Please Select A Folder For Installation."))
         installationDirPath = Settings.getUniversalSetting("HamsiManagerPath", None)
         if installationDirPath is not None:
             installationDirPath = fu.getDirName(installationDirPath)
         else:
             installationDirPath = fu.joinPath(fu.getDirName(fu.HamsiManagerDirectory), "Hamsi")
         self.leInstallationDirectory = MLineEdit(
             str(Settings.getUniversalSetting("pathOfInstallationDirectory", str(installationDirPath))))
         self.pbtnSelectInstallationDirectory = MPushButton(translate("Install", "Browse"))
         self.connect(self.pbtnSelectInstallationDirectory, SIGNAL("clicked()"),
                      self.selectInstallationDirectory)
         VBox = MVBoxLayout()
         VBox.addStretch(10)
         VBox.addWidget(lblPleaseSelect)
         HBox1 = MHBoxLayout()
         HBox1.addWidget(self.leInstallationDirectory)
         HBox1.addWidget(self.pbtnSelectInstallationDirectory)
         VBox.addLayout(HBox1)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     elif _pageNo == 3:
         VBox = MVBoxLayout()
         self.lblActions = MLabel("")
         self.prgbState = MProgressBar()
         VBox.addWidget(self.lblActions)
         VBox.addWidget(self.prgbState)
         HBox.addLayout(VBox)
     elif _pageNo == 4:
         VBox = MVBoxLayout()
         self.lblFinished = MLabel(translate("Install", "Installation Complete."))
         VBox.addStretch(10)
         VBox.addWidget(self.lblFinished)
         VBox.addStretch(2)
         self.isCreateDesktopShortcut = None
         self.isCreateExecutableLink = None
         if uni.isRunningAsRoot():
             self.isCreateExecutableLink = MCheckBox(translate("Install", "Add To The System"))
             self.isCreateExecutableLink.setCheckState(Mt.Checked)
             lblExecutableLink = MLabel(translate("Install", "Executable Link Path : "))
             self.leExecutableLink = MLineEdit(
                 str(Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")))
             self.connect(self.isCreateExecutableLink, SIGNAL("stateChanged(int)"),
                          self.createExecutableLinkChanged)
             VBox.addWidget(self.isCreateExecutableLink)
             HBox1 = MHBoxLayout()
             HBox1.addWidget(lblExecutableLink)
             HBox1.addWidget(self.leExecutableLink)
             VBox.addLayout(HBox1)
         else:
             self.isCreateDesktopShortcut = MCheckBox(translate("Install", "Create Desktop Shortcut."))
             self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
             VBox.addWidget(self.isCreateDesktopShortcut)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     return pnlPage
예제 #9
0
                            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()

    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
예제 #10
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()
예제 #11
0
    def createPage(self, _pageNo):
        pnlPage = MWidget()
        HBox = MHBoxLayout()
        pnlPage.setLayout(HBox)
        defaultLangCode = uni.getDefaultLanguageCode()
        if _pageNo == 0:
            if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode)):
                aboutFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode), "utf-8")
            else:
                aboutFileContent = fu.readFromFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_en_GB"),
                                                   "utf-8")
            lblAbout = MLabel(str(aboutFileContent))
            lblAbout.setWordWrap(True)
            HBox.addWidget(lblAbout)
        elif _pageNo == 1:
            if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode)):
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode), "utf-8")
            else:
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_en_GB"), "utf-8")
            teCopying = MTextEdit()
            teCopying.setPlainText(str(licenceFileContent))
            HBox.addWidget(teCopying)
        elif _pageNo == 2:
            VBox = MVBoxLayout()
            VBox.addStretch(10)
            self.isCreateDesktopShortcut = None
            self.isCreateExecutableLink = None
            self.wAvailableModules = MWidget(self)
            VBox.addWidget(self.wAvailableModules)
            self.vblAvailableModules = MVBoxLayout()
            self.checkAvailableModules()
            VBox.addStretch(1)
            if uni.isRunningAsRoot():
                self.isCreateExecutableLink = MCheckBox(translate("Reconfigure", "Add To The System"))
                self.isCreateExecutableLink.setCheckState(Mt.Checked)
                lblExecutableLink = MLabel(translate("Reconfigure", "Executable Link Path : "))
                self.leExecutableLink = MLineEdit(
                    str(Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")))
                self.connect(self.isCreateExecutableLink, SIGNAL("stateChanged(int)"), self.createExecutableLinkChanged)
                VBox.addWidget(self.isCreateExecutableLink)
                HBox1 = MHBoxLayout()
                HBox1.addWidget(lblExecutableLink)
                HBox1.addWidget(self.leExecutableLink, 10)
                VBox.addLayout(HBox1)
            else:
                self.isCreateDesktopShortcut = MCheckBox(translate("Reconfigure", "Create Desktop Shortcut."))
                self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
                VBox.addWidget(self.isCreateDesktopShortcut)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        elif _pageNo == 3:
            import MyPlugins

            VBox = MVBoxLayout()
            VBox.addStretch(10)
            wPlugins = MyPlugins.MyPluginsForSystem(self)
            HBox.addWidget(wPlugins)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        return pnlPage
예제 #12
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()
예제 #13
0
    def createPage(self, _pageNo):
        pnlPage = MWidget()
        HBox = MHBoxLayout()
        pnlPage.setLayout(HBox)
        defaultLangCode = uni.getDefaultLanguageCode()
        if _pageNo == 0:
            if fu.isFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "About_" + defaultLangCode)):
                aboutFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "About_" + defaultLangCode), "utf-8")
            else:
                aboutFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "About_en_GB"), "utf-8")
            lblAbout = MLabel(str(aboutFileContent))
            lblAbout.setWordWrap(True)
            HBox.addWidget(lblAbout)
        elif _pageNo == 1:
            if fu.isFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "License_" + defaultLangCode)):
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "License_" + defaultLangCode), "utf-8")
            else:
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                                "License_en_GB"), "utf-8")
            teCopying = MTextEdit()
            teCopying.setPlainText(str(licenceFileContent))
            HBox.addWidget(teCopying)
        elif _pageNo == 2:
            VBox = MVBoxLayout()
            VBox.addStretch(10)
            self.isCreateDesktopShortcut = None
            self.isCreateExecutableLink = None
            self.wAvailableModules = MWidget(self)
            VBox.addWidget(self.wAvailableModules)
            self.vblAvailableModules = MVBoxLayout()
            self.checkAvailableModules()
            VBox.addStretch(1)
            if uni.isRunningAsRoot():
                self.isCreateExecutableLink = MCheckBox(
                    translate("Reconfigure", "Add To The System"))
                self.isCreateExecutableLink.setCheckState(Mt.Checked)
                lblExecutableLink = MLabel(
                    translate("Reconfigure", "Executable Link Path : "))
                self.leExecutableLink = MLineEdit(
                    str(
                        Settings.getUniversalSetting(
                            "HamsiManagerExecutableLinkPath",
                            "/usr/bin/hamsi")))
                self.connect(self.isCreateExecutableLink,
                             SIGNAL("stateChanged(int)"),
                             self.createExecutableLinkChanged)
                VBox.addWidget(self.isCreateExecutableLink)
                HBox1 = MHBoxLayout()
                HBox1.addWidget(lblExecutableLink)
                HBox1.addWidget(self.leExecutableLink, 10)
                VBox.addLayout(HBox1)
            else:
                self.isCreateDesktopShortcut = MCheckBox(
                    translate("Reconfigure", "Create Desktop Shortcut."))
                self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
                VBox.addWidget(self.isCreateDesktopShortcut)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        elif _pageNo == 3:
            import MyPlugins

            VBox = MVBoxLayout()
            VBox.addStretch(10)
            wPlugins = MyPlugins.MyPluginsForSystem(self)
            HBox.addWidget(wPlugins)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        return pnlPage
예제 #14
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
예제 #15
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
예제 #16
0
                    if fu.isFile(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop")):
                        fu.removeFileOrDir(
                            fu.joinPath(fu.userDirectoryPath, ".local",
                                        "applications",
                                        "HamsiManager.desktop"))
                self.isUninstallFinished = True
                self.close()
            except:
                from Core import ReportBug

                ReportBug.ReportBug()

    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") + " " +
예제 #17
0
 def createPage(self, _pageNo):
     pnlPage = MWidget()
     HBox = MHBoxLayout()
     pnlPage.setLayout(HBox)
     if _pageNo == 0:
         if fu.isFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "About_" + defaultLangCode)):
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "About_" + defaultLangCode), "utf-8")
         else:
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "About_en_GB"), "utf-8")
         lblAbout = MLabel(str(aboutFileContent))
         lblAbout.setWordWrap(True)
         HBox.addWidget(lblAbout)
     elif _pageNo == 1:
         if fu.isFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "License_" + defaultLangCode)):
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "License_" + defaultLangCode), "utf-8")
         else:
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages",
                             "License_en_GB"), "utf-8")
         teCopying = MTextEdit()
         teCopying.setPlainText(str(licenceFileContent))
         HBox.addWidget(teCopying)
     elif _pageNo == 2:
         lblPleaseSelect = MLabel(
             translate("Install",
                       "Please Select A Folder For Installation."))
         installationDirPath = Settings.getUniversalSetting(
             "HamsiManagerPath", None)
         if installationDirPath is not None:
             installationDirPath = fu.getDirName(installationDirPath)
         else:
             installationDirPath = fu.joinPath(
                 fu.getDirName(fu.HamsiManagerDirectory), "Hamsi")
         self.leInstallationDirectory = MLineEdit(
             str(
                 Settings.getUniversalSetting(
                     "pathOfInstallationDirectory",
                     str(installationDirPath))))
         self.pbtnSelectInstallationDirectory = MPushButton(
             translate("Install", "Browse"))
         self.connect(self.pbtnSelectInstallationDirectory,
                      SIGNAL("clicked()"),
                      self.selectInstallationDirectory)
         VBox = MVBoxLayout()
         VBox.addStretch(10)
         VBox.addWidget(lblPleaseSelect)
         HBox1 = MHBoxLayout()
         HBox1.addWidget(self.leInstallationDirectory)
         HBox1.addWidget(self.pbtnSelectInstallationDirectory)
         VBox.addLayout(HBox1)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     elif _pageNo == 3:
         VBox = MVBoxLayout()
         self.lblActions = MLabel("")
         self.prgbState = MProgressBar()
         VBox.addWidget(self.lblActions)
         VBox.addWidget(self.prgbState)
         HBox.addLayout(VBox)
     elif _pageNo == 4:
         VBox = MVBoxLayout()
         self.lblFinished = MLabel(
             translate("Install", "Installation Complete."))
         VBox.addStretch(10)
         VBox.addWidget(self.lblFinished)
         VBox.addStretch(2)
         self.isCreateDesktopShortcut = None
         self.isCreateExecutableLink = None
         if uni.isRunningAsRoot():
             self.isCreateExecutableLink = MCheckBox(
                 translate("Install", "Add To The System"))
             self.isCreateExecutableLink.setCheckState(Mt.Checked)
             lblExecutableLink = MLabel(
                 translate("Install", "Executable Link Path : "))
             self.leExecutableLink = MLineEdit(
                 str(
                     Settings.getUniversalSetting(
                         "HamsiManagerExecutableLinkPath",
                         "/usr/bin/hamsi")))
             self.connect(self.isCreateExecutableLink,
                          SIGNAL("stateChanged(int)"),
                          self.createExecutableLinkChanged)
             VBox.addWidget(self.isCreateExecutableLink)
             HBox1 = MHBoxLayout()
             HBox1.addWidget(lblExecutableLink)
             HBox1.addWidget(self.leExecutableLink)
             VBox.addLayout(HBox1)
         else:
             self.isCreateDesktopShortcut = MCheckBox(
                 translate("Install", "Create Desktop Shortcut."))
             self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
             VBox.addWidget(self.isCreateDesktopShortcut)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     return pnlPage
예제 #18
0
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Hamsi Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HamsiManager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

from Core.MyObjects import *
from Core import Universals as uni

pluginName = str(translate("MyPlugins/InTheAmarok", "Hamsi Manager In The Amarok"))
pluginVersion = "0.4"
pluginFiles = []
pluginDirectory = "HamsiManagerInTheAmarok"
installThisPlugin = None
uninstallThisPlugin = None

if uni.isRunningAsRoot():
    setupDirectory = "/usr/share/apps/amarok/scripts"
else:
    setupDirectory = uni.getKDE4HomePath() + "/share/apps/amarok/scripts"


def isInstallable():
    return uni.isAvailableKDE4()
예제 #19
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