def test_setenv(self): """Test the core.decode function""" key = 'COLA_UNICODE_TEST' value = '字龍' compat.setenv(key, value) self.assertTrue(key in os.environ) self.assertTrue(os.getenv(key)) compat.unsetenv(key) self.assertFalse(key in os.environ) self.assertFalse(os.getenv(key))
def test_setenv(): """Test the core.decode function""" key = 'COLA_UNICODE_TEST' value = '字龍' compat.setenv(key, value) assert key in os.environ assert os.getenv(key) compat.unsetenv(key) assert key not in os.environ assert not os.getenv(key)
def test_setenv(self): """Test the core.decode function """ key = 'COLA_UNICODE_TEST' value = '字龍' compat.setenv(key, value) self.assertTrue(key in os.environ) self.assertTrue(os.getenv(key)) compat.unsetenv(key) self.assertFalse(key in os.environ) self.assertFalse(os.getenv(key))
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
def __exit__(self, exc_type, exc_val, exc_tb): compat.unsetenv('GIT_SEQUENCE_EDITOR') for var in self.extras: compat.unsetenv(var)
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
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
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
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
def __exit__(self, exc_type, exc_val, exc_tb): compat.unsetenv("GIT_SEQUENCE_EDITOR") for var in self.env: compat.unsetenv(var)