Ejemplo n.º 1
0
 def setUp(self):
     os.environ['LOG_CFG'] = r'D:\Sync\OneDrive\Yu-gi-oh_bot\config.ini'
     dlRuntime = DuelLinkRunTime(
         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), None, False)
     self.provider = Nox(None,
                         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'),
                         dlRuntime)
     self.provider.sleep_factor = 0.0
     loop = asyncio.get_event_loop()
     loop.set_default_executor(ThreadPoolExecutor(2))
Ejemplo n.º 2
0
 def setUp(self):
     os.environ['LOG_CFG'] = r'D:\Sync\OneDrive\Yu-gi-oh_bot\config.ini'
     scheduler = BackgroundScheduler()
     dlRuntime = DuelLinkRunTime(default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), scheduler, False)
     self.provider = Steam(scheduler, default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), dlRuntime, False)
     self.provider.sleep_factor = 0.0
     self.loop = asyncio.get_event_loop()
     self.loop.set_default_executor(ThreadPoolExecutor(2))
     dlRuntime._loop = self.loop
     self.provider.is_process_running()
Ejemplo n.º 3
0
def bot(start, config_file):
    if start:

        def handler(signum, frame):
            if signum == signal.SIGINT:
                dlRuntime.shutdown()
                scheduler.shutdown()
                logger.info("Exiting")
                sys.exit(0)

        signal.signal(signal.SIGINT, handler)
        uconfig = default_config()
        uconfig.read(config_file)
        scheduler = BackgroundScheduler()
        dlRuntime = DuelLinkRunTime(uconfig, scheduler)
        scheduler.start()
        try:
            dlRuntime.set_provider(
                get_provider(uconfig.get('bot',
                                         'provider'))(scheduler, uconfig,
                                                      dlRuntime))
        except Exception as e:
            logger.fatal(
                "Could not get a provider, take a look at your config file")
            logger.fatal(e)
            sys.exit(0)
        dlRuntime.main()

        while True:
            try:
                time.sleep(5)
                if dlRuntime._shutdown:
                    return
            except InterruptedError:
                pass
Ejemplo n.º 4
0
def gui(start, config_file):
    if start:
        import sys
        from PyQt5.QtWidgets import QSystemTrayIcon
        from PyQt5.QtWidgets import QMessageBox
        from PyQt5.QtWidgets import QApplication
        from bot.utils.common import make_config_file, default_config
        from bot.duel_links_runtime import DuelLinkRunTime
        from bot.dl_gui import DuelLinksGui
        sip.setdestroyonexit(False)
        app = QApplication(sys.argv)

        if not QSystemTrayIcon.isSystemTrayAvailable():
            QMessageBox.critical(None, "Systray",
                                 "Systray not dected on system.")
            sys.exit(1)

        QApplication.setQuitOnLastWindowClosed(False)

        uconfig = default_config()
        uconfig.read(config_file)
        dlRuntime = setup_runtime(uconfig)
        dlRuntime.main()
        window = DuelLinksGui(dlRuntime, uconfig.get('locations', 'assets'))
        window.show()
        sys.exit(app.exec_())
Ejemplo n.º 5
0
 def setUp(self):
     os.environ['LOG_CFG'] = r'D:\Sync\OneDrive\Yu-gi-oh_bot\config.ini'
     dlRuntime = DuelLinkRunTime(
         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), None, False)
     dlRuntime._disable_dump = True
     self.provider = Nox(None,
                         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'),
                         dlRuntime)
     self.provider.sleep_factor = 0.0
     loop = asyncio.get_event_loop()
     loop.set_default_executor(ThreadPoolExecutor(2))
     self.battler = VagabondBattle(self.provider)
     dlRuntime = DuelLinkRunTime(
         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), None, False)
     self.provider_steam = Steam(
         None, default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'), dlRuntime,
         False)
     self.provider_steam.sleep_factor = 0.0
     self.battler_steam = VagabondBattle(self.provider_steam)
     self.battler_npc_steam = NPCBattle(self.provider_steam)
Ejemplo n.º 6
0
def gui(start, config_file):
    if start:
        import sys
        from PyQt5.QtWidgets import QSystemTrayIcon
        from PyQt5.QtWidgets import QMessageBox
        from PyQt5.QtWidgets import QApplication
        from bot.utils.common import make_config_file, default_config
        from bot.duel_links_runtime import DuelLinkRunTime
        from bot.dl_gui import DuelLinksGui
        from bot import logger
        sip.setdestroyonexit(False)
        app = QApplication(sys.argv)

        if not QSystemTrayIcon.isSystemTrayAvailable():
            QMessageBox.critical(None, "Systray",
                                 "Systray not dected on system.")
            sys.exit(1)

        QApplication.setQuitOnLastWindowClosed(False)

        uconfig = default_config()
        uconfig.read(config_file)
        dlRuntime = setup_runtime(uconfig)
        dlRuntime.main()
        window = DuelLinksGui(dlRuntime, uconfig.get('locations', 'assets'))
        window.show()

        def handler(signum, frame):
            if signum == signal.SIGINT:
                window.__quit__()
                logger.info("Exiting Yugioh-DuelLinks Bots")

        signal.signal(signal.SIGINT, handler)

        def inmain():
            return app.exec_()

        sys.exit(inmain())
Ejemplo n.º 7
0
def bot(start, config_file):
    if start:
        from bot import logger
        def handler(signum, frame):
            if signum == signal.SIGINT:
                dlRuntime.shutdown()
                logger.info("Exiting Yugioh-DuelLinks Bots")
                sys.exit(0)

        from bot.utils.common import make_config_file, default_config
        signal.signal(signal.SIGINT, handler)
        uconfig = default_config()
        uconfig.read(config_file)
        dlRuntime = setup_runtime(uconfig)
        dlRuntime.main()

        while True:
            try:
                time.sleep(5)
                if dlRuntime._shutdown:
                    return
            except InterruptedError:
                pass
Ejemplo n.º 8
0
 def test_provider(self):
     with self.assertRaises(AssertionError) as context:
         provider = Nox(None, default_config(r'D:\Sync\OneDrive\Fake'),
                        None)
     self.assertTrue('Missing File' in str(context.exception))
Ejemplo n.º 9
0
 def setUp(self):
     os.environ['LOG_CFG'] = r'D:\Sync\OneDrive\Yu-gi-oh_bot\config.ini'
     self.provider = Nox(None,
                         default_config(r'D:\Sync\OneDrive\Yu-gi-oh_bot'),
                         None)