Exemplo n.º 1
0
 def run(self, interpreter):
     """Executes the code of the specified module. Deserializes captured
     json data.
     """
     with utils.ChangeDir(self.dirname):
         command_list = [
             'PYTHONPATH=' + main_dir, interpreter, self.filename
         ] + list(self.args)
         try:
             proc = Popen(' '.join(command_list),
                          stdout=PIPE,
                          stderr=PIPE,
                          shell=True)
             stream_data = proc.communicate()
         except Exception as e:
             logger.error(
                 "Error {0} while executing extract_dist command.".format(
                     e))
             raise ExtractionError
         stream_data = [utils.console_to_str(s) for s in stream_data]
         if proc.returncode:
             logger.error(
                 "Subprocess failed, stdout: {0[0]}, stderr: {0[1]}".format(
                     stream_data))
         self._result = json.loads(
             stream_data[0].split("extracted json data:\n")[-1])
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(DistMetadataExtractor, self).__init__(*args, **kwargs)

        temp_dir = tempfile.mkdtemp()
        try:
            with self.archive as a:
                a.extract_all(directory=temp_dir)
                try:
                    setup_py = glob.glob(temp_dir +
                                         "/{0}*/".format(self.name) +
                                         'setup.py')[0]
                except IndexError:
                    sys.stderr.write(
                        "setup.py not found, maybe local_file is not proper source archive.\n"
                    )
                    raise SystemExit(3)

                with utils.ChangeDir(os.path.dirname(setup_py)):
                    with utils.RedirectStdStreams(
                            stdout=LoggerWriter(logger.debug),
                            stderr=LoggerWriter(logger.warning)):
                        extract_distribution.run_setup(setup_py, 'bdist_rpm')

                self.distribution = extract_distribution.extract_distribution.class_distribution
        finally:
            shutil.rmtree(temp_dir)
Exemplo n.º 3
0
 def run(self):
     """Executes the code of the specified module."""
     with utils.ChangeDir(self.dirname):
         sys.path.insert(0, self.dirname)
         sys.argv[1:] = self.args
         runpy.run_module(self.not_suffixed(self.filename),
                          run_name='__main__',
                          alter_sys=True)