def main(argv): if len(sys.argv) != 2: sys.stdout.write("Please pass the new report as an argument.\n") sys.exit(1) new_report = argv[1] if not os.path.exists(new_report): sys.stdout.write("ERROR: The report %s does not exist.\n" % argv[1]) sys.exit(1) if not Utils.check_user(constants.STACK_USER): sys.stdout.write("ERROR: Run the script as %s " "user.\n" % constants.STACK_USER) sys.exit(1) if not os.path.isfile(constants.OVERCLOUDRC_FILE): sys.stdout.write("ERROR: %s does not exist." "\n" % constants.OVERCLOUDRC_FILE) sys.exit(1) Utils.source_rc_files(constants.OVERCLOUDRC_FILE) with open(new_report) as new_report_data: new_report_json = json.load(new_report_data) new_report_map = generate_new_report_map(new_report_json) old_report_json = create_old_report() if not old_report_json: sys.stdout.write("No existing imported topology.\n") return compare_reports(old_report_json, new_report_map)
def __init__(self): self.token = "1071984975:AAH2rEuvVpcStNlqAPvxpNuUjeiKyOEY2fw" self.base_url = f"https://api.telegram.org/bot{self.token}/" self.headers = { "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36", "accept": "*/*" } (self.past_timestamp, self.curr_timestamp, self.future_timestamp) = Utils.get_timestamps() (self.past_date, self.curr_date, self.future_date) = Utils.get_dates()
def main(): if not Utils.check_user(constants.STACK_USER): sys.stdout.write("ERROR: Run the script as %s user.\n" % constants.STACK_USER) sys.exit(1) if not os.path.isfile(constants.STACKRC_FILE): sys.stdout.write("ERROR: %s does not exist." "\n" % constants.OVERCLOUDRC_FILE) sys.exit(1) if not os.path.isfile(constants.OVERCLOUDRC_FILE): sys.stdout.write("ERROR: %s does not exist." "\n" % constants.OVERCLOUDRC_FILE) sys.exit(1) topo_playbook_path = os.path.join(constants.NUAGE_TC_PATH, "get_topo.yml") run_ansible(topo_playbook_path)
import json import math import requests from models.card_info import CardInfo from helper.utils import Utils utils = Utils() class TCGPlayerUtils: def __init__(self, exchange_rate): self.exchange_rate = exchange_rate self.colones_sign = 'CR' def get_items(self, set_code, card_name, edition="", condition="", image="", expansion="", rarity="", product_id=""): try: print(f'Getting items from set code: {set_code}') card_list = [] url2 = f"https://shop.tcgplayer.com/productcatalog/product/changepricetablepagesize?" \ f"pageSize=50&" \ f"productId={product_id}&" \
from multiprocessing.pool import ThreadPool from flask import Flask, request from flask_restful import Api from helper.tcgplayer_utils import TCGPlayerUtils from helper.tyt_utils import TYTUtils from helper.utils import Utils from flask_cors import CORS app = Flask(__name__) CORS(app) api = Api(app) utils = Utils() exchange_rate = utils.get_exchange_rate() tcgp = TCGPlayerUtils(exchange_rate=exchange_rate) tyt = TYTUtils(exchange_rate=exchange_rate) @app.route('/api/get_sets_by_name', methods=['GET']) def get_sets_by_name(): try: bar = request.args.to_dict() name = bar['name'] results = utils.get_card_info_from_name(name=name) return {'results': results} except Exception as e: print(e) return f'Error: {e}'
from helper.utils import Utils utils = Utils() results = utils.get_card_info_from_name("yata")