示例#1
0
文件: steps.py 项目: tepperly/MixDown
def unpack(pythonCallInfo):
    if os.path.isfile(pythonCallInfo.target.path):
        if not utilityFunctions.validateCompressedFile(pythonCallInfo.target.path):
            pythonCallInfo.success = False
        else:
            if tarfile.is_tarfile(pythonCallInfo.target.path):
                utilityFunctions.untar(pythonCallInfo.target.path, pythonCallInfo.target.outputPath, True)
                pythonCallInfo.target.path = pythonCallInfo.target.outputPath
                pythonCallInfo.success = True
            elif zipfile.is_zipfile(pythonCallInfo.target.path):
                utilityFunctions.unzip(pythonCallInfo.target.path, pythonCallInfo.target.outputPath, True)
                pythonCallInfo.target.path = pythonCallInfo.target.outputPath
                pythonCallInfo.success = True
    elif os.path.isdir(pythonCallInfo.target.path):
        pythonCallInfo.success = True
    else:
        pythonCallInfo.logger.writeError("Given path '" + pythonCallInfo.target.path + "' not understood by MixDown's unpack (path should be a file or a directory at this point)")
        pythonCallInfo.success = False

    return pythonCallInfo
示例#2
0
    def __init__(self):

        # The only way I know how to detect the state of the busy cursor
        # is to try to stop it, and see if this throws an exception.
        try:
            wx.EndBusyCursor()
            self.stoppedBusyCursor = True
        except:
            self.stoppedBusyCursor = False

        wx.BeginBusyCursor()

        self.wxHtmlHelpController = wx.html.HtmlHelpController(style=wx.html.HF_DEFAULT_STYLE, parentWindow=None)

        self.helpZipFile = None
        self.helpZipFilePath = None
        self.helpZipFileDirectory = None
        self.helpFilesDirectory = None

        #self.launcherHelpUrl = "https://cvl.massive.org.au/launcher_files/help/helpfiles.zip"
        self.launcherHelpUrl = "https://raw.github.com/CVL-dev/cvl-fabric-launcher/master/help/helpfiles.zip"
        self.initializationSucceeded = False
        try:
            # Download helpfiles.zip:

            self.helpZipFile = tempfile.NamedTemporaryFile(mode='w+b', prefix='helpfiles-', suffix='.zip', delete=False)
            self.helpZipFilePath = self.helpZipFile.name
            logger.debug("self.helpZipFilePath = " + self.helpZipFilePath)
            r = requests.get(self.launcherHelpUrl, verify=False)
            if r.status_code == 200:
                for chunk in r.iter_content():
                    self.helpZipFile.write(chunk)
            self.helpZipFile.close()

            # We should be able to add the zip archive directly to the 
            # help controller, but that didn't seem to work.

            # Unzip helpfiles.zip:

            (self.helpZipFileDirectory, self.helpZipFileFilename) = os.path.split(self.helpZipFilePath)
            unzip(self.helpZipFilePath, self.helpZipFileDirectory)
            self.helpFilesDirectory = os.path.join(self.helpZipFileDirectory, "helpfiles")
            logger.debug("self.helpFilesDirectory = " + self.helpFilesDirectory)

            self.launcherHtmlHelpProjectFile = os.path.join(self.helpFilesDirectory, launcherHtmlHelpProjectFilename)
            self.initializationSucceeded = self.wxHtmlHelpController.AddBook(self.launcherHtmlHelpProjectFile)

        except:
            logger.debug(traceback.format_exc())

            try:
                # If we don't succeed in downloading help, 
                # we will try using local help files instead.

                if hasattr(sys, 'frozen'):
                    if sys.platform.startswith("darwin"):
                        self.helpFilesDirectory = os.path.join(os.path.dirname(sys.executable), "..", "Resources", "help", "helpfiles")
                    else:
                        self.helpFilesDirectory = os.path.join(os.path.dirname(sys.executable), "help", "helpfiles")
                else:
                    launcherModulePath = os.path.dirname(pkgutil.get_loader("launcher").filename)
                    self.helpFilesDirectory = os.path.join(launcherModulePath, "help", "helpfiles")

                self.launcherHtmlHelpProjectFile = os.path.join(self.helpFilesDirectory, launcherHtmlHelpProjectFilename)
                self.initializationSucceeded = self.wxHtmlHelpController.AddBook(self.launcherHtmlHelpProjectFile)

            except:
                logger.debug(traceback.format_exc())

        if not self.stoppedBusyCursor:
            try:
                wx.EndBusyCursor()
            except:
                pass
    def __init__(self):

        # The only way I know how to detect the state of the busy cursor
        # is to try to stop it, and see if this throws an exception.
        try:
            wx.EndBusyCursor()
            self.stoppedBusyCursor = True
        except:
            self.stoppedBusyCursor = False

        wx.BeginBusyCursor()

        self.wxHtmlHelpController = wx.html.HtmlHelpController(style=wx.html.HF_DEFAULT_STYLE, parentWindow=None)

        self.helpZipFile = None
        self.helpZipFilePath = None
        self.helpZipFileDirectory = None
        self.helpFilesDirectory = None

        # self.launcherHelpUrl = "https://cvl.massive.org.au/launcher_files/help/helpfiles.zip"
        self.launcherHelpUrl = "https://raw.github.com/CVL-dev/cvl-fabric-launcher/master/help/helpfiles.zip"
        self.initializationSucceeded = False
        try:
            # Download helpfiles.zip:

            self.helpZipFile = tempfile.NamedTemporaryFile(mode="w+b", prefix="helpfiles-", suffix=".zip", delete=False)
            self.helpZipFilePath = self.helpZipFile.name
            logger.debug("self.helpZipFilePath = " + self.helpZipFilePath)
            r = requests.get(self.launcherHelpUrl, verify=False)
            if r.status_code == 200:
                for chunk in r.iter_content():
                    self.helpZipFile.write(chunk)
            self.helpZipFile.close()

            # We should be able to add the zip archive directly to the
            # help controller, but that didn't seem to work.

            # Unzip helpfiles.zip:

            (self.helpZipFileDirectory, self.helpZipFileFilename) = os.path.split(self.helpZipFilePath)
            unzip(self.helpZipFilePath, self.helpZipFileDirectory)
            self.helpFilesDirectory = os.path.join(self.helpZipFileDirectory, "helpfiles")
            logger.debug("self.helpFilesDirectory = " + self.helpFilesDirectory)

            self.launcherHtmlHelpProjectFile = os.path.join(self.helpFilesDirectory, launcherHtmlHelpProjectFilename)
            self.initializationSucceeded = self.wxHtmlHelpController.AddBook(self.launcherHtmlHelpProjectFile)

        except:
            logger.debug(traceback.format_exc())

            try:
                # If we don't succeed in downloading help,
                # we will try using local help files instead.

                if hasattr(sys, "frozen"):
                    if sys.platform.startswith("darwin"):
                        self.helpFilesDirectory = os.path.join(
                            os.path.dirname(sys.executable), "..", "Resources", "help", "helpfiles"
                        )
                    else:
                        self.helpFilesDirectory = os.path.join(os.path.dirname(sys.executable), "help", "helpfiles")
                else:
                    launcherModulePath = os.path.dirname(pkgutil.get_loader("launcher").filename)
                    self.helpFilesDirectory = os.path.join(launcherModulePath, "help", "helpfiles")

                self.launcherHtmlHelpProjectFile = os.path.join(
                    self.helpFilesDirectory, launcherHtmlHelpProjectFilename
                )
                self.initializationSucceeded = self.wxHtmlHelpController.AddBook(self.launcherHtmlHelpProjectFile)

            except:
                logger.debug(traceback.format_exc())

        if not self.stoppedBusyCursor:
            try:
                wx.EndBusyCursor()
            except:
                pass