summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-prserv
blob: 14073caf3879ace3387ff510ae30fcd78bd7a3d4 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
import os
import sys,logging
import optparse

sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib'))

import prserv
import prserv.serv

__version__="1.0.0"

PRHOST_DEFAULT=''
PRPORT_DEFAULT=8585

def main():
    parser = optparse.OptionParser(
        version="Bitbake PR Service Core version %s, %%prog version %s" % (prserv.__version__, __version__),
        usage = "%prog [options]")

    parser.add_option("-f", "--file", help="database filename(default prserv.db)", action="store",
                      dest="dbfile", type="string", default="prserv.db")
    parser.add_option("-l", "--log", help="log filename(default prserv.log)", action="store",
                      dest="logfile", type="string", default="prserv.log")
    parser.add_option("--loglevel", help="logging level, i.e. CRITICAL, ERROR, WARNING, INFO, DEBUG",
                      action = "store", type="string", dest="loglevel", default = "WARNING")
    parser.add_option("--start", help="start daemon",
                      action="store_true", dest="start", default="True")
    parser.add_option("--stop", help="stop daemon",
                      action="store_false", dest="start")
    parser.add_option("--host", help="ip address to bind", action="store",
                      dest="host", type="string", default=PRHOST_DEFAULT)
    parser.add_option("--port", help="port number(default 8585)", action="store",
                      dest="port", type="int", default=PRPORT_DEFAULT)

    options, args = parser.parse_args(sys.argv)

    prserv.init_logger(os.path.abspath(options.logfile),options.loglevel)

    if options.start:
        prserv.serv.start_daemon(options)
    else:
        prserv.serv.stop_daemon()

if __name__ == "__main__":
    try:
        ret = main()
    except Exception:
        ret = 1
        import traceback
        traceback.print_exc(5)
    sys.exit(ret)

OpenPOWER on IntegriCloud