def search_crypto(): global crypto_dict os.system("cls") check_crypto_dict() for el in crypto_dict: print(el, end = " ") print("") symbol = input("Enter symbol of crypto currency: ") url_id = crypto_dict[symbol.upper()] data, info = api.get_info(url_id, option="search") table = tables.create_table(data, "search") os.system("cls") print(table) print("Description: " + info["description"]) print("Website: " + info["urls"]["website"][0]) if info["urls"]["website"] else print("Website: /") print("Source code: " + info["urls"]["source_code"][0]) if info["urls"]["source_code"] else print("Souce Code: /") print("") choice = input("Do you want to search again? (y/n) ") search_crypto() if choice.lower() == "y" or choice.lower() =="yes" else main()
def fiat_currency(): global crypto_dict global currencies os.system("cls") check_crypto_dict() for el in crypto_dict: print(el, end = " ") if currencies == []: currencies = api.get_currencies() pick = input("Insert cryptocurrency: >>").upper() print("") for currency in currencies: print(currency["symbol"], end=" ") fiat = input("Insert fiat currency: >>").upper() data = api.get_info(crypto_dict[pick], fiat) last_updated = data["last_updated"] date = last_updated.split("T")[0] time = last_updated.split("T")[1][:-1] price = round(data["quote"][fiat]["price"],2) print("") print("Value of {0} for {1} on {2} at {3} is {4} {5}".format(pick, fiat, date, time, price, fiat)) choice = input("Do you want to search again? (y/n) ") fiat_currency() if choice.lower() == "y" or choice.lower() =="yes" else main()
def run_by_gender(token, number, gender, query, folder_id, ws): query['pageSize'] = 0 query['gender'] = GENDER[gender] while number: resume_list, resume_str = get_resume_list(token, query) resume_list_is_purchase = get_resume_list_is_purchase(token, resume_str) resume_id_list_is_purchase = [get_resume_id_is_purchase(resume) for resume in resume_list_is_purchase] for resume in resume_list: if ws.closed: return resume_id = get_resume_id(resume) if resume_id in resume_id_list_is_purchase: continue else: read_resume(token, resume_id) result, balance, free_count = unlock_resume(token, resume_id, folder_id) if free_count < 100: convert_balance(token) if result: info = get_info(token, resume_id) msg = json.dumps({'info': info}) ws.send(msg) number -= 1 if number == 0: return query['pageSize'] += 1
def dashboard(server_id): if session.get('token') is None: return redirect('/') guild = get_guild(server_id) if guild is None: return redirect(get_invite_link(config["id_bot"], server_id, quote(config["redirect_2"]))) servers = api.get_guilds(session.get('token')) guilds = list(filter(lambda g: (g['owner'] is True) or bool((int(g['permissions']) >> 5) & 1),servers)) perm = [] for gg in guilds: if guild["id"] == gg["id"]: perm.append(guild["id"]) else: pass guild_db = get_guild_find(server_id) if guild_db is None: return redirect(url_for('guilds')) if guild["id"] in perm: try: user = api.get_info(session.get('token')) date = get_date_guild(server_id) except requests.exceptions.HTTPError:return redirect("/") return render_template('dashboard.html', guild=guild,guild_db=guild_db,user=user, date=date, title="Asuna - "+guild["name"])
def me(): if session.get('token') is None: return redirect("/") try: user = api.get_info(session.get('token')) except requests.exceptions.HTTPError: return "Invalid Token, try again." return jsonify(user)
def guilds(): if session.get('token') is None: return redirect('/') try: user = api.get_info(session.get('token')) servers = api.get_guilds(session.get('token')) guilds = list(filter(lambda g: (g['owner'] is True) or bool((int(g['permissions']) >> 5) & 1),servers)) except requests.exceptions.HTTPError: return redirect("/") return render_template('select-server.html', user=user, guilds=guilds, title="Asuna - Servidores")
def search(): raw = api.get_info(request.args.get('city'), request.args.get('job')) res = ranking.rankme(raw) return jsonify({ 'req': { 'city': request.args.get('city'), 'job': request.args.get('job') }, 'res' : res })
def index(): if session.get('token') is None: url_authentication = str(config["url_app"]).format(config["id_bot"], quote(config["redirect"]), quote(config["scopes"])) url_bot = str(config["url_bot"]).format(config["id_bot"], quote(config["redirect_3"]), quote("bot")) url = {"url_bot":url_bot, "url_authentication":url_authentication} return render_template('index.html', url=url, title="Asuna - Index") try: user = api.get_info(session.get('token')) except requests.exceptions.HTTPError: return "Token invalido!" url_bot = str(config["url_bot"]).format(config["id_bot"], quote(config["redirect_2"]), quote("bot")) url = {"url_bot":url_bot} return render_template('index.html', url=url, title="Asuna - Index", user=user)
def info(): if request.method == "GET": # 如果是get请求则跳转回主页 return "<script>window.location.href='/';</script> " user = request.form["username"] pwd = request.form["password"] try: content = api.get_info(user, pwd) except: traceback.print_exc() return "阿勒,服务器出现了一个异常,请稍后再试试吧" if content["状态"] == "正常": return render_template("info.html", content=content) elif content["状态"] == "密码错误": return "密码错误" else: return "ugly refuse"
def main(): offset = request.args.get('offset', 30 * 60) offset = int(offset) url = request.args.get('url') domain = request.args.get('domain') skip = request.args.get('skip', 10) if url: urls = [api.get_info(url)] domains = [url.lstrip('http://').split('/')[0].split(':')[0]] elif domain: domains = [domain] urls = [ info for info in api.get_urls_and_hostname() if domain in info.get('url') ] else: urls = api.get_urls_and_hostname() domains = [ info.get('url').lstrip('http://').split('/')[0].split(':')[0] for info in urls ] # remove port from domain if domain is ip domains = [ i if ':' not in i else i.split(':')[0] for i in domains if i ] domains = list(set(domains)) domains.sort() # only display 1 url per domain short_list = [] for domain in domains: for info in urls: if domain in info.get('url'): short_list.append(info) break urls = short_list return render_template('home.html', urls=urls, domains=domains, offset=offset, skip=skip)
def nme(): if session.get('token') is None: return redirect("/") try: if "identify" in session.get('scopes'): user = api.get_info(session.get('token')) else: user = None if "guilds" in session.get('scopes'): guilds = jsonify(api.get_guilds(session.get('token'))) else: guilds = None if "connections" in session.get('scopes'): connections = api.get_connections(session.get('token')) else: connections = None except requests.exceptions.HTTPError as e: return "Unexpected Error:<br>{}".format(e) print(guilds) if "email" in session.get('scopes'): email = True else: email = False print(session.get('scopes')) return render_template('me.html', user=user, guilds=guilds, connections=connections, email=email)
def main(): offset = request.args.get('offset', 30 * 60) offset = int(offset) url = request.args.get('url') domain = request.args.get('domain') skip = request.args.get('skip', 10) if url: urls = [api.get_info(url)] domains = [url.lstrip('http://').split('/')[0].split(':')[0]] elif domain: domains = [domain] urls = [info for info in api.get_urls_and_hostname() if domain in info.get('url')] else: urls = api.get_urls_and_hostname() domains = [info.get('url').lstrip('http://').split('/')[0].split(':')[0] for info in urls] # remove port from domain if domain is ip domains = [i if ':' not in i else i.split(':')[0] for i in domains if i] domains = list(set(domains)) domains.sort() # only display 1 url per domain short_list = [] for domain in domains: for info in urls: if domain in info.get('url'): short_list.append(info) break urls = short_list return render_template('home.html', urls=urls, domains=domains, offset=offset, skip=skip)
def get_info(arguments): api.initialize_configuration() api.get_info(arguments['--app'], arguments['--env'])
def getting_token(message): """ Authenticating user. """ token = None logging.debug("Deleting message with credentials") logging.debug(BOT.delete_message(message.chat.id, message.message_id)) logging.debug("Sending message, that will be edited") message_from_bot = BOT.send_message(message.chat.id, config.PLEASE_WAIT) logging.debug(message_from_bot) session = requests.Session() try: logging.debug("Trying to auth user") token = auth(*message.text.split(" "), session) except (SystemError, ConnectionError, ConnectionResetError, ProtocolError): logging.error("Error on auth request to schools.by") logging.debug( BOT.edit_message_text( chat_id=message_from_bot.chat.id, message_id=message_from_bot.message_id, text=config.SOMETHING_WENT_WRONG, )) return except KeyError: logging.debug("Incorrect credentials") logging.debug( BOT.edit_message_text( chat_id=message_from_bot.chat.id, message_id=message_from_bot.message_id, text=config.INCORRECT_CREDENTIALS, )) return TOKENS[str(message.from_user.id)] = dict() TOKENS[str(message.from_user.id)]["token"] = token try: TOKENS[str(message.from_user.id)]["user_info"] = get_info( TOKENS[str(message.from_user.id)]["token"], session) except (SystemError, ConnectionError, ConnectionResetError, ProtocolError): logging.error("Error on get_info request to schools.by") logging.debug( BOT.edit_message_text( chat_id=message_from_bot.chat.id, message_id=message_from_bot.message_id, text=config.SOMETHING_WENT_WRONG, )) return if TOKENS[str(message.from_user.id)]["user_info"]["type"] == "Parent": try: TOKENS[str(message.from_user.id)]["pupils"] = get_pupils( token, TOKENS[str(message.from_user.id)]["user_info"]["id"], session) except (SystemError, ConnectionError, ConnectionResetError, ProtocolError): logging.error("Error on get_pupils request to schools.by") logging.debug( BOT.edit_message_text( chat_id=message_from_bot.chat.id, message_id=message_from_bot.message_id, text=config.SOMETHING_WENT_WRONG, )) return logging.debug("Replying, that user is authenticated") logging.debug( BOT.edit_message_text( chat_id=message_from_bot.chat.id, message_id=message_from_bot.message_id, text=config.LOGGED_IN.format( TOKENS[str(message.from_user.id)]["user_info"]["last_name"], TOKENS[str(message.from_user.id)]["user_info"]["first_name"], TOKENS[str(message.from_user.id)]["user_info"]["subdomain"], ), )) update_config()