def __init__(self, user=None, password=None, server=None, port=None, anon=False): """Initialise an SR trac object.""" config = Config() if server is None: server = config["server"] if port is None: port = config["https_port"] self.server = server self.port = port rpc_settings = {"server": server, "port": port} if anon: rpc_url = "https://{server}:{port}/trac/rpc" else: rpc_url = "https://{user}:{password}@{server}:{port}/trac/login" \ "/rpc" user = config.get_user(user) rpc_settings["user"] = user rpc_settings["password"] = config.get_password(password, user=user) rpc_url = rpc_url.format(**rpc_settings) ServerProxy.__init__(self, rpc_url) if 'ticket.create' not in self.system.listMethods(): raise WrongServer()
def command(args): import sys import subprocess from sr.tools.config import Config config = Config() username = config.get_user() url = GIT_URL.format(username=username, team=args.team.upper(), project=args.project) cmdline = ["git", "clone", url] if args.dir is not None: cmdline.append(args.dir) sys.exit(subprocess.call(cmdline))