def test_import_and_render(self): importer = memory_importer.MemoryImporter() mem = importer.read_ram('testdata/full-image.mem') self.args.output = self.args.tmpfile('full-image.png') a = app.Application() a.create_output(mem, self.args, 'horizontal', None) self.assert_equal_image(self.args.output, 'testdata/full-image.png')
def test1(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label(root, text="Test1 - Trying to place ship incorrectly", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.add_ship(bs.Ship(0, 0, bs.Direction.SOUTH, 4)) root.update() time.sleep(1) self.assertFalse(app.add_ship(bs.Ship(1, 0, bs.Direction.EAST, 3))) root.update() time.sleep(1) root.destroy() root.mainloop()
def test2(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label( root, text="Test2 - Place all ships correctly and start Play", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(2) root.destroy() root.mainloop()
def app(): debugon() import app a = app.Application(sys.argv) a.loadTranslations() return a
def __init__(self, exception_handler=exception_to_json_view): ## An app.Application instance. self.app = app.Application() ## Function to convert exceptions to a view.View instance. self.__exception_handler = exception_handler ## A logger. self.log = None
def start_server(conf, logger=None): tornado.options.parse_command_line() http_server = tornado.httpserver.HTTPServer(app.Application(conf)) http_server.listen(port=conf['port'], address=conf['ip']) logger.info('Development server is running at http://%s:%s/.' % (conf['ip'], conf['port'])) logger.info('Quit the server with CONTROL-C.') tornado.ioloop.IOLoop.instance().start()
def main(): config = utils.config.Config('config.json', default=default.config.DEFAULT) client = api.vk.Client(config.get('VK_API_TOKEN'), debug=config.get('DEBUG_MODE')) application = app.Application(config=config, client=client) while application.running: time.sleep(1)
def test_output(self): img = Image.open('testdata/full-image.png') self.process_image(img) a = app.Application() a.create_output(self.ppu_memory, self.args, 'horizontal', None) actual_file = self.args.compile expect_file = 'testdata/full-image-rom.nes' self.assert_file_eq(actual_file, expect_file)
def test91(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label( root, text="Test11 - Lose, then reset without quitting the game", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) for x in range(9): for y in range(9): if app._Application__game.player_board.gameover(): break if app._Application__game.ai_board.board[x][y] not in [ "1", "2", "3", "0" ]: app.shoot(x, y) root.update() time.sleep(1) app.reset_action_ingame() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) app.shoot(4, 4) root.update() time.sleep(1) root.destroy() root.mainloop()
def test_import_by_kind(self): importer = memory_importer.MemoryImporter() mem = importer.read('testdata/full-image.mem', 'ram') a = app.Application() a.create_output(mem, self.args, 'horizontal', None) self.assert_output_result('chr') self.assert_output_result('nametable') self.assert_output_result('palette') self.assert_output_result('attribute')
def test_output_square_small_with_locked_tiles(self): img = Image.open('testdata/full-image-small-square.png') self.args.is_locked_tiles = True self.process_image(img) a = app.Application() a.create_output(self.ppu_memory, self.args, 'horizontal', None) actual_file = self.args.compile expect_file = 'testdata/full-image-rom-small-square-locked-tiles.nes' self.assert_file_eq(actual_file, expect_file)
def test_output_from_memory_dump(self): """Memory can be imported then split into components.""" memfile = 'testdata/full-image-mem.bin' a = app.Application() a.read_memory(memfile, 'ram', self.args) self.assert_output_result('chr') self.assert_output_result('palette') self.assert_output_result('nametable') self.assert_output_result('attribute') self.assert_output_result('nametable1') self.assert_output_result('attribute1')
def test9(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label(root, text="Test9 - Trying to shot same fields after reset", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) for i in range(0, 9, 2): app.shoot(i, i) root.update() time.sleep(1) app.reset_action_ingame() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) for i in range(0, 9, 2): app.shoot(i, i) root.update() time.sleep(1) root.destroy() root.mainloop()
def test_views(self): """Create views of the input.""" img = Image.open('testdata/full-image.png') self.process_image(img) a = app.Application() a.create_views(self.ppu_memory, self.args, img) self.assert_file_eq(self.args.palette_view, self.golden('pal', 'png')) self.assert_file_eq(self.args.colorization_view, self.golden('color', 'png')) self.assert_file_eq(self.args.reuse_view, self.golden('reuse', 'png')) self.assert_file_eq(self.args.nametable_view, self.golden('nt', 'png')) self.assert_file_eq(self.args.chr_view, self.golden('chr', 'png')) self.assert_file_eq(self.args.grid_view, self.golden('grid', 'png'))
def run(self): # pragma: no cover self.server.start_slave( controller.Slave, controller.Channel(self.masterq, self.should_exit)) iol = tornado.ioloop.IOLoop.instance() http_server = tornado.httpserver.HTTPServer( app.Application(self.options.wdebug)) http_server.listen(self.options.wport) tornado.ioloop.PeriodicCallback(self.tick, 5).start() try: iol.start() except (Stop, KeyboardInterrupt): self.shutdown()
def main(): """ @return int """ import os, sys # Use UTF-8 encoding for Qt from PySide.QtCore import QTextCodec #sys_codec = QTextCodec.codecForLocale() u8codec = QTextCodec.codecForName("UTF-8") QTextCodec.setCodecForCStrings(u8codec) QTextCodec.setCodecForTr(u8codec) import config from sakurakit import skdebug #skdebug.DEBUG = config.APP_DEBUG or '--debug' in sys.argv skdebug.DEBUG = '--debug' in sys.argv print >> sys.stderr, "reader: debug = %s" % skdebug.DEBUG from sakurakit.skdebug import dprint, dwarn dprint("enter") if '--help' in sys.argv: print_help() dprint("exit: help") #sys.exit(os.EX_USAGE) return 0 dprint("create app") import app a = app.Application(sys.argv) #dprint("set max thread count") #from PySide.QtCore import QThreadPool #if QThreadPool.globalInstance().maxThreadCount() < config.QT_THREAD_COUNT: # QThreadPool.globalInstance().setMaxThreadCount(config.QT_THREAD_COUNT) dprint("create main object") import main m = main.MainObject(a) #m.run(a.arguments()) # arguments differs on different system m.run(a.arguments()) dprint("exec") returnCode = a.exec_() #skos.kill_my_process() return returnCode
def main(config_file): """Main""" try: settings = quickfix.SessionSettings(config_file) application = app.Application() storefactory = quickfix.FileStoreFactory(settings) logfactory = None #quickfix.FileLogFactory(settings) initiator = quickfix.SocketInitiator(application, storefactory, settings, logfactory) initiator.start() application.run() initiator.stop() except (quickfix.ConfigError, quickfix.RuntimeError) as e: print(e) #initiator.stop() sys.exit()
def test7(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label(root, text="Test7 - Trying to shot same ship field twice", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) while 1: x = random.randint(0, 9) y = random.randint(0, 9) if app._Application__game.ai_board.board[x][y] == "1": app.shoot(x, y) root.update() time.sleep(1) app.shoot(x, y) root.update() time.sleep(1) break root.destroy() root.mainloop()
def test5(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label(root, text="Test5 - Trying to place ship on player board", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.random_board() root.update() time.sleep(1) app.play() root.update() time.sleep(1) while 1: x = random.randint(0, 9) y = random.randint(0, 9) if app._Application__game.player_board.board[x][y] == "1": app.add_ship( bs.Ship(x, y, bs.Direction.SOUTH, 1) ) # I execute add_ship command, because on player board there is still that command during the game root.update() time.sleep(1) break root.destroy() root.mainloop()
def test8(self): root = tk.Tk() canvas = tk.Canvas(root, width=1300, height=700) app = ap.Application(root, canvas) text = tk.Label(root, text="Test8 - Place some ships and reset board", fg="red", width=42, bg='black', font='WarHeliosCondCBold 25 bold') canvas.create_window(470, 710, anchor='nw', window=text) root.update() time.sleep(1) app.start_action() root.update() time.sleep(1) app.add_ship(bs.Ship(0, 0, bs.Direction.SOUTH, 4)) root.update() time.sleep(1) app.add_ship(bs.Ship(5, 0, bs.Direction.EAST, 3)) root.update() time.sleep(1) app.add_ship(bs.Ship(5, 5, bs.Direction.EAST, 3)) root.update() time.sleep(1) app.reset_action() root.update() time.sleep(1) root.destroy() root.mainloop()
def main(): """ Main function """ db = tables.db db.close() # - if not closed properly on precedent use if "install" in sys.argv: raw_data = install.Data() db.create_tables([ tables.Products, tables.Categories, tables.Stores, tables.Categorized, tables.Buyable, tables.Substitutes ]) clean_data = install.Cleaner(raw_data.data) save = install.Saver(clean_data.cleaned_data) save.associate(clean_data.cleaned_data) db.close() db.connect() appli = app.Application() appli.start() db.close()
def get_app(self): return app.Application()
print(error) def send_captcha(browser, code): """ envoi de la solution dans la page Chrome """ try: txt_box_url = '/html/body/center/table/tbody/tr/td/table/tbody/tr/td/form[2]/table/tbody/tr[2]/td[2]/input[1]' captcha_textbox = browser.find_element_by_xpath(txt_box_url) captcha_textbox.send_keys(code) valid_but_url = '/html/body/center/table/tbody/tr/td/table/tbody/tr/td/form[2]/table/tbody/tr[2]/td[2]/input[7]' validate_button = browser.find_element_by_xpath(valid_but_url) validate_button.click() except Exception as error: print(error) def check_enrollment(browser): condition_url = '/html/body/center/table/tbody/tr/td/center[1]' condition = browser.find_element_by_xpath(condition_url) if condition.text == 'You have successfully enrolled.': print("Enrolled Successfully : ", datetime.now().strftime('%Y-%m-%d %H:%M:%S')) return True else: print("Enrollment failed - wrong code : ", datetime.now().strftime('%Y-%m-%d %H:%M:%S')) return False if __name__ == '__main__': App = app.Application()
def get_app(self): return app.Application(database_name='test', xsrf_cookies=False, optimize_static_content=False, embed_static_url=False)
def run(): application = app.Application() """
def get_app(self): return app.Application(database_name='test')
def main(): # Use UTF-8 encoding for Qt from PySide.QtCore import QTextCodec #sys_codec = QTextCodec.codecForLocale() u8codec = QTextCodec.codecForName("UTF-8") QTextCodec.setCodecForCStrings(u8codec) QTextCodec.setCodecForTr(u8codec) import config from sakurakit import skdebug #skdebug.DEBUG = config.APP_DEBUG or '--debug' in sys.argv skdebug.DEBUG = '--debug' in sys.argv print "installer: debug = %s" % skdebug.DEBUG from sakurakit.skdebug import dprint, dwarn dprint("enter") if '--help' in sys.argv: print_help() dprint("leave: help") return # Singleton #dprint("check single instance") #from sakurakit import skipc #inst = skipc.SingleInstance() #single_app = inst.passed #if not single_app: # dprint("multiple instances are running") # sys.exit(-1) dprint("python = %s" % sys.executable) #dprint("rootdir = %s" % rootdir) #dprint("mecabrc = %s" % mecabrc_path) dprint("create app") import app a = app.Application(sys.argv) dprint("load translations") a.loadTranslations() # Take the ownership of sakurakit translation from sakurakit import sktr sktr.manager().setParent(a) dprint("load settings") import settings ss = settings.global_() ss.setParent(a) dprint("update settings") if ss.version() != config.VERSION_TIMESTAMP: dprint("app update detected, migrate settings") ss.setVersion(config.VERSION_TIMESTAMP) ss.sync() dprint("set max thread count") from PySide.QtCore import QThreadPool if QThreadPool.globalInstance().maxThreadCount() < config.QT_THREAD_COUNT: QThreadPool.globalInstance().setMaxThreadCount(config.QT_THREAD_COUNT) dprint("create main object") import main m = main.MainObject() m.run(a.arguments()) #import netman #netman.manager().queryComments(gameId=183) #import hashman #print hashman.md5sum('/Users/jichi/tmp/t.cpp') dprint("exec") sys.exit(a.exec_())
def main(): application = app.Application() http_server = tornado.httpserver.HTTPServer(application) http_server.listen(config.options["port"]) tornado.ioloop.IOLoop.current().start()
def test_handler(): assert app.Application()
import sys from pyojo.tools.shell import init_app_shell import app init_app_shell() sys.exit(app.Application(sys.argv).run())