Exemplo n.º 1
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if len(a) < 1:
            filename = "setup.py"
        else:
            filename = a[0]
        if not op.exists(filename):
            raise ValueError("file %s not found" % filename)

        output = o.output_filename
        if op.exists(output):
            raise UsageException("file %s exists, not overwritten" % output)

        if o.verbose:
            show_output = True
        else:
            show_output = False

        if o.setup_args:
            setup_args = comma_list_split(o.setup_args)
        else:
            setup_args = ["-q", "-n"]

        monkey_patch_mode = o.type

        convert_log = "convert.log"
        log = open(convert_log, "w")
        try:
            try:
                convert(ctx, filename, setup_args, monkey_patch_mode,
                        o.verbose, output, log, show_output)
            except ConvertionError:
                raise
            except Exception:
                e = extract_exception()
                log.write("Error while converting - traceback:\n")
                tb = sys.exc_info()[2]
                traceback.print_tb(tb, file=log)
                msg = "Error while converting %s - you may look at %s for " \
                      "details (Original exception: %s %s)"
                raise ConvertionError(msg %
                                      (filename, convert_log, type(e), str(e)))
        finally:
            log.flush()
            log.close()
Exemplo n.º 2
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if len(a) < 1:
            filename = "setup.py"
        else:
            filename = a[0]
        if not op.exists(filename):
            raise ValueError("file %s not found" % filename)

        output = o.output_filename
        if op.exists(output):
            raise UsageException("file %s exists, not overwritten" % output)

        if o.verbose:
            show_output = True
        else:
            show_output = False

        if o.setup_args:
            setup_args = comma_list_split(o.setup_args)
        else:
            setup_args = ["-q", "-n"]

        monkey_patch_mode = o.type

        convert_log = "convert.log"
        log = open(convert_log, "w")
        try:
            try:
                convert(ctx, filename, setup_args, monkey_patch_mode, o.verbose, output, log, show_output)
            except ConvertionError:
                raise
            except Exception:
                e = extract_exception()
                log.write("Error while converting - traceback:\n")
                tb = sys.exc_info()[2]
                traceback.print_tb(tb, file=log)
                msg = "Error while converting %s - you may look at %s for " \
                      "details (Original exception: %s %s)" 
                raise ConvertionError(msg % (filename, convert_log, type(e), str(e)))
        finally:
            log.flush()
            log.close()
Exemplo n.º 3
0
 def test_simple(self):
     self.assertEqual(comma_list_split("-a,-b"), ["-a", "-b"])
Exemplo n.º 4
0
 def test_simple(self):
     self.assertEqual(comma_list_split("-a,-b"), ["-a", "-b"])