Exemplo n.º 1
0
def main():
    if len(argv) != 2:
        print("Invalid arguments.")
        exit(1)
    elif argv[1] == "publish":
        pub = Publisher()
        pub.start()
    elif argv[1] == "listen":
        lis = Listener()
        lis.start()
    else:
        print("Invalid argument.")
def nrdf_feed():
    # Create logger instance
    logger = Logger()
    logrep = logger.myLogger()

    # Load Config from file
    _config_location = r'config.json'
    with open(_config_location, 'r') as f:
        _config = json.load(f)
    logrep.info('Successfully loaded config file : %s' % _config_location)

    # Load Selected Mongo Environment
    if _config['mongo-type'] == "test":
        mongoConfig = _config['mongo-test']
    else:
        mongoConfig = _config['mongo-live']

    # Network Rail Rules state security token must be present
    logrep.info('Process Name : {}'.format(_config['process-id']))
    logrep.info('Network Rail Security Token : {}'.format(
        _config['security-token']))

    # Create Mongo Connection
    mongodb = MongoClient(mongoConfig['connection-string'],
                          username=mongoConfig['username'],
                          password=mongoConfig['password'],
                          authSource='admin',
                          authMechanism='SCRAM-SHA-256')

    db = mongodb[mongoConfig['db-name']]
    logrep.info('MongoDB Connection Established [%s:%s]' %
                (mongoConfig['connection-string'], mongoConfig['db-name']))

    # Full Installation Process - Potentially needs some tweaking
    if (_config['installation']['full'] == True):
        logrep.info('Installation = True | Starting Installation Procedure')
        ins = Installation(db, logrep, _config)
        ins.importCORPUS()
        ins.importSMART()
        ins.importReference(_config['installation']['geography'])
        ins.downloadFullSchedule()
        ins.importFullSchedule()

    # Create Stomp Logic
    mq = stomp.Connection(host_and_ports=[
        (_config['stomp-connection']['host-url'],
         _config['stomp-connection']['host-port'])
    ],
                          keepalive=True,
                          vhost=_config['stomp-connection']['host-url'],
                          heartbeats=(20000, 10000))

    # Create Listener Object
    mq.set_listener('', Listener(mq, logrep, db, _config))

    wait = input('')
    mq.disconnect()

    while mq.is_connected():
        sleep(1)
Exemplo n.º 3
0
    def runLevel(self):
        #start level
        self.isLevelRunning = True
        startTime = time.time() #begin timer

        #create listener
        listen2Me = Listener('user_output.txt', self.levelToRun.getValidShortcutsList())
        listen2Me.start() #start listening user input and stop when shortcuts are done
        self.isLevelRunning = False

        #end level and record time,  user input, and actions
        endTime = time.time() #end timer
        self.elapsedTime = endTime - startTime #record elapsed time

        self.userInput = listen2Me.getCompletedShortcuts()
        self.userActions = len(listen2Me.completedShortcuts) #listener needs to be changed to count all actions
Exemplo n.º 4
0
Arquivo: ned.py Projeto: breyerjs/ned
                ned_response = COMMANDS
            else:
                ned_response = DEFAULT_RESPONSE
            responses.append(ned_response)
        # Any karmatic changes that have happened
        if commands.karmatic_entities:
            karma_response = Karma().process_commands(
                commands.karmatic_entities)
            responses.append(karma_response)
        return responses
    except Exception as e:
        print(e)
        response = 'Great Scott! I seem to have encountered an error :('
        return [response]


if __name__ == "__main__":
    if slack_client.rtm_connect(with_team_state=False, auto_reconnect=True):
        print("Ned is connected and running!")
        slack_listener = Listener(slack_client)
        while True:
            commands = slack_listener.listen(slack_client.rtm_read())
            if commands and commands.work_to_do:
                responses = _get_responses(commands)
                for response in responses:
                    send_response(slack_client, commands.event['channel'],
                                  response)
            time.sleep(RTM_READ_DELAY)
    else:
        print("Ruh roh! Connection failed. Exception traceback printed above.")
from airflow import DAG
from airflow.operators import PythonOperator, ShortCircuitOperator,\
    EmailOperator
from airflow.utils.trigger_rule import TriggerRule

from datetime import datetime

from listener.listener import Listener
from listener.email import EmailService

listener = Listener()
email_service = EmailService()

default_args = {
    'owner': 'M & E',
    'depends_on_past': False,
    'start_date': datetime(2020, 1, 1),
    'email': ['*****@*****.**'],
    'email_on_failure': True,
    'email_on_retry': True,
    'retries': 0,
}

with DAG(
        'PriceAlerter',
        default_args=default_args,
        schedule_interval='*/5 9-17 * * *',
        catchup=False,
) as dag:
    price_listener = PythonOperator(
        task_id='listener',
Exemplo n.º 6
0
init(autoreset=True)

parser = argparse.ArgumentParser(description='An interactive bot to talk about stars and planets')
parser.add_argument('--dep_tree', default=False, type=bool, help='print dependencies tree of every heard sentence (default: False)')
parser.add_argument("--kb_file", help="file containing the knowledge-base (dafault: the last updated file in the kb directory)")

args = parser.parse_args()

# TO BUILD THE DEPENDENCIES TREE
if args.dep_tree:
    stanfordnlp.download('en')   # This downloads the English models for the neural pipeline
    print('Building pipeline...')
    nlp = stanfordnlp.Pipeline() # This sets up a default neural pipeline in English

listener = Listener()
speaker = Speaker()

bot_name = "\t\t\t\t\tAstroBot"
colorAstro = colored(bot_name +':', 'yellow')
agent = Agent(speaker, listener, colorAstro, args.kb_file)
print(f"{colorAstro} Hi, how can I help you?")
speaker.speak("Hi, how can I help you?")
while True:
    command = listener.listen()
    command = command.strip()

    if command == "exit":
        print(f"{colorAstro} Bye bye")
        speaker.speak("Bye bye")
        break