def __init__(self): pygame.init() #self.screen_size = pygame.display.list_modes()[0] Application.__init__(self) #pygame.display.toggle_fullscreen() self.ships = ShipGroup(self.max_ships) self.xplos = ExplosionGroup() self.screen_bounds = bounds = self.screen.get_rect() dc_height = 40 self.dc_font = pygame.font.Font(None, 30) self.dc_bounds = Rect(0, bounds.height - dc_height, bounds.width, dc_height) self.game_bounds = Rect(0, 0, bounds.width, bounds.height - dc_height) spawn_area = self.game_bounds.inflate(-self.game_bounds.width/4, -self.game_bounds.height/4) self.spawners = [ TieSpawner(1000, self.ships, self.game_bounds, spawn_area), YWingSpawner(2000, self.ships, self.game_bounds) ] self.detonator = Detonator(self.game_bounds, self.xplos) for spawner in self.spawners: spawner.spawn() Ship.death_count = DeathCount() self.current_weapon = MiniExplosionsWeapon(self)
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = Group() self.spawners = [ TieSpawner(2000, self.ships, self.bounds) ]
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = Group() self.spawners = [ShipSpawner(2000, self.ships, self.bounds)]
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = ShipGroup(self.max_ships) self.spawners = [TieSpawner(2000, self.ships, self.bounds)]
def start_pspeps(self, ip_addr, port, firmware_id, app_path, use_async=True): """ Demux different projects """ if app_path and firmware_id: base_dir = os.path.dirname(os.path.abspath(__file__)) or '.' import pkgutil self.app_dir = os.path.join(base_dir, app_path) if self.app_dir not in sys.path: sys.path.insert(0, self.app_dir) from app import Application Window.set_title(firmware_id) self.app = Application(ip=ip_addr, port=port, use_async=use_async) self.clients = {} for loader, name, ispkg in pkgutil.iter_modules( path=[self.app_dir + '/clients']): if not ispkg: mtime = self.get_client_mtime(name) self.clients[name] = (importlib.import_module('clients.' + name), mtime) self.client_options = self.clients.keys() self.dispatch('on_start') else: Logger.error('No valid firmware_id found. Quit now...')
def __init__(self): pygame.init() #self.screen_size = pygame.display.list_modes()[0] Application.__init__(self) #pygame.display.toggle_fullscreen() self.ships = ShipGroup(self.max_ships) self.xplos = ExplosionGroup() self.screen_bounds = bounds = self.screen.get_rect() dc_height = 40 self.dc_font = pygame.font.Font(None, 30) self.dc_bounds = Rect(0, bounds.height - dc_height, bounds.width, dc_height) self.game_bounds = Rect(0, 0, bounds.width, bounds.height - dc_height) spawn_area = self.game_bounds.inflate(-self.game_bounds.width / 4, -self.game_bounds.height / 4) self.spawners = [ TieSpawner(1000, self.ships, self.game_bounds, spawn_area), YWingSpawner(2000, self.ships, self.game_bounds) ] self.detonator = Detonator(self.game_bounds, self.xplos) for spawner in self.spawners: spawner.spawn() Ship.death_count = DeathCount() self.current_weapon = MiniExplosionsWeapon(self)
def main(): global app app = Application() if len(sys.argv) > 1: init_dota(sys.argv[1:], app) app.start()
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = ShipGroup(self.max_ships) self.spawners = [ TieSpawner(2000, self.ships, self.bounds), YWingSpawner(2000, self.ships, self.bounds) ]
def main(): app = Application(args=docopt(__doc__)) config = app.load_config(AethalometerConfiguration) app.run(decoder=AethalometerDecoder, data_handlers=(AethalometerDataStorer(config.store_dir, config.backup_dir),), connection_handlers=())
def main(): tornado.options.parse_command_line() app = Application() app.listen(options.port) print "start on port %s..."%options.port instance = tornado.ioloop.IOLoop.instance() tornado.autoreload.start(instance) instance.start()
def main(): app = Application(args=docopt(__doc__)) config = app.load_config(DataTakerConfiguration) app.run(decoder=DataTakerDecoder, data_handlers=(DataTakerDataStorer(config.store_dir, config.backup_dir),), connection_handlers=((DataTakerConnectionHandler(config.cmd_file)),))
def main(args=None): # create the application app = Application() r = pysol_init(app, args) if r != 0: return r # let's go - enter the mainloop app.mainloop()
def main(screen): try: app = Application(screen) app.run() return None, None except Exception as e: log.error("Unhandled Exception: {}".format(e)) log.error(traceback.format_exc()) return e, traceback.format_exc()
def main(): setup = Setup() config = setup.run() app = Application(config) app.run() teardown = Teardown() teardown.run()
def test_discipline_data_returns_dict_from_json(test_data_file): app = Application(".") expected = [ "string1", "string2", "string3", ] result = app.parse_disciplines() assert expected == result
def __init__(self): #initialize Application Application.__init__(self) self.bounds = self.screen.get_rect() #won't produce more than max_ships self.ships = ShipGroup(self.max_ships) #Sprite Group, makes sprite fxn (collision) easier self. spawners = [ TieSpawner(1000, self.ships, self.bounds), YWingSpawner(2000, self.ships, self.bounds)] self.xplos = ExplosionGroup()
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = ShipGroup(self.max_ships) self.xplos = ExplosionGroup() Explosion.group = self.xplos self.spawners = [ TieSpawner(1000, self.ships, self.bounds), YWingSpawner(2000, self.ships, self.bounds) ]
def main(): """ Main module that loads application with configurations and executes it's command line version """ configuration = {} app = Application(configuration) app.run_from_commandline()
def __init__(self, options): pygame.init() pygame.display.set_mode(settings.SCREEN_SIZE) pygame.display.set_caption(settings.CAPTION) self.nick = options["nick"] self.addr = options["addr"] self.port = options["port"] self.factory = NetworkControllerFactory(self) Application.__init__(self, ConnectingState)
def main(): # initialize pygame pygame.init() pygame.display.set_mode((800, 600)) # create game app = Application(Instruction) try: app.run() except KeyboardInterrupt: app.quit()
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = ShipGroup(self.max_ships) self.bullets = ShipGroup(self.max_ships) self.xplos = ExplosionGroup() self.score = 0 self.player = Player(400, 560, 20, 20, self.bounds, (255, 255, 255)) Explosion.group = self.xplos self.spawners = [TieSpawner(1000, self.ships, self.bounds), YWingSpawner(2000, self.ships, self.bounds)]
def run(args): app = Application(args) app.init_db(dummy=not args.without_dummy) application = lambda env, start_response: app(env, start_response) ip_addr = utils.get_local_ip_addr() print(f"\nStarting Python WSGI Server ...") print(f"addresss: http://localhost:{args.port}") print(f"local address: http://{ip_addr}:{args.port}/\n\n") server = simple_server.make_server('', args.port, application) server.serve_forever()
def __init__(self, device): self.bus = dbus.SystemBus() self.msg_manager = MessageManager(self.stop) self.device = device wlan_mac_addr = self.msg_manager.net_manager.get_wlan_hw_address() self.device_name = '{} ({})'.format(device, wlan_mac_addr[-8:]) Application.__init__(self, self.bus, self.device_name) self.msg_manager.start(self.vsp_svc.tx) self.init_ble_service() self.net_stat = NetStat(self.ConnectionStatsChanged) self.lte_stat = LTEStat(self.ConnectionStatsChanged)
def run_app(port): app = Application(name=setting.name, camera_port=port) while not app.stopped: app.process() app.debug() app.shutdown()
def __init__(self,name,interval=1000): super(SystemTrayIcon,self).__init__() self.fgColor = QColor( Application.settingsValue("fgColor", QColor("#33b0dc"))) self.bgColor = QColor( Application.settingsValue("bgColor", QColor("#144556"))) self.interval = Application.settingsValue( "%s/interval" % name, interval).toInt()[0] pix = QPixmap(22,22) p = QPainter(pix) p.fillRect(pix.rect(), Qt.black) p.end() self.setIcon(QIcon(pix)) self.startTimer( self.interval)
def test_acm_discrete(self): p = 7 q = 11 s = 9 a = 1 b = 1 n = 5 plainfile_begin = np.random.randint(0, 256, 58, 'B').tobytes() cipherimage = Application(p, q, s, a, b, n).encrypt(plainfile_begin) plainfile_end = Application(p, q, s, a, b, n).decrypt(cipherimage) self.assertEqual(plainfile_begin, plainfile_end)
def test_acm_general_any(self): p = 7 q = 11 s = 9 a = 2 b = 3 n = 2 plainfile_begin = np.random.randint(0, 256, 58, 'B').tobytes() cipherimage = Application(p, q, s, a, b, n).encrypt(plainfile_begin) plainfile_end = Application(p, q, s, a, b, n).decrypt(cipherimage) self.assertEqual(plainfile_begin, plainfile_end)
def main(): root = Tk() root.title("Stock Tracker") root.geometry("340x540") app = Application(root) root.mainloop()
def main(): tornado.options.parse_command_line() app = Application() http_server = tornado.httpserver.HTTPServer(app) http_server.bind(options.port) http_server.start(app.config.debug and 1 or -1) tornado.ioloop.IOLoop.instance().start()
async def make_app() -> Application: config = Config() data_client = DataServiceClient(base_url='', debug=True) feeds = await data_client.get_rss_sources() app = Application(refetch_interval=config.refetch_time, feeds=feeds, publisher=None) return app
def main(): usage = "usage: %prog [-c CRAPFILE] | [CRAPFILE]" parser = OptionParser(usage) (options, args) = parser.parse_args() if len(args) > 1: parser.error("incorrect number of arguments") app = Application() if len(args): file_load(app.design, args[0]) app.show_app() gtk.main() else: app.design.update() app.show_app() gtk.main()
def demo_main(): script_basename = "youpinitel-demo" cfg_home = "/etc" if os.getuid() == 0 else ".youpinitel" parser = argparse.ArgumentParser(description="Youpi + Minitel demonstration") parser.add_argument( "-m", "--minitel-port", help="device to which the Minitel is connected (default: %(default)s)", dest="minitel_port", default="/dev/ttyUSB0", ) parser.add_argument("-p", "--arm-port", help="device to which the arm interface is connected", dest="arm_port") parser.add_argument("-b", "--arm-busname", help="nROS bus name of the arm controller", dest="arm_busname") parser.add_argument( "-c", "--config-file", help="configuration file (default: %(default)s)", dest="config_file", type=file, default=os.path.join(cfg_home, "%s.json" % script_basename), ) parser.add_argument("-d", "--debug", help="activates debug trace", action="store_true") args = parser.parse_args() try: app = Application(log=logging.getLogger("app"), **args.__dict__) except Exception as e: if args.debug: logging.exception("unexpected error") logging.getLogger().fatal("unable to initialize application instance (%s)", e) else: try: app.run() except Exception as e: if args.debug: logging.exception("unexpected error") else: # logging.getLogger().fatal('unexpected error : (%s) %s', e.__class__.__name__, e) logging.getLogger().exception(e) else: logging.getLogger().info("application terminated")
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.shipGroup = Group() self.playerBulletGroup = Group() self.bulletGroup = Group() self.enemySpawners = [ ShipSpawner(5000, self.shipGroup, self.bounds), ShipSpawner(10000, self.shipGroup, self.bounds, LeetEnemy) ] self.enemySpawners[1].setOrigin(40,40) self.player = Player() self.playerGroup = pygame.sprite.GroupSingle(self.player) self.playerFired = 0,0
def __init__(self): Application.__init__(self) pygame.key.set_repeat(100,100) self.gameover = False self.kills = 0 self.ships = Group() self.bullets = Group() self.player_bullets = BulletGroup(10) self.spawners = [ BadGuySpawner(100, self.ships, self.bounds, self.bullets), FastGuySpawner(250, self.ships, self.bounds, self.bullets), MadGuySpawner(300, self.ships, self.bounds, self.bullets)] self.player = Player(self.screen_size[0]/2, self.screen_size[1]-25, 0, 0, self.bounds, self.player_bullets) self.killed_text = UpdateText("Killed: ", self.kills, (self.screen_size[0]-100, self.screen_size[1]-25), 30) self.lives_text = UpdateText("Lives: ", self.player.lives, (10, self.screen_size[1]-25), 30)
def main(): root = tkinter.Tk() root.title('人生如遊戲') # check does the window need fixed size if config['window']['fixed_size'] == 'yes': root.resizable(width=False, height=False) application = Application(root)
def __init__(self): Application.__init__(self) self.screenRect = self.screen.get_rect() self.minDt = 200 self.enemyGroup = Group() self.enemyGroup.add(BasicEnemy(100,100,0,1,self.screenRect,80)) self.bulletGroup = Group() self.player = Player(self.screenRect) self.playerGroup = GroupSingle(self.player) self.playerWeaponType = 1 self.playerFired = False self.playerMoveX = 0 self.playerMoveY = 0 self.playerMoveFlag = False
async def test_func1(): app = Application() func2_stub = MagicMock(return_value='future result!') func2_coro = asyncio.coroutine(func2_stub) async with patch.object(Application, 'func2', return_value=func2_coro) as mock: res = await app.func1() print(res)
def main(): app = Application(handlers=routes, default_host=options.host, debug=options.debug, **settings) server = HTTPServer(app) server.listen(options.port, address=options.host) gen_log.info('http://{host}:{port}/ Debug: {debug}'.format( host=options.host, port=options.port, debug=options.debug)) IOLoop.instance().start()
def main(): # initialize pygame pygame.init() screen = pygame.display.set_mode((600, 600)) app = Application(Game) try: app.run() except KeyboardInterrupt: app.quit() screen = pygame.display.set_mode((800, 800)) # create game game = Game(screen) try: game.run() except KeyboardInterrupt: game.quit()
def __init__(self, sound=1, server='', galaxy='', empire='', password='', shipBattle=None, glow=1): self.shutdownFlag = Event() props = WindowProperties() props.setTitle('%s (Game = %s)' % (windowtitle, galaxy)) base.win.requestProperties(props) Application.__init__(self, server=server, galaxy=galaxy, empire=empire, password=password, shipBattle=shipBattle, glow=glow) self.pandapath = Filename.fromOsSpecific(self.path).getFullpath() self.imagePath = self.pandapath + '/images/' self.soundPath = self.pandapath + '/sounds/' self.modelPath = self.pandapath + '/models/' self.sound = sound self.finalcard = None self.glowCamera = None self.glowOn = True if glow: self.setupGlowFilter() self.gameLoopInterval = Func(self.gameLoop) self.gameLoopInterval.loop() self.createSounds() self.playMusic()
def main(): # initialize pygame pygame.init() screen = pygame.display.set_mode((800, 800)) pygame.display.set_caption("Super Coin Get") app = Application(screen) app.set_state(GameState) # create game try: app.run() except KeyboardInterrupt: app.quit()
class URLShortenerTests(testing.AsyncHTTPTestCase): port = 9000 app = Application(db_port=27017, service_port=port) app.collection = app.db_client["URL_test_db"]["URL_collection"] def get_app(self): return self.app def test_obj_id_reconstruction(self): obj_id = ObjectId() short_url = encode_to_base62(obj_id) reconstructed_obj_id = decode_to_obj_id(short_url) self.assertEqual( obj_id, reconstructed_obj_id, "The object ID should be able to identically restored from the base 62 ID" ) def test_url_validation(self): self.assertEqual(validate_url("http://www.google.com"), True) self.assertEqual(validate_url("://www.google.com"), False) self.assertEqual(validate_url("_ssss.biz"), False) self.assertEqual( validate_url("http://FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"), True) self.assertEqual(validate_url("http://192.0.2.1"), True) self.assertEqual(validate_url("aaaaaaaaaaa"), False) self.assertEqual(validate_url("google.com"), False) self.assertEqual(validate_url("ftp://www.google.com"), True) @tornado.testing.gen_test def test_url_shortening_service(self): test_url = "https://httpbin.org/get" self.get_app().listen(self.port) original_response = yield tornado.httpclient.AsyncHTTPClient().fetch( test_url) short_url_response = yield tornado.httpclient.AsyncHTTPClient().fetch( "http://localhost:{}/shorten_url".format(self.port), method="POST", body=urllib.parse.urlencode({'url': test_url})) self.assertEqual(short_url_response.code, HTTPStatus.CREATED, "Insert new URL must succeed") short_url = json.loads(short_url_response.body)['shortened_url'] redirected_response = yield tornado.httpclient.AsyncHTTPClient().fetch( short_url, method="GET") self.assertEqual(redirected_response.code, HTTPStatus.OK, "Fetch long URL must succeed") self.assertEqual( original_response.body, redirected_response.body, "The shortened URL must redirect to the long URL's location")
def MainLoop(self): tornado.options.parse_command_line() # if options.debug == 'debug': # import pdb # pdb.set_trace() #引入相关的pdb模块进行断点调试 Log.Info('Init Server...') self.mainApp = Application(self.io_loop) self.http_server = tornado.httpserver.HTTPServer(self.mainApp, xheaders=True) self.http_server.listen(options.port) # 初始化异步数据库接口 Log.Info('Server Running in port %s...' % options.port) self.io_loop.start()
def main(): try: # Start server http_server = tornado.httpserver.HTTPServer(Application.instance(), xheaders=True) http_server.bind(options.port, address=options.addr) http_server.start() # Attach handlers to IOLoop ioloop = tornado.ioloop.IOLoop.instance() ioloop.start() except: tornado.options.print_help() raise
def main(): parse_command_line() mainApplication = Application() server_loop = tornado.ioloop.IOLoop.instance() http_server = tornado.httpserver.HTTPServer(mainApplication) http_server.listen(options.port) periodic_pull = tornado.ioloop.PeriodicCallback( mainApplication.periodic_run, settings.POLL_TIMEOUT, server_loop) periodic_pull.start() server_loop.start()
def main(): parser = argparse.ArgumentParser( description= "Limits: A program written in python that sets screen time limits") parser.add_argument("--window", action="store_true", help="Open the limits window on startup") args = parser.parse_args() if is_running(): open_window() sys.exit() root = tkinter.Tk() root.title("Limits") root.resizable(width=True, height=True) if not args.window: root.withdraw() app = Application(root) app.mainloop() sys.exit()
def main(): # initialize pygame pygame.init() pygame.display.set_mode((800, 800)) # create game app = Application(MainMenu) try: app.run() except KeyboardInterrupt: app.quit()
def main(): root = Tk() # Set the title of the Gui. root.title("Biomez Graphical User Interface") # Gives the dimensions for the program at startup. root.geometry("1000x1000") # Set the minimum size of the GUI. root.minsize(1000, 750) # Prevent resizing of the application. root.resizable(True, True) # Run the class app = Application() # Set the topbar icon for the GUI. topbarIcon = Image('photo', file='./sammy.ico') root.call('wm', 'iconphoto', root._w, topbarIcon) # Anything after this line below will execute after the GUI is exited. root.mainloop()
#!/usr/bin/env python # # vim:syntax=python:sw=4:ts=4:expandtab import guppy from app import Application from components import get_current_user from components.console import BetterConsole if __name__ == '__main__': # inject dependencies guppy.features.Provide('AppTitle', 'Inversion of Control ...\n\n... The Python Way') guppy.features.Provide('CurrentUser', get_current_user) guppy.features.Provide('Console', BetterConsole, prefix='-->') # <-- transient lifestyle # features.Provide('Console', BetterConsole(prefix='-->')) # <-- singleton lifestyle # use dependencies app = Application() app.print_yourself()
def quit(self): Application.quit(self) pygame.quit() reactor.stop()
def start(self): Application.start(self) reactor.run()
def run(args): try: app = Application(args.path) app.run() except IOError as e: print("error: failed to open file \"%s\"" % args.path)
h2 = rpinet.addHost( 'h2', machines.get('RPI_C03') ) c1 = rpinet.addController( 'c1', machines.get('RPI_C04') ) rpinet.addLink(h1, s1) rpinet.addLink(s1, s2) rpinet.addLink(s2, s3) rpinet.addLink(s3, s4) rpinet.addLink(h2, s4) cmd = ConfigUtility() cmd.read( sys.argv[1] ) c1.addService( cmd.get('REMOTE','NOHUP'), cmd.get('RYU') ) video_streaming = Application( cmd.get('VIDEO_STREAMING') ) video_streaming.setServer( h1, cmd.get('REMOTE','GENERAL') ) video_streaming.setClient( h2, cmd.get('REMOTE','PSEUDO_TERMINAL') ) monitoring = Application( cmd.get('MONITORING') ) monitoring.setServer( h1, cmd.get('REMOTE','GENERAL') ) monitoring.setClient( h2, cmd.get('REMOTE','GENERAL') ) monitoring.setLogNo( sys.argv[2] ) emu = SdnEmu(rpinet) emu.addStartQueue( monitoring ) #FIFO emu.addStartQueue( video_streaming ) emu.start() emu.callChecker( video_streaming ) emu.addStopQueue( monitoring ) #FIFO
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.ships = ShipGroup(self.max_ships) self.xplos = ExplosionGroup()
#!/usr/bin/env python # -*- encoding: UTF-8 -*- """ Propose: Describe application url Author: 'yac' Date: """ from app import Application from _session import Session session = Session() app_ = Application() session.expire_after = int(app_.conf['global']['session_expired_after']) log = app_.init_logger('APP') @app_.route('/host/<host_key>') def host_cotroller(host_key, **params): try: if host_key == 'modules': return {"result": {"local_host": True, "net_policy_server": True}, "success": True} return {'host': 'ok', 'host_key': session.session} except StandardError: log.exception('Error in host_cotroller') return {'success': False, 'errorMessage': 'server_error'}
def main(): port = int(os.environ.get("PORT", 5000)) app = Application() app.listen(port) tornado.ioloop.IOLoop.instance().start()
def __init__(self): Application.__init__(self) self.bounds = self.screen.get_rect() self.player = Player(380, 740, 6, 6, self.bounds)