def get_site(args): if args.password: pwd = args.password else: pwd = getpass.getpass("SMW Password: "******"Connecting to SMW") if conf.smw.https: site = mwclient.Site(('https', conf.smw.host), path=conf.smw.path) try: site = mwclient.Site(('http', conf.smw.host), path=conf.smw.path) except: try: site = mwclient.Site(('https', conf.smw.host), path=conf.smw.path) except: G.critical("Cannot login the swm site") raise try: site.login(args.username, pwd) except mwclient.errors.LoginError: exer("Can not login. (Wrong password?)") G.info("Connected to SMW") return site