mirror of
https://git.yoctoproject.org/git/poky
synced 2026-01-01 13:58:04 +00:00
optparse is deprecated since Python 2.7 Note that this is neither supposed to change the options supported by bitbake-prserv nor the way they are interpreted. Note that in the "--help" output, long options are now reported for example as "--host HOST" instead of "--host=HOST" but both are equivalent anyway, as they already were with optparse. (Bitbake rev: 434cd00a9e5a8ef32088f1a587005adf910a92eb) Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Tim Orling <ticotimo@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
94 lines
2.1 KiB
Python
Executable File
94 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Copyright BitBake Contributors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
import os
|
|
import sys,logging
|
|
import argparse
|
|
import warnings
|
|
warnings.simplefilter("default")
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "lib"))
|
|
|
|
import prserv
|
|
import prserv.serv
|
|
|
|
VERSION = "1.1.0"
|
|
|
|
PRHOST_DEFAULT="0.0.0.0"
|
|
PRPORT_DEFAULT=8585
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="BitBake PR Server. Version=%s" % VERSION,
|
|
formatter_class=argparse.RawTextHelpFormatter)
|
|
|
|
parser.add_argument(
|
|
"-f",
|
|
"--file",
|
|
default="prserv.sqlite3",
|
|
help="database filename (default: prserv.sqlite3)",
|
|
)
|
|
parser.add_argument(
|
|
"-l",
|
|
"--log",
|
|
default="prserv.log",
|
|
help="log filename(default: prserv.log)",
|
|
)
|
|
parser.add_argument(
|
|
"--loglevel",
|
|
default="INFO",
|
|
help="logging level, i.e. CRITICAL, ERROR, WARNING, INFO, DEBUG",
|
|
)
|
|
parser.add_argument(
|
|
"--start",
|
|
action="store_true",
|
|
help="start daemon",
|
|
)
|
|
parser.add_argument(
|
|
"--stop",
|
|
action="store_true",
|
|
help="stop daemon",
|
|
)
|
|
parser.add_argument(
|
|
"--host",
|
|
help="ip address to bind",
|
|
default=PRHOST_DEFAULT,
|
|
)
|
|
parser.add_argument(
|
|
"--port",
|
|
type=int,
|
|
default=PRPORT_DEFAULT,
|
|
help="port number (default: 8585)",
|
|
)
|
|
parser.add_argument(
|
|
"-r",
|
|
"--read-only",
|
|
action="store_true",
|
|
help="open database in read-only mode",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
prserv.init_logger(os.path.abspath(args.log), args.loglevel)
|
|
|
|
if args.start:
|
|
ret=prserv.serv.start_daemon(args.file, args.host, args.port, os.path.abspath(args.log), args.read_only)
|
|
elif args.stop:
|
|
ret=prserv.serv.stop_daemon(args.host, args.port)
|
|
else:
|
|
ret=parser.print_help()
|
|
return ret
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
ret = main()
|
|
except Exception:
|
|
ret = 1
|
|
import traceback
|
|
traceback.print_exc()
|
|
sys.exit(ret)
|
|
|