GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#57)
by Matic
01:02
created

run_bot()   A

Complexity

Conditions 3

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
c 2
b 0
f 0
dl 0
loc 23
rs 9.0856
1
#!/usr/bin/env python
2
3
import sys
4
from daemon import Daemon
5
6
7
def run_bot():
8
    import settings
9
    from handler import Bot
10
11
    while True:
12
        try:
13
            # initialize and run
14
            botko = Bot(settings)
15
            botko.run()
16
17
        except Exception:
18
            # log the error
19
            from traceback import format_exc
20
            from datetime import datetime
21
            from time import sleep
22
23
            print("ERR " + str(format_exc()))
24
25
            f = open('error_log', 'a')
26
            f.write(str(datetime.now()) + "\n")
27
            f.write(str(format_exc() + "\n\n"))
28
            f.close()
29
            sleep(10)
30
31
32
def print_usage():
33
    print("usage: %s start|stop|restart|nodaemon" % sys.argv[0])
34
35
36
class BotkoDaemon(Daemon):
37
38
    def run(self):
39
        run_bot()
40
41
if __name__ == "__main__":
42
    daemon = BotkoDaemon('/tmp/botko.pid')  # nosec: predictable, but low risk
43
    if len(sys.argv) == 2:
44
        if sys.argv[1] == 'start':
45
            daemon.start()
46
        elif sys.argv[1] == 'stop':
47
            daemon.stop()
48
        elif sys.argv[1] == 'restart':
49
            daemon.restart()
50
        elif sys.argv[1] == 'nodaemon':
51
            run_bot()
52
        else:
53
            print_usage()
54
            sys.exit(2)
55
        sys.exit(0)
56
    else:
57
        print_usage()
58
        sys.exit(2)
59