Example #1
0
    def do(self):
        for env in ('FILENAME', 'REVISION', 'ARGS'):
            try:
                compat.unsetenv(env)
            except KeyError:
                pass
        rev = None
        args = None
        opts = _config.get_guitool_opts(self.action_name)
        cmd = opts.get('cmd')
        if 'title' not in opts:
            opts['title'] = cmd

        if 'prompt' not in opts or opts.get('prompt') is True:
            prompt = N_('Run "%s"?') % cmd
            opts['prompt'] = prompt

        if opts.get('needsfile'):
            filename = selection.filename()
            if not filename:
                Interaction.information(
                        N_('Please select a file'),
                        N_('"%s" requires a selected file.') % cmd)
                return False
            compat.setenv('FILENAME', filename)

        if opts.get('revprompt') or opts.get('argprompt'):
            while True:
                ok = Interaction.confirm_config_action(cmd, opts)
                if not ok:
                    return False
                rev = opts.get('revision')
                args = opts.get('args')
                if opts.get('revprompt') and not rev:
                    title = N_('Invalid Revision')
                    msg = N_('The revision expression cannot be empty.')
                    Interaction.critical(title, msg)
                    continue
                break

        elif opts.get('confirm'):
            title = os.path.expandvars(opts.get('title'))
            prompt = os.path.expandvars(opts.get('prompt'))
            if Interaction.question(title, prompt):
                return
        if rev:
            compat.setenv('REVISION', rev)
        if args:
            compat.setenv('ARGS', args)
        title = os.path.expandvars(cmd)
        Interaction.log(N_('Running command: %s') % title)
        cmd = ['sh', '-c', cmd]

        if opts.get('noconsole'):
            status, out, err = core.run_command(cmd)
        else:
            status, out, err = Interaction.run_command(title, cmd)

        Interaction.log_status(status,
                               out and (N_('Output: %s') % out) or '',
                               err and (N_('Errors: %s') % err) or '')

        if not opts.get('norescan'):
            self.model.update_status()
        return status
Example #2
0
    def do(self):
        for env in ('FILENAME', 'REVISION', 'ARGS'):
            try:
                compat.unsetenv(env)
            except KeyError:
                pass
        rev = None
        args = None
        cfg = gitcfg.current()
        opts = cfg.get_guitool_opts(self.action_name)
        cmd = opts.get('cmd')
        if 'title' not in opts:
            opts['title'] = cmd

        if 'prompt' not in opts or opts.get('prompt') is True:
            prompt = N_('Run "%s"?') % cmd
            opts['prompt'] = prompt

        if opts.get('needsfile'):
            filename = selection.filename()
            if not filename:
                Interaction.information(
                        N_('Please select a file'),
                        N_('"%s" requires a selected file.') % cmd)
                return False
            compat.setenv('FILENAME', filename)

        if opts.get('revprompt') or opts.get('argprompt'):
            while True:
                ok = Interaction.confirm_config_action(cmd, opts)
                if not ok:
                    return False
                rev = opts.get('revision')
                args = opts.get('args')
                if opts.get('revprompt') and not rev:
                    title = N_('Invalid Revision')
                    msg = N_('The revision expression cannot be empty.')
                    Interaction.critical(title, msg)
                    continue
                break

        elif opts.get('confirm'):
            title = os.path.expandvars(opts.get('title'))
            prompt = os.path.expandvars(opts.get('prompt'))
            if Interaction.question(title, prompt):
                return
        if rev:
            compat.setenv('REVISION', rev)
        if args:
            compat.setenv('ARGS', args)
        title = os.path.expandvars(cmd)
        Interaction.log(N_('Running command: %s') % title)
        cmd = ['sh', '-c', cmd]

        if opts.get('background'):
            core.fork(cmd)
            status, out, err = (0, '', '')
        elif opts.get('noconsole'):
            status, out, err = core.run_command(cmd)
        else:
            status, out, err = Interaction.run_command(title, cmd)

        Interaction.log_status(status,
                               out and (N_('Output: %s') % out) or '',
                               err and (N_('Errors: %s') % err) or '')

        if not opts.get('background') and not opts.get('norescan'):
            self.model.update_status()
        return status
Example #3
0
    def do(self):
        for env in ('FILENAME', 'REVISION', 'ARGS'):
            try:
                compat.unsetenv(env)
            except KeyError:
                pass
        rev = None
        args = None
        opts = _config.get_guitool_opts(self.name)
        cmd = opts.get('cmd')
        if 'title' not in opts:
            opts['title'] = cmd

        if 'prompt' not in opts or opts.get('prompt') is True:
            prompt = i18n.gettext('Are you sure you want to run %s?') % cmd
            opts['prompt'] = prompt

        if opts.get('needsfile'):
            filename = selection.filename()
            if not filename:
                Interaction.information('Please select a file',
                                        '"%s" requires a selected file' % cmd)
                return False
            compat.putenv('FILENAME', filename)

        if opts.get('revprompt') or opts.get('argprompt'):
            while True:
                ok = Interaction.confirm_config_action(cmd, opts)
                if not ok:
                    return False
                rev = opts.get('revision')
                args = opts.get('args')
                if opts.get('revprompt') and not rev:
                    title = 'Invalid Revision'
                    msg = 'The revision expression cannot be empty.'
                    Interaction.critical(title, msg)
                    continue
                break

        elif opts.get('confirm'):
            title = os.path.expandvars(opts.get('title'))
            prompt = os.path.expandvars(opts.get('prompt'))
            if Interaction.question(title, prompt):
                return
        if rev:
            compat.putenv('REVISION', rev)
        if args:
            compat.putenv('ARGS', args)
        title = os.path.expandvars(cmd)
        Interaction.log('running: ' + title)
        cmd = ['sh', '-c', cmd]

        if opts.get('noconsole'):
            status, out, err = utils.run_command(cmd)
        else:
            status, out, err = Interaction.run_command(title, cmd)

        Interaction.log_status(status, out and 'stdout: %s' % out, err
                               and 'stderr: %s' % err)

        if not opts.get('norescan'):
            self.model.update_status()
        return status
Example #4
0
    def do(self):
        for env in ("FILENAME", "REVISION", "ARGS"):
            try:
                compat.unsetenv(env)
            except KeyError:
                pass
        rev = None
        args = None
        opts = _config.get_guitool_opts(self.name)
        cmd = opts.get("cmd")
        if "title" not in opts:
            opts["title"] = cmd

        if "prompt" not in opts or opts.get("prompt") is True:
            prompt = i18n.gettext("Are you sure you want to run %s?") % cmd
            opts["prompt"] = prompt

        if opts.get("needsfile"):
            filename = selection.filename()
            if not filename:
                Interaction.information("Please select a file", '"%s" requires a selected file' % cmd)
                return False
            compat.putenv("FILENAME", filename)

        if opts.get("revprompt") or opts.get("argprompt"):
            while True:
                ok = Interaction.confirm_config_action(cmd, opts)
                if not ok:
                    return False
                rev = opts.get("revision")
                args = opts.get("args")
                if opts.get("revprompt") and not rev:
                    title = "Invalid Revision"
                    msg = "The revision expression cannot be empty."
                    Interaction.critical(title, msg)
                    continue
                break

        elif opts.get("confirm"):
            title = os.path.expandvars(opts.get("title"))
            prompt = os.path.expandvars(opts.get("prompt"))
            if Interaction.question(title, prompt):
                return
        if rev:
            compat.putenv("REVISION", rev)
        if args:
            compat.putenv("ARGS", args)
        title = os.path.expandvars(cmd)
        Interaction.log("running: " + title)
        cmd = ["sh", "-c", cmd]

        if opts.get("noconsole"):
            status, out, err = utils.run_command(cmd)
        else:
            status, out, err = Interaction.run_command(title, cmd)

        Interaction.log_status(status, out and "stdout: %s" % out, err and "stderr: %s" % err)

        if not opts.get("norescan"):
            self.model.update_status()
        return status
Example #5
0
    def do(self):
        for env in ("FILENAME", "REVISION", "ARGS"):
            try:
                compat.unsetenv(env)
            except KeyError:
                pass
        rev = None
        args = None
        cfg = gitcfg.current()
        opts = cfg.get_guitool_opts(self.action_name)
        cmd = opts.get("cmd")
        if "title" not in opts:
            opts["title"] = cmd

        if "prompt" not in opts or opts.get("prompt") is True:
            prompt = N_('Run "%s"?') % cmd
            opts["prompt"] = prompt

        if opts.get("needsfile"):
            filename = selection.filename()
            if not filename:
                Interaction.information(N_("Please select a file"), N_('"%s" requires a selected file.') % cmd)
                return False
            compat.setenv("FILENAME", filename)

        if opts.get("revprompt") or opts.get("argprompt"):
            while True:
                ok = Interaction.confirm_config_action(cmd, opts)
                if not ok:
                    return False
                rev = opts.get("revision")
                args = opts.get("args")
                if opts.get("revprompt") and not rev:
                    title = N_("Invalid Revision")
                    msg = N_("The revision expression cannot be empty.")
                    Interaction.critical(title, msg)
                    continue
                break

        elif opts.get("confirm"):
            title = os.path.expandvars(opts.get("title"))
            prompt = os.path.expandvars(opts.get("prompt"))
            if Interaction.question(title, prompt):
                return
        if rev:
            compat.setenv("REVISION", rev)
        if args:
            compat.setenv("ARGS", args)
        title = os.path.expandvars(cmd)
        Interaction.log(N_("Running command: %s") % title)
        cmd = ["sh", "-c", cmd]

        if opts.get("background"):
            core.fork(cmd)
            status, out, err = (0, "", "")
        elif opts.get("noconsole"):
            status, out, err = core.run_command(cmd)
        else:
            status, out, err = Interaction.run_command(title, cmd)

        Interaction.log_status(status, out and (N_("Output: %s") % out) or "", err and (N_("Errors: %s") % err) or "")

        if not opts.get("background") and not opts.get("norescan"):
            self.model.update_status()
        return status