Beispiel #1
0
def reFillDatabases(_table="All", _actionType="dropAndInsert", _makeBackUp=False):
    if _makeBackUp:
        from Core import Settings

        Settings.makeBackUp(_table)
    tableCreateQueries, sqlCommands, tableInsertImportantQueries = [], [], []
    tableCreateQueries.append(getDBPropertiesCreateQuery())
    for database in getAllDatabases():
        if _table == database.tableName or _table == "All":
            tableCreateQueries.append(database.getTableCreateQuery())
            if _actionType == "dropAndInsert":
                sqlCommands.append(database.getDeleteTableQuery())
            sqlCommands += database.getDefaultsQueries()
            tableInsertImportantQueries += getAmendedSQLInsertOrUpdateQueries("dbProperties", {
                "keyName": "'" + database.tableName + "_Version'", "value": "'" + str(database.tableVersion) + "'"},
                                                                              ["keyName"])
    con = getDefaultConnection()
    for sqlCommand in tableCreateQueries:
        cur = con.cursor()
        cur.execute(str(sqlCommand))
        con.commit()
    for sqlCommand in tableInsertImportantQueries:
        cur = con.cursor()
        cur.execute(str(sqlCommand))
        con.commit()
    for sqlCommand in sqlCommands:
        cur = con.cursor()
        cur.execute(str(sqlCommand))
        con.commit()
Beispiel #2
0
 def uninstallPlugin(self, _pluginName, _isQuiet=False):
     isUninstalled = False
     pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
                               ["pluginName", "pluginFiles", "pluginDirectory", "uninstallThisPlugin",
                                "setupDirectory", "pluginVersion"], 0)
     if pluginModule.uninstallThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             for pluginFile in pluginModule.pluginFiles:
                 if fu.isFile(fu.joinPath(pluginModule.setupDirectory, pluginFile)):
                     fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isUninstalled = True
         else:
             if fu.isDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory)):
                 fu.removeFileOrDir(fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory))
             isUninstalled = True
     else:
         isUninstalled = pluginModule.uninstallThisPlugin()
     if isUninstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(""))
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Uninstallation Is Complete"),
                          str(translate("MyPlugins", "\"%s\" is uninstalled on your system.")) % (
                              pluginModule.pluginName))
     elif isUninstalled == "AlreadyUninstalled":
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Already Uninstalled"),
                          str(translate("MyPlugins", "\"%s\" already uninstalled on your system.")) % (
                              pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(translate("MyPlugins", "Plug-in Uninstallation Failed"),
                               str(translate("MyPlugins", "\"%s\" failed to uninstall on your system.")) % (
                                   pluginModule.pluginName))
 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()
Beispiel #4
0
def fillMySettings(_setAgain=False, _isCheckUpdate=True):
    global MySettings, isShowVerifySettings, changedDefaultValuesKeys, newSettingsKeys, tableType
    from Core import Settings

    sets = Settings.setting()
    currentSettingVersion = trStr(sets.value("settingsVersion"))
    defaultValues = Settings.getDefaultValues()
    valueTypesAndValues = Settings.getValueTypesAndValues()
    for keyValue in Settings.getKeysOfSettings():
        value = trStr(sets.value(keyValue, trQVariant(defaultValues[keyValue])))
        if keyValue not in MySettings.keys() or _setAgain:
            MySettings[keyValue] = str(
                Settings.emendValue(keyValue, value, defaultValues[keyValue], valueTypesAndValues[keyValue]))
    for keyValue in sets.allKeys():
        keyValue = str(keyValue)
        if keyValue not in MySettings.keys():
            value = trStr(sets.value(keyValue, trQVariant("")))
            MySettings[keyValue] = str(Settings.emendValue(keyValue, value, "", "str"))
    newSettingVersion = str(MySettings["settingsVersion"])
    if _isCheckUpdate:
        if str(currentSettingVersion) is not "" and newSettingVersion != currentSettingVersion:
            newSettingsKeys, changedDefaultValuesKeys = Settings.updateOldSettings(currentSettingVersion,
                                                                                   newSettingVersion)
            isShowVerifySettings = True
    fu.fileSystemEncoding = MySettings["fileSystemEncoding"]
    fu.themePath = fu.joinPath(fu.HamsiManagerDirectory, "Themes", MySettings["themeName"])
    if tableType is None:
        tableType = MySettings["tableType"]
        if tableType not in getTableTypesNames():
            tableType = "1"
    if getBoolValue("isInstalledKDE4Language") is False:
        from Core import MyConfigure

        MyConfigure.installKDE4Languages()
Beispiel #5
0
def getValue(_key, _defaultValue=""):
    try:
        return MySettings[_key]
    except:
        from Core import Settings

        sets = Settings.setting()
        MySettings[_key] = str(trStr(sets.value(_key, trQVariant(_defaultValue))))
        return MySettings[_key]
Beispiel #6
0
        def createPage(self, _pageNo):
            pnlPage = MWidget()
            HBox = MHBoxLayout()
            pnlPage.setLayout(HBox)
            if _pageNo == 0:
                VBox = MVBoxLayout()
                self.lblAreYouSure = MLabel(translate("Uninstall", "Are you sure you want to uninstall Hamsi Manager?"))
                VBox.addStretch(10)
                VBox.addWidget(self.lblAreYouSure)
                VBox.addStretch(10)
                HBox.addLayout(VBox)
            if _pageNo == 1:
                lblPleaseSelect = MLabel(
                    translate("Uninstall", "Please Select Directory Of Hamsi Manager To Uninstall."))
                UninstallationDirPath = fu.getDirName(
                    str(Settings.getUniversalSetting("HamsiManagerPath", str(fu.HamsiManagerDirectory))))
                self.leUninstallationDirectory = MLineEdit(
                    str(Settings.getUniversalSetting("pathOfInstallationDirectory", str(UninstallationDirPath))))
                self.pbtnSelectUninstallationDirectory = MPushButton(translate("Uninstall", "Browse"))
                self.connect(self.pbtnSelectUninstallationDirectory, SIGNAL("clicked()"),
                             self.selectUninstallationDirectory)
                VBox = MVBoxLayout()
                VBox.addStretch(2)
                VBox.addWidget(lblPleaseSelect)
                HBox1 = MHBoxLayout()
                HBox1.addWidget(self.leUninstallationDirectory)
                HBox1.addWidget(self.pbtnSelectUninstallationDirectory)
                VBox.addLayout(HBox1)
                VBox.addStretch(2)
                HBox.addLayout(VBox)
            elif _pageNo == 2:
                import MyPlugins

                self.lblFinished = MLabel(translate("Uninstall", "Uninstallation Completed."))
                VBox = MVBoxLayout()
                VBox.addStretch(2)
                VBox.addWidget(self.lblFinished)
                VBox.addStretch(2)
                wPlugins = MyPlugins.MyPluginsForSystem(pnlPage, "uninstall")
                VBox.addWidget(wPlugins)
                VBox.addStretch(2)
                HBox.addLayout(VBox)
            return pnlPage
Beispiel #7
0
 def installPlugin(self, _pluginName, _isQuiet=False):
     isInstalled = False
     pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(),
                               ["pluginName", "pluginFiles", "pluginDirectory", "installThisPlugin",
                                "setupDirectory", "pluginVersion"], 0)
     if pluginModule.installThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             try: fu.makeDirs(pluginModule.setupDirectory)
             except: pass
             for pluginFile in pluginModule.pluginFiles:
                 fu.copyOrChange(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginFile),
                                 fu.joinPath(pluginModule.setupDirectory, pluginFile), "file", "only", True)
                 MyConfigure.reConfigureFile(fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isInstalled = True
         else:
             oldFilePath = fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName,
                                       pluginModule.pluginDirectory)
             newFilePath = fu.copyOrChange(oldFilePath,
                                           fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory),
                                           "directory", "only", True)
             if newFilePath != oldFilePath:
                 isInstalled = True
     else:
         isInstalled = pluginModule.installThisPlugin()
     if isInstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName), str(pluginModule.pluginVersion))
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Installation Is Complete"),
                          str(translate("MyPlugins", "\"%s\" is installed on your system.")) % (
                              pluginModule.pluginName))
     elif isInstalled == "AlreadyInstalled":
         if _isQuiet is False:
             Dialogs.show(translate("MyPlugins", "Plug-in Already Installed"),
                          str(translate("MyPlugins", "\"%s\" already installed on your system.")) % (
                              pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(translate("MyPlugins", "Plug-in Installation Failed"),
                               str(translate("MyPlugins", "\"%s\" failed to install on your system.")) % (
                                   pluginModule.pluginName))
Beispiel #8
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()
Beispiel #9
0
def getColorSchemesAndPath():
    from Core import Settings

    colorSchemes, colorSchemePaths = [], []
    colorSchemes.append("Default")
    colorSchemePaths.append("")
    if isActivePyKDE4:
        from PyKDE4.kdecore import KStandardDirs, KGlobal

        schemeFiles = KGlobal.dirs().findAllResources("data", "color-schemes/*.colors", KStandardDirs.NoDuplicates)
        for scheme in schemeFiles:
            sets = Settings.getSettings(scheme)
            colorSchemes.append(trStr(sets.value("Name", fu.getBaseName(scheme))))
            colorSchemePaths.append(scheme)
    return colorSchemes, colorSchemePaths
Beispiel #10
0
 def fillPlugins(self):
     self.lstwPluginList.clear()
     self.myPluginsNames = []
     for plugin in uni.getMyPluginsNames():
         pluginModule = __import__("MyPlugins." + plugin, globals(), locals(),
                                   ["pluginName", "pluginVersion", "isInstallable"], 0)
         if pluginModule.isInstallable():
             installedVersion = Settings.getUniversalSetting(str(pluginModule.pluginName), "")
             if installedVersion == "":
                 details = translate("MyPlugins", "Could Not Be Determined")
             elif installedVersion != pluginModule.pluginVersion:
                 details = translate("MyPlugins", "Have A New Version")
             else:
                 details = translate("MyPlugins", "Installed")
             self.lstwPluginList.addItem(str(pluginModule.pluginName) + "\n\t" + details)
             self.myPluginsNames.append(plugin)
     if self.lstwPluginList.count() == 0:
         self.lstwPluginList.addItem(translate("MyPlugins", "Could not find the appropriate plug-in to your system"))
         self.pbtnInstall.setEnabled(False)
Beispiel #11
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()
Beispiel #12
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
Beispiel #13
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()
Beispiel #14
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()
Beispiel #15
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
Beispiel #16
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()
Beispiel #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
    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
Beispiel #19
0
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
#
# Gfi Informatique, Inc., hereby disclaims all copyright interest in the
# extensive testing project written by Denis Machard
#
# Author: Denis Machard
# Contact: [email protected]
# Website: www.extensivetesting.org
# -------------------------------------------------------------------

from Core import ConfigureExe
from Core import BuildWin
from Core import Settings
from Core.Libs import Logger

import json

# read the config
CONFIG = None
with open("%s/config.json" % (Settings.getDirExec())) as f:
    CONFIG_RAW = f.read()
CONFIG = json.loads(CONFIG_RAW)

# start the compilation
ConfigureExe.run()
BuildWin.run(pluginName=CONFIG["plugin"]["name"],
             pluginVersion=CONFIG["plugin"]["version"])
Beispiel #20
0
        """
        """
        with open( "%s/config.json" % (QtHelper.dirExec()) ) as f:
            CONFIG_RAW = f.read()
        self.config = json.loads(CONFIG_RAW)
        
    def cfg(self):
        """
        """
        return self.config
        
if __name__ == '__main__':
    app = QApplication(sys.argv)
    
    # initiliaze settings application, read settings from the ini file
    Settings.initialize()
    
    # initialize logger
    logPathFile = "%s/%s" % ( QtHelper.dirExec(), Settings.instance().readValue( key = 'Trace/file' ) )
    level = Settings.instance().readValue( key = 'Trace/level' )
    size = Settings.instance().readValue( key = 'Trace/max-size-file' )
    nbFiles = int( Settings.instance().readValue( key = 'Trace/nb-backup-max' ) )
    Logger.initialize( logPathFile=logPathFile, level=level, size=size, nbFiles=nbFiles, noSettings=True )
    
    
    # init the core plugin
    MyPlugin = CorePlugin.MainWindow(debugMode=DEBUGMODE)
   
    # create the main  widget   
    WidgetSettings = SettingsPage(parent=MyPlugin)
    MyPlugin.addSettingsPage( widget=WidgetSettings )
Beispiel #21
0
    def __init__(self, _errorDetails="", _pathOfReportFile=None):
        global isClose
        currentMainWindow = getMainWindow()
        if uni.isStartingSuccessfully:
            isShowFixMe = False
        else:
            isShowFixMe = True
        if currentMainWindow is None:
            setMainWindow(self)
        try: MDialog.__init__(self, currentMainWindow)
        except: MDialog.__init__(self, None)
        self.pathOfReportFile = _pathOfReportFile
        self.namMain = None
        self.nrqPost = None
        self.nrpBack = None
        isClose = False
        try:
            if isActivePyKDE4:
                self.setButtons(MDialog.NoDefault)
        except: pass

        try:
            if Dialogs.pnlState is not None:
                Dialogs.showState("", 1, 1)
        except: pass
        pnlMain = MWidget(self)
        self.vblMain = MVBoxLayout(pnlMain)
        self.pbtnSendAndClose = MPushButton(translate("ReportBug", "Send And Close"))
        self.pbtnCancel = MPushButton(translate("ReportBug", "Cancel"))
        self.connect(self.pbtnSendAndClose, SIGNAL("clicked()"), self.sendAndClose)
        self.connect(self.pbtnCancel, SIGNAL("clicked()"), self.cancel)
        self.pbtnShowDetailsPage = MPushButton(translate("ReportBug", "Show Details File"))
        self.pbtnCheckUpdate = MPushButton(translate("ReportBug", "Check Update"))
        self.cckbIsSendTableContents = Options.MyCheckBox(self, translate("ReportBug",
                                                                          "Send Table Contents For More Details"), 0,
                                                          _stateChanged=self.isSendTableContents)
        self.teErrorDetails = MTextEdit()
        try:
            self.teErrorDetails.setHtml(str(_errorDetails.replace("<hr>", "")))
        except:
            self.teErrorDetails.setHtml(translate("ReportBug",
                                                  "I cannot send the error details due to some character errors.<br>To see the details, please click on the \"Show details file\" button."))
            self.teErrorDetails.setEnabled(False)
        self.connect(self.pbtnShowDetailsPage, SIGNAL("clicked()"), self.showDetailsPage)
        self.connect(self.pbtnCheckUpdate, SIGNAL("clicked()"), self.checkUpdate)
        self.teErrorDetails.setMinimumHeight(220)
        self.vblMain.addWidget(self.teErrorDetails, 20)
        self.vblMain.addWidget(self.cckbIsSendTableContents, 1)
        lblUserNotes = MLabel(translate("ReportBug", "Notes : "))
        lblName = MLabel(translate("ReportBug", "Name And Surname : "))
        lblEMailAddress = MLabel(translate("ReportBug", "E-mail Address : "))
        lblAlert = MLabel(translate("ReportBug",
                                    "Note : Will be kept strictly confidential. It will be used solely to learn information about of your report."))
        self.teUserNotes = MTextEdit(self)
        self.leName = MLineEdit(self)
        self.leEMailAddress = MLineEdit(self)
        hbox1 = MHBoxLayout()
        hbox1.addWidget(lblUserNotes, 1)
        hbox1.addWidget(self.teUserNotes, 20)
        hbox2 = MHBoxLayout()
        hbox2.addWidget(lblName, 1)
        hbox2.addWidget(self.leName, 20)
        hbox3 = MHBoxLayout()
        hbox3.addWidget(lblEMailAddress, 1)
        hbox3.addWidget(self.leEMailAddress, 20)
        hbox0 = MHBoxLayout()
        hbox0.addWidget(self.pbtnShowDetailsPage, 1)
        hbox0.addWidget(self.pbtnCheckUpdate, 1)
        hbox0.addStretch(2)
        hbox0.addWidget(self.pbtnSendAndClose, 1)
        hbox0.addWidget(self.pbtnCancel, 1)
        VBox1 = MVBoxLayout()
        VBox1.addLayout(hbox2)
        VBox1.addLayout(hbox3)
        VBox1.addWidget(lblAlert)
        gboxContactInformations = MGroupBox(translate("ReportBug", "Contact Informations : "))
        gboxContactInformations.setLayout(VBox1)
        self.vblMain.addLayout(hbox1, 1)
        self.vblMain.addWidget(gboxContactInformations, 1)
        self.vblMain.addLayout(hbox0, 1)
        try:
            if isActivePyKDE4:
                self.setMainWidget(pnlMain)
            else:
                self.setLayout(self.vblMain)
        except:
            self.setLayout(self.vblMain)
        self.setWindowTitle(translate("ReportBug", "Please Report This Bug!.."))
        self.setMaximumSize(600, 375)
        self.show()
        self.setMaximumSize(10000, 10000)
        if isShowFixMe and isQuickMake is False and uni.loggingLevel != logging.DEBUG:
            try:
                answer = Dialogs.askSpecial(translate("ReportBug", "I Have A Suggestion!"),
                                            translate("ReportBug", "<b>Please check the following: ;</b><br>" +
                                                      "<b>1-)</b>If you have received this error when you were checking the last folder, reset the \"Last Directory\",<br>" +
                                                      "<b>2-)</b>If you have received this error due to your changed settings, reset the \"Settings\",<br>" +
                                                      "<b>3-)</b>If you continue to receive this error even after resetting the settings, reset \"All\".<br>" +
                                                      "<br><b>You can enable Hamsi Manager to run as normal.<br>Please take a moment to send us the error report.</b>"),
                                            translate("ReportBug", "Last Directory"),
                                            translate("ReportBug", "All"),
                                            translate("ReportBug", "Settings"),
                                            translate("ReportBug", "Ignore"))
                if answer == translate("ReportBug", "Last Directory"):
                    Settings.setting().setValue("lastDirectory", trQVariant(fu.userDirectoryPath))
                elif answer == translate("ReportBug", "Settings"):
                    Settings.reFillSettings(True)
                elif answer == translate("ReportBug", "All"):
                    Settings.reFillAll(True)
            except: pass
Beispiel #22
0
def getLastPathByEvent(_keyPath, _defaultPath):
    from Core import Settings

    sets = Settings.settingForPaths()
    return str(trStr(sets.value(_keyPath, trQVariant(_defaultPath))))
Beispiel #23
0
    def addResultsInTestLab(self, testcases, config={}):
        """
        """
        try:
            # connect
            self.RestAuthenticate(logger=self.logResultsStatus)

            rootFolder = self.RestFindTestsetFolder(logger=self.logResultsStatus, 
                                                    folderName="Root", parentId="-1")
            if rootFolder is None: 
                raise Exception( "Unable to detect the root folder in test lab" )

            rootTpFolder = self.RestFindTestFolder(logger=self.logResultsStatus, 
                                                   folderName="Subject", parentId="0")
            if rootTpFolder is None: 
                raise Exception( "Unable to detect the root folder in test plan" )
                
            # clean up the path
            testsetpath = config["TestSet_Path"].replace("//", "/")
            if testsetpath.startswith("/"): testsetpath = testsetpath[1:]
            if testsetpath.endswith("/"): testsetpath = testsetpath[:-1]
            if not len(testsetpath): folders = []
            else: folders = self.__splitall(testsetpath)

            # iterate on all folders
            ret = None
            parentId = rootFolder["id"]
            for d in folders:
                ret = self.RestFindTestsetFolder(logger=self.logResultsStatus, 
                                                 folderName=d, parentId=parentId)
                if ret is None and not config["Add_Folders"]:
                    raise Exception( 'Folder (%s) is missing in test lab' % d )
                elif ret is None and config["Add_Folders"]:
                    parentId = self.RestAddTestsetFolder(logger=self.logResultsStatus, 
                                                         folderName=d, 
                                                         parentId=parentId)
                else:
                    parentId = ret["id"]
                
            if config["Add_TestSet"]:
                testsetId = self.RestCreateTestset(logger=self.logResultsStatus, 
                                                   testsetName=config["TestSet_Name"], 
                                                   parentId=parentId,
                                                   subtypeId=config["TestSet_TypeId"])
            else:
                oTestset = self.RestFindTestset(logger=self.logResultsStatus, 
                                                testsetName=config["TestSet_Name"], 
                                                parentId=parentId)
                testsetId = oTestset["id"]

            for tc in testcases:
                # clean the testpath
                testpath= "%s/" % tc['testpath']
                testpath = testpath.replace("//", "/")
                if testpath.startswith("/"): testpath = testpath[1:]
                if testpath.endswith("/"): testpath = testpath[:-1]
                if not len(testpath): folders = []
                else: folders = self.__splitall(testpath)

                # iterate on all folders
                ret = None
                parentIdTp = rootTpFolder["id"]
                for d in folders:
                    ret = self.RestFindTestFolder(logger=self.logResultsStatus, 
                                                  folderName=d, 
                                                  parentId=parentIdTp)
                    if ret is None :
                        raise Exception( 'Folder (%s) is missing in test plan' % d )
                    else:
                        parentIdTp = ret["id"]
                if parentIdTp is None:
                    raise Exception('Folder parent id is missing ?')

                # finally search the test in testplan ?
                oTest = self.RestFindTest(logger=self.logResultsStatus, 
                                          testName=tc['testname'], 
                                          parentId=parentIdTp)
                
                if config["Add_TestInstance"]:
                    # add the test instance in testset
                    testinsId = self.RestCreateTestInstance(logger=self.logResultsStatus, 
                                                            testId=oTest["id"], 
                                                            testsetId=testsetId,
                                                            subtypeId=config["TestInstance_TypeId"])
                else:
                    oTestins = self.RestFindTestInstance(logger=self.logResultsStatus, 
                                                         testinsName=tc["name"], 
                                                         parentId=oTest["id"])
                    testinsId = oTestins["id"]

                # create a run with the state not completed
                runName = "%s_%s" % (Settings.instance().readValue( key = 'Common/name' ), 
                                    time.strftime('%d-%m-%y %H:%M',time.localtime()) )
                ownerName = self.core().settings().cfg()["credentials"]["login"]
                runId = self.RestCreateRun(logger=self.logResultsStatus, testinsId=testinsId, runName=runName, 
                                            ownerName=ownerName, testsetId=testsetId, testId=oTest["id"], 
                                            testStatus="Not Completed", subtypeId=config["TestRun_TypeId"] )
                    
                # create a run for all steps
                steps = self.RestGetTestInstanceSteps(logger=self.logResultsStatus, runId=runId)

                if "steps" in tc:
                    i = 0
                    for stpId in steps:
                        try:
                            stp = tc["steps"][i]
                        except Exception as e:
                            raise Exception("step %s is missing" % i )
                        else:
                            self.RestUpdateRunStep(logger=self.logResultsStatus, 
                                                   stepId=stpId, runId=runId, 
                                                   stepStatus=stp["result"], stepActual=stp["actual"] )
                            i += 1
                else:
                    for stpId in steps:
                        self.RestUpdateRunStep(logger=self.logResultsStatus, 
                                               stepId=stpId, runId=runId, 
                                               stepStatus=tc["result"], stepActual="")

                # complete the run
                self.RestUpdateRun(logger=self.logResultsStatus, 
                                   runId=runId, runStatus=tc["result"])

            # disconnect
            self.RestLogout(logger=self.logResultsStatus)
            
            self.ResultsExported.emit(testcases, config)
        except Exception as e:
            if self.WsLwssoCookie is not None: self.RestLogout(logger=self.logResultsStatus)
                
            self.logResultsStatus("Error on result(s) export" )
            self.Error.emit( "%s" % e )
Beispiel #24
0
 def installPlugin(self, _pluginName, _isQuiet=False):
     isInstalled = False
     pluginModule = __import__(
         "MyPlugins." + _pluginName, globals(), locals(), [
             "pluginName", "pluginFiles", "pluginDirectory",
             "installThisPlugin", "setupDirectory", "pluginVersion"
         ], 0)
     if pluginModule.installThisPlugin is None:
         if pluginModule.pluginDirectory == "":
             try:
                 fu.makeDirs(pluginModule.setupDirectory)
             except:
                 pass
             for pluginFile in pluginModule.pluginFiles:
                 fu.copyOrChange(
                     fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins",
                                 _pluginName, pluginFile),
                     fu.joinPath(pluginModule.setupDirectory, pluginFile),
                     "file", "only", True)
                 MyConfigure.reConfigureFile(
                     fu.joinPath(pluginModule.setupDirectory, pluginFile))
             isInstalled = True
         else:
             oldFilePath = fu.joinPath(fu.HamsiManagerDirectory,
                                       "MyPlugins", _pluginName,
                                       pluginModule.pluginDirectory)
             newFilePath = fu.copyOrChange(
                 oldFilePath,
                 fu.joinPath(pluginModule.setupDirectory,
                             pluginModule.pluginDirectory), "directory",
                 "only", True)
             if newFilePath != oldFilePath:
                 isInstalled = True
     else:
         isInstalled = pluginModule.installThisPlugin()
     if isInstalled:
         Settings.setUniversalSetting(str(pluginModule.pluginName),
                                      str(pluginModule.pluginVersion))
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins", "Plug-in Installation Is Complete"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" is installed on your system.")) %
                 (pluginModule.pluginName))
     elif isInstalled == "AlreadyInstalled":
         if _isQuiet is False:
             Dialogs.show(
                 translate("MyPlugins", "Plug-in Already Installed"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" already installed on your system."))
                 % (pluginModule.pluginName))
     else:
         if _isQuiet is False:
             Dialogs.showError(
                 translate("MyPlugins", "Plug-in Installation Failed"),
                 str(
                     translate("MyPlugins",
                               "\"%s\" failed to install on your system."))
                 % (pluginModule.pluginName))
Beispiel #25
0
def setLastPathByEvent(_keyPath, _path):
    from Core import Settings

    sets = Settings.settingForPaths()
    sets.setValue(_keyPath, trQVariant(_path))
    def addResultsInTestLab(self, testcases, config={}):
        """
        """
        try:
            # connect
            self.logResultsStatus( "Connection to the COM API..." )

            pythoncom.CoInitialize()
            qc_cx = win32client.Dispatch("TDApiOle80.TDConnection")
            qc_cx.InitConnectionEx(self.url)
            qc_cx.Login(self.login, self.password)
            qc_cx.Connect(self.domain, self.project)
            self.logResultsStatus( "Connected" )
            
            # find path folder in test lab
            self.logResultsStatus("Finding path in test lab..." )
            if config["Add_Folders"]:
                testsetpath="Root/%s" % ( config["TestSet_Path"] )
                testsetpath = os.path.normpath(testsetpath)
                testsetpathSplit = self.__splitpath(path=testsetpath)

                treeManager = qc_cx.TestSetTreeManager
                tl = "Root/"
                if len(testsetpathSplit) == 1:
                    testLabFolder = treeManager.NodeByPath(os.path.normpath(tl))
                
                for f in testsetpathSplit[1:]:
                    try:
                        testLabFolder = treeManager.NodeByPath(os.path.normpath("%s/%s" % (tl, f)))
                        tl = os.path.normpath("%s/%s" % (tl, f))
                    except pythoncom.com_error as e:
                        self.logResultsStatus("Creating folder %s in test lab..." % f )
                        testLabFolder = treeManager.NodeByPath(os.path.normpath("%s" % tl))
                        testLabFolder = testLabFolder.AddNode(f)
                        tl = os.path.normpath("%s/%s" % (tl, f))
            else:
                treeManager = qc_cx.TestSetTreeManager
                testsetpath="Root/%s" % ( config["TestSet_Path"] )
                testsetpath = os.path.normpath(testsetpath)
                testLabFolder = treeManager.NodeByPath(testsetpath) 
                if testLabFolder is None:  raise Exception( 'Unable to find the provided path in test lab' )
            
                
            # create the testset according to the testset name provided
            if config["Add_TestSet"]:
                self.logResultsStatus("Creating testset (%s) in test lab..." % config["TestSet_Name"] )
                testsetFactory = testLabFolder.TestSetFactory
                testset = testsetFactory.AddItem(None)
                testset.Name = config["TestSet_Name"]
                testset.SetField("CY_COMMENT", u"<html><body>%s</body></html>" % "testset generated automatically")
                testset.Post()
            else:
                # find testset name
                self.logResultsStatus("Searching testset (%s) in test lab..." % config["TestSet_Name"] )
                testset = None
                testsets = testLabFolder.FindTestSets(config["TestSet_Name"])
                if testsets is None:  raise Exception( 'Unable to find the test set in test lab' )
                for ts in testsets:
                    if ts.Name == config["TestSet_Name"]:
                        testset = ts
                        break
                if testset is None: raise Exception( 'Testset (%s) not found in test lab' % config["TestSet_Name"] )
            
            # add test instance in testset ?
            if config["Add_TestInstance"]:
                self.logResultsStatus("Finding test(s) from testplan..." )
                tsTestFactory = testset.TSTestFactory

                treeTpManager = qc_cx.TreeManager
                for tc1 in testcases:
                    testpath="Subject/%s/" % tc1['testpath']
                    testpath = os.path.normpath(testpath)
                    try:
                        testPlanFolder = treeTpManager.NodeByPath(testpath) 
                    except pythoncom.com_error as e:
                        raise Exception( 'Unable to find the provided path %s in test plan' %  tc1['testpath'] )
                    
                    try:
                        testsTp = testPlanFolder.FindTests(tc1['testname'])
                    except pythoncom.com_error as e:
                        raise Exception( 'Test (%s) not found in test plan (%s)' % (tc1['testname'],tc1['testpath'])  )
                    
                    objTestTp = None
                    if testsTp is not None:
                        for tTp in testsTp:
                            if tTp.Name == tc1['testname']:
                                objTestTp = tTp
                                break
                    if objTestTp is None:raise Exception( 'Test object (%s) not found in test plan (%s)' % (tc1['testname'], tc1['testpath']) )
                    
                    testInstance = tsTestFactory.AddItem(None)
                    testInstance.Status = "No Run"
                    testInstance.SetField("TC_TEST_ID", objTestTp)
                    testInstance.Post()

            

            self.logResultsStatus("Finding test instance in test lab..." )
            
            #find testset name
            self.logResultsStatus("Refreshing testset (%s) from test lab..." % config["TestSet_Name"] )
            testset = None
            testsets = testLabFolder.FindTestSets(config["TestSet_Name"])
            if testsets is None:  raise Exception( 'Unable to find the test set in test lab' )
            for ts in testsets:
                if ts.Name == config["TestSet_Name"]:
                    testset = ts
                    break
            if testset is None: raise Exception( 'Testset (%s) not found in test lab' % config["TestSet_Name"] )

            # get tests instance
            testsetList = testset.TSTestFactory.NewList("")
            testInstances = []
            for ti in testsetList:
                testInstances.append(ti)
            if not len(testInstances): raise Exception( 'Testset (%s) is empty' % config["TestSet_Name"])
    
            # finally run all testcases instances
            for tc in testcases:

                testI = None
                testIN = tc["name"]
                self.logResultsStatus("Test instance to search in testset: (%s)" % testIN )
                for ti in testInstances:
                    self.logResultsStatus("Test instance detected: (%s)" % ti.Name )
                    if ti.Name == testIN:
                        testI = ti
                        break
                if testI is None:
                    raise Exception("test instance (%s) not found" % testIN )
         
                self.logResultsStatus("Running test instance (%s)..." % testIN )
                # run test instance
                runFactory = testI.RunFactory
                runName = "%s_%s" % (Settings.instance().readValue( key = 'Common/name' ),
                                    time.strftime('%d-%m-%y %H:%M',time.localtime()) )
                runInstance = runFactory.AddItem(runName)
                runInstance.Status = tc["result"]
                runInstance.CopyDesignSteps() 
                runInstance.Post()
                
                # set steps results
                if "steps" in tc: 
                    i = 0
                    for stepFactory in runInstance.StepFactory.NewList(""):
                        try:
                            stp = tc["steps"][i]
                        except Exception as e:
                            raise Exception("step %s is missing" % i )
                        else:
                            stepFactory.Status = stp["result"]
                            stepFactory.SetField("ST_ACTUAL", stp["actual"])
                            stepFactory.post() 

                            stepFactory.UnLockObject()
                            i += 1
                            
                # if no step is provided but exists on qc 
                # then you set all steps with the result of the testcase
                else:
                    for stepFactory in runInstance.StepFactory.NewList(""):
                        stepFactory.Status = tc["result"]
                        stepFactory.post() 
                        stepFactory.UnLockObject()
                            
            # disconnect
            self.logResultsStatus("Disconnection from the COM API..." )
            qc_cx.Logout()
            qc_cx.ReleaseConnection()
            self.logResultsStatus("Disconnected" )
            
            self.ResultsExported.emit()
        except pythoncom.com_error as e:
            hr,msg,exc,arg = e.args
            if exc is None:
                details = "HP connect missing!"
            else:  
                _, _, details, _, _, _ = exc
            self.logTestsStatus("Error on test(s) export" )
            self.Error.emit( "%s: %s" % (msg, details) )
        except Exception as e:
            self.logResultsStatus("Error on results(s) export" )
            self.Error.emit( "%s" % e )
    def closeEvent(self, _event):
        try:
            if uni.isRaisedAnError is False:
                if uni.isContinueThreadAction():
                    uni.cancelThreadAction()
                    _event.ignore()
            uni.isStartedCloseProcess = True
            uni.printForDevelopers("Started closeEvent")
            MApplication.setQuitOnLastWindowClosed(True)
            try:
                self.PlayerBar.MusicPlayer.stop()
            except:
                pass
            Details.closeAllDialogs()
            uni.printForDevelopers("Closed Dialogs")
            if uni.isRaisedAnError is False:
                if self.Table.checkUnSavedValues() is False:
                    uni.isStartedCloseProcess = False
                    uni.printForDevelopers("Close ignored")
                    _event.ignore()
            uni.printForDevelopers("Before self.doBeforeCloseProcesses")
            if self.doBeforeCloseProcesses() is False:
                _event.ignore()
                return None
            uni.printForDevelopers("After self.doBeforeCloseProcesses")
            if isActivePyKDE4:
                uni.printForDevelopers("Before Save KDE Configs")
                kconf = MGlobal.config()
                kconfGroup = MConfigGroup(kconf, "DirectoryOperator")
                self.FileManager.dirOperator.writeConfig(kconfGroup)
                self.FileManager.actCollection.writeSettings(kconfGroup)
                uni.printForDevelopers("After Save KDE Configs")
            uni.printForDevelopers("Before Save Configs")
            uni.setMySetting(self.Table.hiddenTableColumnsSettingKey,
                             self.Table.hiddenTableColumns)
            Bars.setAllBarsStyleToMySettings()
            Records.setRecordType(1)
            fu.writeToBinaryFile(
                fu.joinPath(fu.pathOfSettingsDirectory, "LastState"), self.saveState())
            Records.restoreRecordType()
            geometry = [self.geometry().x(), self.geometry().y(), self.geometry().width(),
                        self.geometry().height()]
            uni.setMySetting("MainWindowGeometries", geometry)
            uni.setMySetting("lastDirectory", self.FileManager.currentDirectory)
            uni.setMySetting("isMainWindowMaximized", self.isMaximized())
            uni.setMySetting("isShowAdvancedSelections", self.SpecialTools.isShowAdvancedSelections)
            uni.setMySetting("tableType", uni.tableType)
            uni.setMySetting("activeTabNoOfSpecialTools", self.SpecialTools.tabwTabs.currentIndex())
            uni.saveSettings()
            Settings.saveUniversalSettings()
            if uni.isActiveAmarok and uni.getBoolValue("amarokIsUseHost") is False:
                import Amarok

                uni.printForDevelopers("Before Amarok.stopEmbeddedDB")
                Amarok.stopEmbeddedDB()
                uni.printForDevelopers("After Amarok.stopEmbeddedDB")
            uni.printForDevelopers("After Save Configs")
            uni.printForDevelopers("Before self.doAfterCloseProcesses")
            self.doAfterCloseProcesses()
            uni.printForDevelopers("After self.doAfterCloseProcesses")
        except:
            if ReportBug.isClose is False:
                ReportBug.ReportBug()
                _event.ignore()
Beispiel #28
0
        """
        with open("%s/config.json" % (QtHelper.dirExec())) as f:
            CONFIG_RAW = f.read()
        self.config = json.loads(CONFIG_RAW)

    def cfg(self):
        """
        """
        return self.config


if __name__ == '__main__':
    app = QApplication(sys.argv)

    # initiliaze settings application, read settings from the ini file
    Settings.initialize()

    # initialize logger
    logPathFile = "%s/%s" % (QtHelper.dirExec(),
                             Settings.instance().readValue(key='Trace/file'))
    level = Settings.instance().readValue(key='Trace/level')
    size = Settings.instance().readValue(key='Trace/max-size-file')
    nbFiles = int(Settings.instance().readValue(key='Trace/nb-backup-max'))
    Logger.initialize(logPathFile=logPathFile,
                      level=level,
                      size=size,
                      nbFiles=nbFiles,
                      noSettings=True)

    # init the core plugin
    MyPlugin = CorePlugin.MainWindow(debugMode=DEBUGMODE)
Beispiel #29
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()
Beispiel #30
0
    import FileUtils as fu

    fu.initStartupVariables()
    from Core import Universals as uni

    uni.printForDevelopers("Before CommandLineOptions")
    from Core import CommandLineOptions
    uni.printForDevelopers("Before CommandLineOptions.checkCommandLineOptions")
    if CommandLineOptions.checkCommandLineOptions():
        from Core import ReportBug

        uni.printForDevelopers("Before Settings")
        from Core import Settings

        uni.printForDevelopers("Before Settings.checkSettings")
        Settings.checkSettings()
        uni.printForDevelopers("Before uni.fillMySettings")
        uni.fillMySettings()
        if isActivePyKDE4:
            uni.printForDevelopers("ActivePyKDE4")
            appName = "HamsiManager"
            programName = ki18n("Hamsi Manager")
            version = uni.version
            appLicense = MAboutData.License_GPL_V3
            appCopyright = ki18n(str("Murat Demir ([email protected])"))
            kde4LangCode = uni.MySettings["language"]
            text = ki18n(str(""))
            homePage = str("hamsiapps.com")
            bugEmail = str("Murat Demir ([email protected])")
            if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + kde4LangCode)):
                aboutFileContent = fu.readFromFile(