def check_command(cmd, exp): base = [prog, '-r', repo] args = cmd.split(' ') if not args == ['']: # need this for 'just `ghi`' command test base.extend(args) sys.argv = base if type(exp) == type(Exception): assert_raises(exp, main) else: assert main() == exp
def check_command(cmd, exp): base = [prog, "-r", repo] args = cmd.split(" ") if not args == [""]: # need this for 'just `ghi`' command test base.extend(args) sys.argv = base if type(exp) == type(Exception): assert_raises(exp, main) else: output = main() assert output == exp
def check_command(cmd, exp): base = [prog, '-r', repo] args = cmd.split(' ') if not args == ['']: # need this for 'just `ghi`' command test base.extend(args) sys.argv = base if type(exp) == type(Exception): assert_raises(exp, main) else: output = main() assert output == exp
try: repository = kwargs.get('repo') if repository: user, repo = get_remote_info_from_option(repository) else: user, repo = get_remote_info() commands = Commands(user, repo) getattr(commands, cmd)(*args[1:], **kwargs) except AttributeError: return "error: command '%s' not implemented" % cmd except Exception, info: return "error: %s" % info if __name__ == '__main__': main() ########NEW FILE######## __FILENAME__ = utils import os import sys import re import urllib2 import tempfile import subprocess import textwrap from urllib2 import build_opener, HTTPCookieProcessor, Request from urllib import urlencode from subprocess import Popen, PIPE, STDOUT opener = build_opener(HTTPCookieProcessor)