def find_reviewers(ui, api_server, user_cache_filename, auth, search_strings): cache = bzauth.load_user_cache(ui, api_server, user_cache_filename) section = api_server search_results = [] for search_string in search_strings: name = cache.get(section, search_string) if name: search_results.append({"search_string": search_string, "names": [name], "real_names": ["not_a_real_name"]}) continue try: try: users = bz.find_users(auth, search_string) except Exception as e: raise util.Abort(e.message) name = None real_names = map(lambda user: "******" % (user["real_name"], user["email"]) if user["real_name"] else user["email"], users["users"]) names = map(lambda user: user["name"], users["users"]) search_results.append({"search_string": search_string, "names": names, "real_names": real_names}) if len(real_names) == 1: cache.set(section, search_string, names[0]) except Exception, e: search_results.append({"search_string": search_string, "error": str(e), "real_names": None}) raise
def find_users(ui, api_server, user_cache_filename, token, search_strings): c = bzauth.load_user_cache(ui, api_server, user_cache_filename) section = api_server search_results = [] for search_string in search_strings: name = c.get(section, search_string) if name: search_results.append({"search_string": search_string, "names": [name], "real_names": ["not_a_real_name"]}) continue try: users = json.load(urlopen(ui, bz.find_users(api_server, token, search_string))) name = None real_names = map(lambda user: "******" % (user["real_name"], user["email"]) if user["real_name"] else user["email"], users["users"]) names = map(lambda user: user["name"], users["users"]) search_results.append({"search_string": search_string, "names": names, "real_names": real_names}) if len(real_names) == 1: c.set(section, search_string, names[0]) except Exception, e: search_results.append({"search_string": search_string, "error": str(e), "real_names": None}) raise