def initpygame(settings, caption, settingsfile): pygame.init() screen = get_screen(settings["res_x"], settings["res_y"], settings["hardware_buffer"], settings["fullscreen"]) mode = "game" if "--editor" in sys.argv: mode = "editor" debug("Loading game editor") global imagecache imagecache = ImageCache() global frontend frontend = Frontend(mode=mode, settingsfile=settingsfile) global tilemaps tilemaps = Tilemaps() global messages imagecache.load() wallpaper = imagecache["landscape.png"] wallpaper = pygame.transform.smoothscale(wallpaper, (settings["res_x"], settings["res_y"])) screen.blit(wallpaper, (0, 0)) pygame.display.set_caption(caption) frontend = Frontend(screen, imagecache, eventstack, tilemaps, mode=mode, settingsfile=settingsfile) messages = Messages(screen, eventstack) messages.error("Welcome to Mirthless") if not "--editor" in sys.argv: messages.error( "Game mode is barely started. The editor is much further along. Try starting the game with --editor" ) messages.message(":)") tilemaps.initialize() return screen, frontend.screenlayout(), frontend
def test_can_show_status_as_paid(self): frontend = Frontend(Frontend.TYPE_FRONTEND_INVISIBLE) frontend.start() frontend.show_paid() active_div = frontend.get_active_div() frontend.shutdown() self.assertEqual(active_div, "#paid")
def test_can_show_invoice(self): frontend = Frontend(Frontend.TYPE_FRONTEND_INVISIBLE) frontend.start() frontend.show_invoice('bitcoin:1asdf') active_div = frontend.get_active_div() frontend.shutdown() self.assertEqual(active_div, "#invoice")
class GraphApp: @staticmethod def win_attributes(the_window): the_window.update_idletasks() w = the_window.winfo_screenwidth() h = the_window.winfo_screenheight() size = (410, 400) x = w / 2 - size[0] / 2 y = h / 2 - size[1] / 2 the_window.geometry("%dx%d+%d+%d" % (size + (x, y))) the_window.attributes('-topmost', 1) the_window.attributes('-topmost', 0) the_window.wm_title("Project 1: The Grapher") the_window.config(cursor='cross', background='#197278') the_window.overrideredirect(1) def __init__(self): self.win = Tk() self.win.protocol("WM_DELETE_WINDOW", self.win.destroy) self.win_attributes(self.win) self.web_server = object() self.server_is_running = False for button_type in ['upload', 'readme', 'quit']: ButtonCreator(self.win, button_type, self.fxn_mapper(button_type)) self.win.mainloop() def run_front_end(self, graph_data): self.web_server = Frontend(graph_data) self.web_server.start() self.server_is_running = True def upload(self): filename = askopenfilename() if filename: graph_data = file_import(filename) self.run_front_end(graph_data) def quit(self): self.win.destroy() if self.server_is_running: self.web_server.stop() def open_readme(self): webbrowser.open("file://" + os.path.abspath("readme.txt")) def fxn_mapper(self, typ): if typ == 'upload': return self.upload if typ == 'readme': return self.open_readme if typ == 'quit': return self.quit
def create_test_workspace(output): # Remove any existing output. shutil.rmtree(output, True) # Copy the base tests. copy_tree(os.path.join(SCRIPT_DIR, 'test_project'), output) # run.py file builder = Frontend(local_dir=SCRIPT_DIR) run_py_path = os.path.join(output, 'run.py') builder.write_file( path=run_py_path, template_name='run_py', data=TestData()) make_executable(run_py_path) return True
def __init__(self, registerfile, shiftregister, reset=0, load_file=None): self.registerfile = registerfile self.shiftregister = shiftregister # add control units self._units = {} self.led = Led(self.registerfile) self._units['LEDs'] = self.led self.hitlogic = HitLogic(self.registerfile) self._units['Hit logic'] = self.hitlogic self.filter = Filter(self.registerfile) self._units['Filter'] = self.filter self.monitor = Monitor(self.shiftregister) self._units['Monitor'] = self.monitor self.frontend = Frontend(self.shiftregister) self._units['Frontend'] = self.frontend self.adcbias = AdcBias(self.shiftregister) self._units['ADC bias'] = self.adcbias self.digital = Digital(self.registerfile) self._units['Digital'] = self.digital if reset: self.reset() self.apply() if load_file: self.load(load_file) self.update()
def main(): """ Main function to be called :return: Tkinter frame """ root = Tk() Frontend(root) root.mainloop()
class MainResource(object): def __init__(self): self._logger = logging.getLogger('gunicorn.error') self._frontend = Frontend() self._frontend.start() def on_get(self, req, resp): self._logger.debug( f'Handling {req.method} request {req.url} with params {req.params}' ) try: top_phrases = self._frontend.top_phrases_for_prefix( req.params['prefix']) response_body = json.dumps({ "status": "success", "data": { "top_phrases": top_phrases } }) resp.status = falcon.HTTP_200 resp.body = response_body except BackendNodesNotAvailable as err: response_body = json.dumps({ "status": "error", "message": "No backend nodes available to complete the request" }) resp.status = falcon.HTTP_500 resp.body = response_body except Exception as e: self._logger.error('An error occurred when processing the request', exc_info=e) response_body = json.dumps({ "status": "error", "message": "An error occurred when processing the request" }) resp.status = falcon.HTTP_500 resp.body = response_body
def test_user_can_initiate_new_invoice(self): q = Queue() def request_received(): q.put(None) frontend = Frontend(Frontend.TYPE_FRONTEND_INVISIBLE, invoice_request_callback=request_received) frontend.start() frontend.exercise_javascript_bridge() q.get() frontend.shutdown()
#!/usr/bin/env python from threading import Lock from flask import Flask, render_template, session, request from flask_socketio import SocketIO, Namespace, emit, join_room, leave_room, \ close_room, rooms, disconnect from frontend import Frontend import asyncio from threading import Thread async_mode = None app = Flask(__name__) socketio = SocketIO(app, async_mode=async_mode) f = Frontend(socketio) @app.route('/') def index(): return render_template('index.html', async_mode=socketio.async_mode) @socketio.on('disconnect_request', namespace='/daq') def on_disconnect_request(): disconnect() @socketio.on('ping', namespace='/daq') def on_ping(): emit('pong')
def handler(req): """main handler; called by mod_python""" from frontend import Frontend f = Frontend(req) return f.handle()
def build(self): return Frontend()
from tkinter import * from frontend import Frontend FE = Frontend() window = Tk() window.wm_title("Bookstore") titleLabel = Label(window, text='Title:') titleLabel.grid(row=0, column=0) autherLabel = Label(window, text='Auther:') autherLabel.grid(row=0, column=2) yearLabel = Label(window, text='Year:') yearLabel.grid(row=1, column=0) ISBNLabel = Label(window, text='ISBN:') ISBNLabel.grid(row=1, column=2) titleInput = StringVar() titleEntry = Entry(window, textvariable=titleInput) titleEntry.grid(row=0, column=1) autherInput = StringVar() autherEntry = Entry(window, textvariable=autherInput) autherEntry.grid(row=0, column=3) yearInput = StringVar() yearEntry = Entry(window, textvariable=yearInput) yearEntry.grid(row=1, column=1)
def run_front_end(self, graph_data): self.web_server = Frontend(graph_data) self.web_server.start() self.server_is_running = True
def run_frontend_server(proxy_port, frontend_port): f = Frontend('frontend', f'localhost:{proxy_port}', f'localhost:{frontend_port}', dnslb) f.start()
def test_can_be_started_and_stopped_and_defaults_to_idle(self): frontend = Frontend(Frontend.TYPE_FRONTEND_INVISIBLE) frontend.start() active_div = frontend.get_active_div() frontend.shutdown() self.assertEqual(active_div, "#idle")
if not api_key: raise Exception("Unable to load API key.") bitpay_provider = BitPayProvider(api_key) nfc_broadcast = NFCBroadcast() nfc_broadcast.start() invoice_queue = Queue() def new_invoice_requested(): invoice_queue.put(None) frontend = Frontend(frontend_type=Frontend.TYPE_FRONTEND_SMALL_DISPLAY, invoice_request_callback=new_invoice_requested) frontend.start() invoice_queue.get() # wait until user initiates a new invoice invoice = bitpay_provider.create_invoice(DEFAULT_AMOUNT, DEFAULT_CURRENCY) payment_request_service = \ BluetoothPaymentRequestService(invoice.get_payment_request()) payment_request_service.start() tx_submission_service = BluetoothTxSubmissionService(invoice.get_bip70_url()) tx_submission_service.start() bluetooth_address = tx_submission_service.get_bluetooth_address() nfc_broadcast.set_btc_uri(
print('Running. Press CTRL-C to exit.') try: Frontend({ 'phi': { 'mode': 'uniform', 'radius': 10 }, 'image': { 'path': 'resource/crack.bmp' }, 'algorithms': [{ 'name': 'ChanVese', 'kwargs': { 'dt': .5, 'mu': 0.2, 'v': 0, 'lambda1': 5, 'lambda2': 5 } }, { 'name': 'ChanVese', 'kwargs': { 'dt': .5, 'mu': 0.8, 'v': 0, 'lambda1': 1, 'lambda2': 1 } }] }).update() except KeyboardInterrupt: print('exiting...')
def __init__(self): self._logger = logging.getLogger('gunicorn.error') self._frontend = Frontend() self._frontend.start()
from yaml import safe_load from sys import exit from frontend import Frontend from manipulator import Manipulator from udp_comms import UDPComms if __name__ == "__main__": # TODO: XInput doesn't work with *nix devices, so we need to look into a different module try: with open("config/config.yml") as f: config = safe_load(f) except: print("Please copy config/template.yml to config/config.yml") exit(0) comms = UDPComms(config, debug=True) frontend = Frontend() manipulator = Manipulator() manipulator.start() frontend.start()
# parser.add_argument("--dns", help="dns address and port") # parser.add_argument("--listen_ip", help="ip address to listen") # parser.add_argument("--listen_port", help="port to listen") parser.add_argument("--upstream", help="upstream addr and port") parser.add_argument("--bind", help="bind addr and port") parser.add_argument("--name", help="app name. can be 'dns', 'frontend', 'proxy', 'counter") parser.add_argument("--dnslb", help="use client load balancer", action='store_true', default=False) def channel_options(args): return [('grpc.lb_policy_name', 'round_robin')] if args.dnslb else None if __name__ == '__main__': args = parser.parse_args() name = args.name if name == 'frontend': f = Frontend(name, args.upstream, args.bind, channel_options(args)) f.start() elif name == 'proxy': p = Proxy(name, args.upstream, args.bind, channel_options(args)) p.start() elif name == 'counter': run_server(args.bind) else: raise RuntimeError("Invalid App name!!")
#!/usr/bin/env python from frontend import Frontend def show_msg(): print "Request for a new invoice" frontend = Frontend(frontend_type=Frontend.TYPE_FRONTEND_SMALL_DISPLAY, invoice_request_callback=show_msg) frontend.start() raw_input("Press return to perform transition") frontend.show_paid() raw_input("Press return to exit") frontend.shutdown()
import renderer import theme_handler from curses_handler import CursesHandler from frontend import Frontend __tag__ = 'main' if __name__ == '__main__': locale.setlocale(locale.LC_ALL, '') code = locale.getpreferredencoding() error = None c_handler = CursesHandler() try: if c_handler.curses_init(): renderer.init_color() theme_handler.init_theme() renderer.draw_loading_screen() frontend = Frontend(c_handler) frontend.start() input_handler.start_input_handler(frontend) except BaseException as e: error = e finally: c_handler.curses_deinit() if error: # print type(error) print error.message
def test_can_switch_to_paid_and_back_to_idle(self): frontend = Frontend(Frontend.TYPE_FRONTEND_INVISIBLE) frontend.start() frontend.show_paid() active_div = frontend.get_active_div() frontend.show_idle() active_div2 = frontend.get_active_div() frontend.shutdown() self.assertEqual(active_div, "#paid") self.assertEqual(active_div2, "#idle")
from exploiter import Exploiter from webservice import WebService from submitter import Submitter from frontend import Frontend import signal import logging.config if __name__ == '__main__': logging.config.fileConfig(fname='log.conf') logger_exploiter = logging.getLogger('exploiter') logger_submitter = logging.getLogger('submitter') logger_webservice = logging.getLogger('webservice') WebService.start(logger_webservice) Exploiter.start(logger_exploiter) Submitter.start(logger_submitter) Frontend.start() signal.pause()
def init_backend(cmds): program = Frontend() return program.start(cmds)