def add_connections(): """Adds fake user connections to the system""" current_users = db.session.query(User.user_id).all() for i in range(2000): user1 = random.choice(current_users) user2 = random.choice(current_users) if user1 != user2 and not pair_lookup(user1, user2): pair = Pair(user_1_id=user1, user_2_id=user2) db.session.add(pair) db.session.commit()
def add_pair_to_db(current_user_id, user_connecting_with_id): """Adds a pair to the database, should only be called after a connection has been requested by one user and accepted by the other""" pair = Pair(user_1_id=user_connecting_with_id, user_2_id=current_user_id) db.session.add(pair) db.session.commit() other_user_username = (User.query.filter( User.user_id == user_connecting_with_id).first()).username Request.query.filter(Request.requester_id == user_connecting_with_id, Request.requestee_id == current_user_id).delete() db.session.commit() return pair.pair_id
import pandas as pd import json import datetime from model import Pair, Trade fp = open("input_csv/ed_trade_data.json") jsondata = json.load(fp) pairlist = jsondata.keys() total_data = [] for i in pairlist: pair = Pair(i) pair_data = jsondata[str(pair)] trades = [] for j in pair_data: trade = Trade(i, j) trades.append(trade) total_data.append(trades) print pd.DataFrame(total_data)
def update_model(self, game_model): game_model.pairs = {} for pair in range(len(self.pairs)): pair_card = Pair() # achar achar = self.pairs[pair].get_text(1) if achar != '': pair_card.set_property('achar', achar) # bchar bchar = self.pairs[pair].get_text(2) if bchar != '': pair_card.set_property('bchar', bchar) # aspeak aspeak = self.pairs[pair].get_speak(1) pair_card.set_property('aspeak', aspeak) # bspeak bspeak = self.pairs[pair].get_speak(2) pair_card.set_property('bspeak', bspeak) # aimg aimg = self.pairs[pair].get_image_path(1) if aimg is not None: aimgfile = self.pairs[pair].get_image_path(1) pair_card.set_property('aimg', basename(aimgfile)) # bimg bimg = self.pairs[pair].get_image_path(2) if bimg is not None: bimgfile = self.pairs[pair].get_image_path(2) pair_card.set_property('bimg', basename(bimgfile)) # asnd asnd = self.pairs[pair].get_sound(1) logging.debug('update_model asnd %s', asnd) if asnd is not None: pair_card.set_property('asnd', basename(asnd)) # bsnd bsnd = self.pairs[pair].get_sound(2) logging.debug('update_model bsnd %s', bsnd) if bsnd is not None: pair_card.set_property('bsnd', basename(bsnd)) game_model.pairs[pair] = pair_card self.pair_list_modified = False
import time import pyautogui as pg from model import Pair from sequence import * from util import logcall pg.FAILSAFE = True # Banned from Equestria (Daily) v1.5 WINDOW_TITLE = 'Banned from Equestria (Daily)' WINDOW_POS_OFFSET = Pair(0, 0) EXTRA_POS_OFFSET = Pair(-8, -8) # Misc @logcall def place_window(): """Find the window, raise it, size it and move it""" browser_window: pg.Window [browser_window] = pg.getWindowsWithTitle(WINDOW_TITLE) x, y = WINDOW_POS_OFFSET cx, cy = EXTRA_POS_OFFSET browser_window.moveTo(x + cx, y + cy) browser_window.resizeTo(newWidth=835, newHeight=820) browser_window.activate() @logcall def reload():
def get_pairs(numbers): extracted_pairs = [] for i in range(0, len(numbers) - 1): for m in range(i + 1, len(numbers)): extracted_pairs.append(Pair(numbers[i], numbers[m])) return extracted_pairs