def start(self, pause_sec=2): wi = WebInterface(DownloadManager.base_url) wp_all = AllHeroesParser() wp_detail = HeroDetailParser() heroes_all = wp_all.parse(wi.load_html_content(DownloadManager.all_heroes_url)) self.heroes = [] for i, hero in enumerate(heroes_all): img_path = DataManager.convert_url_to_img_path(hero['url'], hero['img_url']) sleep(pause_sec) details = wp_detail.parse(wi.load_html_content(hero['url'])) related_to = {} for related_hero in details: related_to[related_hero['name']] = related_hero['advantage'] self.heroes.append(Hero(name=hero['name'], img_path=img_path, related_to=related_to)) try: with open(img_path, 'rb') as fp: pass except IOError: # image file not found sleep(pause_sec) DataManager.save_image(wi.load_image(hero['img_url']), img_path) self.hero_loaded.emit(hero['name'], i+1, len(heroes_all)) self.job_done.emit()
def main(): webcam = WebCam() tracker = ScrumBoardTracker(webcam) tracker.start() webinterface = WebInterface(webcam) webinterface.start() reactor.run()
def main(): socket_num = int(input('Node socket: ')) node = Node(socket_num) interface = WebInterface(node, socket_num + 1) threading.Thread(target=interface.start, args=(None, )).start() print( 'Node running on socket {}, web interface accessible at localhost:{}'. format(socket_num, socket_num + 1)) node.start()
def start(self, pause_sec=2): wi = WebInterface(DownloadManager.base_url) wp_all = AllHeroesParser() wp_detail = HeroDetailParser() heroes_all = wp_all.parse( wi.load_html_content(DownloadManager.all_heroes_url)) self.heroes = [] for i, hero in enumerate(heroes_all): img_path = DataManager.convert_url_to_img_path( hero['url'], hero['img_url']) sleep(pause_sec) details = wp_detail.parse(wi.load_html_content(hero['url'])) related_to = {} for related_hero in details: related_to[related_hero['name']] = related_hero['advantage'] self.heroes.append( Hero(name=hero['name'], img_path=img_path, related_to=related_to)) try: with open(img_path, 'rb') as fp: pass except IOError: # image file not found sleep(pause_sec) DataManager.save_image(wi.load_image(hero['img_url']), img_path) self.hero_loaded.emit(hero['name'], i + 1, len(heroes_all)) self.job_done.emit()
from flask import Flask from flask import render_template, redirect, request from chess import Board from movehistory import MoveHistory from webinterface import WebInterface app = Flask(__name__) ui = WebInterface() game = Board() movehistory = MoveHistory(100) @app.route('/') def root(): return render_template('index.html') @app.route('/newgame', methods=["POST"]) def newgame(): game.start() ui.board = game.display() wname, bname = request.form['wname'], request.form['bname'] if wname and bname: return redirect('/play') else: return redirect('/') @app.route('/play', methods=['POST', 'GET']) def play(): if request.method == "POST":