예제 #1
0
파일: patcher.py 프로젝트: L0FKA/PyPatcher
    def _runPyPatch(self, srcDir, patchDir):
        """
        As python doesn't keep open python files, it is trivial to patch a
        running python file. Unpack the patch, extract and then restart the
        application
        """
        try:
            patchdiff.applyPatchDirectory(srcDir, patchDir)
        except patchdiff.PatchError:
            self._setBroken()
            raise BrokenError(('There was an error patching.'
                             + ' See patcherr.log for more information'))

        self._removeCfgFile()

        shutil.rmtree(patchDir)
        os.spawnlp(sys.executable, sys.executable, *sys.argv)
        sys.exit()
예제 #2
0
파일: patcher.py 프로젝트: L0FKA/PyPatcher
    def _finishFrozenPatch(self):
        cfg = _jsonFromFile(self.cfgPath)
        oldBin = cfg['oldbin']
        srcDir = cfg['srcdir']
        patchDir = cfg['patchdir']

        try:
            patchdiff.applyPatchDirectory(srcDir, patchDir)
        except patchdiff.PatchError:
            self._setBroken()
            raise BrokenError(('There was an error patching.'
                             + ' See patcherr.log for more information'))

        self._removeCfgFile()

        shutil.rmtree(patchDir)
        os.execlp(oldBin, oldBin)
        sys.exit()