Exemplo n.º 1
0
def run(args):
    from tyggbot.tbutil import load_config
    config = load_config(args.config)

    if 'main' not in config:
        log.error('Missing section [main] in config')
        sys.exit(1)

    if 'sql' in config:
        log.error('The [sql] section in config is no longer used. See config.example.ini for the new format under [main].')
        sys.exit(1)

    if 'db' not in config['main']:
        log.error('Missing required db config in the [main] section.')
        sys.exit(1)

    tyggbot = TyggBot(config, args)

    tyggbot.connect()

    def on_sigterm(signal, frame):
        tyggbot.quit()
        sys.exit(0)

    signal.signal(signal.SIGTERM, on_sigterm)

    try:
        tyggbot.start()
    except KeyboardInterrupt:
        tyggbot.quit()
        pass
Exemplo n.º 2
0
def run(args):
    from tyggbot.tbutil import load_config
    config = load_config(args.config)

    if 'main' not in config:
        log.error('Missing section [main] in config')
        sys.exit(1)

    if 'sql' in config:
        log.error(
            'The [sql] section in config is no longer used. See config.example.ini for the new format under [main].'
        )
        sys.exit(1)

    if 'db' not in config['main']:
        log.error('Missing required db config in the [main] section.')
        sys.exit(1)

    tyggbot = TyggBot(config, args)

    tyggbot.connect()

    def on_sigterm(signal, frame):
        tyggbot.quit()
        sys.exit(0)

    signal.signal(signal.SIGTERM, on_sigterm)

    try:
        tyggbot.start()
    except KeyboardInterrupt:
        tyggbot.quit()
        pass
Exemplo n.º 3
0
    def setUp(self):
        from tyggbot.tyggbot import TyggBot
        from tyggbot.models.user import User, UserManager
        from tyggbot.tbutil import load_config
        import datetime

        config = load_config('config.ini')
        args = TyggBot.parse_args()
        self.tyggbot = TyggBot(config, args)
        self.source = self.tyggbot.users['testuser123Kappa']
        self.source.username_raw = 'PajladA'
        self.source.points = 142
        self.source.last_seen = datetime.datetime.strptime('17:01:42', '%H:%M:%S')
Exemplo n.º 4
0
    def setUp(self):
        from tyggbot.tyggbot import TyggBot
        from tyggbot.models.user import User, UserManager
        from tyggbot.tbutil import load_config
        import datetime

        config = load_config('config.ini')
        args = TyggBot.parse_args()
        self.tyggbot = TyggBot(config, args)
        self.source = self.tyggbot.users['testuser123Kappa']
        self.source.username_raw = 'PajladA'
        self.source.points = 142
        self.source.last_seen = datetime.datetime.strptime(
            '17:01:42', '%H:%M:%S')
Exemplo n.º 5
0
app._static_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
app.register_blueprint(api.page)

config = configparser.ConfigParser()

parser = argparse.ArgumentParser(description='start the web app')
parser.add_argument('--config', default='config.ini')
parser.add_argument('--host', default='0.0.0.0')
parser.add_argument('--port', type=int, default=2325)
parser.add_argument('--debug', dest='debug', action='store_true')
parser.add_argument('--no-debug', dest='debug', action='store_false')
parser.set_defaults(debug=False)

args = parser.parse_args()

config = load_config(args.config)

DBManager.init(config['main']['db'])

session = DBManager.create_session()
num_decks = session.query(func.count(Deck.id)).scalar()
custom_web_content = {}
for web_content in session.query(WebContent).filter(WebContent.content is not None):
    custom_web_content[web_content.page] = web_content.content
session.close()

has_decks = num_decks > 0

errors.init(app)

modules = config['web'].get('modules', '').split()
Exemplo n.º 6
0
app.register_blueprint(api.page)
app.register_blueprint(admin.page)

config = configparser.ConfigParser()

parser = argparse.ArgumentParser(description='start the web app')
parser.add_argument('--config', default='config.ini')
parser.add_argument('--host', default='0.0.0.0')
parser.add_argument('--port', type=int, default=2325)
parser.add_argument('--debug', dest='debug', action='store_true')
parser.add_argument('--no-debug', dest='debug', action='store_false')
parser.set_defaults(debug=False)

args = parser.parse_args()

config = load_config(args.config)

if 'web' not in config:
    log.error('Missing [web] section in config.ini')
    sys.exit(1)

if 'pleblist_password_salt' not in config['web']:
    salt = generate_random_salt()
    config.set('web', 'pleblist_password_salt', salt.decode('utf-8'))

if 'secret_key' not in config['web']:
    salt = generate_random_salt()
    config.set('web', 'secret_key', salt.decode('utf-8'))

if 'logo' not in config['web']:
    twitchapi = TwitchAPI()