diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-02-07 02:01:19 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-02-07 02:01:19 +0100 |
commit | 1cf5842c3ec4479b8789bc0061048dd4747d7bae (patch) | |
tree | ff32fc1a19198dafa463d1578616744f6af99012 /main.py | |
parent | c2109e5561299b2a120d1a669d58f6147ca40fb1 (diff) | |
download | automato-1cf5842c3ec4479b8789bc0061048dd4747d7bae.tar.gz |
python module
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/main.py b/main.py deleted file mode 100755 index b2ffe42..0000000 --- a/main.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 - -import yaml -import json -import logging -import time - -import transport -import state -import command -import endpoint -import trigger -import misc -import action - -logging.basicConfig(level=logging.DEBUG) -logging.getLogger('paramiko').setLevel(logging.WARNING) - -# Use a TypeDict here -with open('endpoints.yml', 'r') as f: - endpoint_config = yaml.safe_load(f) - -with open('triggers.yml', 'r') as f: - trigger_config = yaml.safe_load(f) - -with open('actions.yml', 'r') as f: - action_config = yaml.safe_load(f) - -endpoints = {} -for ep_key in endpoint_config: - endpoints[ep_key] = endpoint.Endpoint(ep_key, endpoint_config[ep_key]) - -triggers = {} -for trg_key in trigger_config: - cls = misc.import_class(trigger_config[trg_key]['class']) - del trigger_config[trg_key]['class'] - - if cls.NEEDS_CONTEXT: - triggers[trg_key] = cls(endpoints, **trigger_config[trg_key]) - else: - triggers[trg_key] = cls(**trigger_config[trg_key]) - -actions = {} -for act_key in action_config: - actions[act_key] = action.Action(act_key, action_config[act_key], endpoints, triggers) - - -# TODO should we do that in Endpoint.__init__()? -for k in endpoints: - endpoints[k].connectTransport() - -for act_key in action_config: - actions[act_key].execute() - -for act_key in action_config: - actions[act_key].execute() - - -#print(endpoints['host1'].getState('user.jonas')) -#print(endpoints['host1'].getState('user.jonas')) -# -#time.sleep(31) -#print(endpoints['host1'].getState('user.jonas')) - -#endpoints['host1'].executeCommand('notify', msg='moinsen') - -#tr = transport.SshTransport('localhost', username='jonas') -#tr.connect() -# -#noti = command.NotifyCommand(tr) -#noti.execute('OwO') -# -#sta = state.UserState(tr) -#sta.collect() -# -#tr.disconnect() |