summaryrefslogtreecommitdiff
path: root/butler.py
blob: 7019b61f284ad0c4a1b979afc974972e9beb1c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys

def main():
    nowait = 'nowait' not in sys.argv
    args = [arg for arg in sys.argv[1:] if arg != 'nowait']
    if len(args) == 0:
        args = ['calculate', 'generate', 'send']

    try:
        from ausbutler.config import load_config
        from ausbutler.goniec import Goniec
        from ausbutler.interface import Interface

        i = Interface(load_config('butler'))

        if 'calculate' in args:
            i.calculate_all()

        if 'generate' in args:
            files = i.generate_all()
            if 'send' in args:
                client = Goniec(load_config('goniec'))
                client.send(files)
    except Exception as e:
        print 'ERROR: %s: %s' % (type(e).__name__, str(e))

    if nowait:
        raw_input('Press any key to continue...')

if __name__ == '__main__':
    main()