Esempio n. 1
0
def main():
    logs.setup_logging()
    if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
        try:
            commands.script(configuration=configuration.CURRENT_CONFIGURATION,
                            script_path=sys.argv[1],
                            script_args=sys.argv[2:])
        except argh.CommandError as e:
            sys.exit('error: {0}'.format(e))
    else:
        parser = argh.ArghParser()
        subparsers_action = argh.utils.get_subparsers(parser, create=True)
        subparsers_action.metavar = ''
        if settings.settings_path.exists():
            try:
                commands.add_script_based_commands()
            except argh.CommandError as e:
                sys.exit('error: {0}'.format(e))
        parser.add_commands(commands.app.commands)
        errors = StringIO()
        parser.dispatch(errors_file=errors)
        errors_value = errors.getvalue()
        if errors_value:
            errors_value = errors_value.replace('CommandError',
                                                'error').strip()
            sys.exit(errors_value)
Esempio n. 2
0
File: main.py Progetto: AviaE/claw
def main():
    logs.setup_logging()
    if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
        try:
            commands.script(configuration=configuration.CURRENT_CONFIGURATION,
                            script_path=sys.argv[1],
                            script_args=sys.argv[2:])
        except argh.CommandError as e:
            sys.exit('error: {0}'.format(e))
    else:
        parser = argh.ArghParser()
        subparsers_action = argh.utils.get_subparsers(parser, create=True)
        subparsers_action.metavar = ''
        if settings.settings_path.exists():
            try:
                commands.add_script_based_commands()
            except argh.CommandError as e:
                sys.exit('error: {0}'.format(e))
        parser.add_commands(commands.app.commands)
        errors = StringIO()
        parser.dispatch(errors_file=errors)
        errors_value = errors.getvalue()
        if errors_value:
            errors_value = errors_value.replace('CommandError',
                                                'error').strip()
            sys.exit(errors_value)
Esempio n. 3
0
def init_app(env, **kwargs):
    try:
      setup_logging('INFO')
      if env == '':
         raise TypeError('Supplied Env value is empty') # (Checks, if we are passing the env value as empty and raises exception)
      logger.info('Starting APP in {} mode'.format(env))
      return create_app()
    except ValueError as e:
      logger.error('Gunicorn server failed to start due to ValueError.{}'.format(e))
    except Exception as e:
      logger.error('Gunicorn server failed to start. {}'.format(e))
Esempio n. 4
0
async def main() -> None:
    loop = asyncio.get_running_loop()
    setup_logging()
    app = await make_app()

    logger.info('Running app...Refetch interval interval: %s.',
                app.refetch_interval)
    for signum in (signal.SIGTERM, signal.SIGINT):
        loop.add_signal_handler(signum,
                                lambda: asyncio.ensure_future(shutdown(app)))
    await app.start()
Esempio n. 5
0
 def load(self):
     try:
         setup_logging('INFO')
         logger.info('Starting APP in PROD mode')
         return create_app()  #self.application
     except Exception as e:
         logger.error('Falcon APP not loaded.{}'.format(e))
         raise falcon.HTTPError(
             status="503 APP Unavailable",
             title='Atlantis APP',
             description='Atlantis falcon APP failed to start',
             code=503)
Esempio n. 6
0
def run(conf_file):
    setup_logging('logs')
    conf = get_config(conf_file)
    mb = Motherboard()
    mb.start()
    try:
        b = phone.Battery(vrpi=mb.v_rpi_3v3)
        b.bsi = 82e3
        b.btemp = 50e3
        with phone_context(phone.Phone, conf['phone']['pin']) as p:
            while not p.registered:
                time.sleep(0.5)
            logger.info(p)
            logger.info(mb)
            msg = finnish_alarm(conf['alarm']['name'], mb.startup_reason, mb.v_batt, mb.temperature)
            p.send_sms(conf['phone']['number'], msg)
    finally:
        mb.request_shutdown(10)
        mb.stop()
import os
import sys
import csv
import argparse

import pandas as pd
from termcolor import colored

from logs import setup_logging
import db

setup_logging()

INSTITUTIONS = ['amex', 'halifax', 'firstdirect']

CATEGORIES_KEYMAP = {
    'q': 'Groceries',
    'w': 'Rent',
    'e': 'Bills',
    'a': 'Travel',
    's': 'Material Items',
    'd': 'Entertainment',
    'z': 'Savings',
    'x': 'Eating Out/Drinks',
    'g': 'Clothing',
    'v': 'Earnings',
    't': 'Transfers',
    'f': 'Cash Withdrawal',
    'c': 'Miscellaneous',
    'r': 'Not Applicable'
}
Esempio n. 8
0
import signal as signals

import messages
from config import config
from curio import SignalQueue, TaskGroup, run, spawn, tcp_server  # Queue, CancelledError
from feeds import ClientStreamFeed
from logs import setup_logging
from tasks import ControlTask, HeartbeatTask, StatusTask

logger = setup_logging(__name__)

# TODO: convert all this into a class that is configurable
# Make the messaging layer agnostic?
#

feed = ClientStreamFeed()
out_feed = ClientStreamFeed()


async def connection_handler(client, addr):
    logger.info('connection from %s', addr)
    async with client:
        client_stream = client.as_stream()
        async with TaskGroup(wait=any) as workers:
            # connect client stream to main feed
            await workers.spawn(out_feed.outgoing, client_stream)
            await workers.spawn(feed.incoming, client_stream)
            # TODO: incoming feed message parsing

        # May not need this
        await feed.publish(messages.EXIT)