forked from stb-tester/stb-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstbt-config
executable file
·40 lines (30 loc) · 1.04 KB
/
stbt-config
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
#!/usr/bin/env python
"""
Copyright 2013 YouView TV Ltd.
License: LGPL v2.1 or (at your option) any later version (see
https://github.com/stb-tester/stb-tester/blob/master/LICENSE for details).
"""
import argparse
import sys
import stbt
def error(s):
sys.stderr.write("stbt config: error: %s\n" % s)
sys.exit(1)
parser = argparse.ArgumentParser()
parser.prog = "stbt config"
parser.description = """Prints the value of the specified key from the stbt
configuration file. See 'configuration' in the stbt(1) man page."""
parser.epilog = \
"Returns non-zero exit status if the specified key or section isn't found."
parser.add_argument(
"name", metavar="section.key",
help="e.g. 'global.source_pipeline' or 'record.control_recorder'")
args = parser.parse_args(sys.argv[1:])
if args.name.rfind(".") == -1:
error(
"'name' parameter must contain the section and key separated by a dot")
section, key = args.name.rsplit(".", 1)
try:
print stbt.get_config(section, key)
except stbt.ConfigurationError as e:
error(e.message)