import Core

if Core.checkMandatoryModules():
    from Core.MyObjects import *
    import FileUtils as fu

    fu.initStartupVariables()
    from Core import Universals as uni
    from Core import Execute

    proFile = fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.pro")
    proFileContent = "SOURCES = %SOURCES% \nTRANSLATIONS = %TRANSLATIONS%"""

    SOURCES = ""
    TRANSLATIONS = ""
    directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
    for fileName in directoriesAndFiles:
        if (fu.isFile(fileName) and fileName.find(".py") > -1 and
                    fileName.find(".pyc") == -1 and fileName.find(".pyw") == -1):
            SOURCES += fileName.replace(fu.HamsiManagerDirectory + fu.sep, "") + " \\\n         "

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

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

    fu.writeToFile(proFile, proFileContent)

    args = ["pylupdate4"]
Example #2
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()
import Core

if Core.checkMandatoryModules():
    from Core.MyObjects import *
    import FileUtils as fu

    fu.initStartupVariables()
    from Core import Universals as uni
    from Core import Execute

    proFile = fu.joinPath(fu.HamsiManagerDirectory, "HamsiManager.pro")
    proFileContent = "SOURCES = %SOURCES% \nTRANSLATIONS = %TRANSLATIONS%" ""

    SOURCES = ""
    TRANSLATIONS = ""
    directoriesAndFiles = fu.readDirectoryWithSubDirectories(
        fu.HamsiManagerDirectory)
    for fileName in directoriesAndFiles:
        if (fu.isFile(fileName) and fileName.find(".py") > -1
                and fileName.find(".pyc") == -1
                and fileName.find(".pyw") == -1):
            SOURCES += fileName.replace(fu.HamsiManagerDirectory + fu.sep,
                                        "") + " \\\n         "

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

    proFileContent = proFileContent.replace("%SOURCES%", SOURCES)
    proFileContent = proFileContent.replace("%TRANSLATIONS%", TRANSLATIONS)
Example #4
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()