Commit 6af74906 authored by Philip ABBET's avatar Philip ABBET

[scripts] 'describe.py' can now be configured using a file

parent 8577d403
......@@ -27,6 +27,7 @@
import sys
import os
import platform
import collections
import simplejson
......@@ -36,14 +37,30 @@ def main():
# resolve package name
name = 'environment'
if len(sys.argv) > 1: name = sys.argv[1]
if len(sys.argv) > 1:
name = sys.argv[1]
# resolve version
version = '1'
if len(sys.argv) > 2: version = sys.argv[2]
if len(sys.argv) > 2:
version = sys.argv[2]
# use a configuration file if one exists
databases = None
if os.path.exists('/etc/beat/environment.json'):
with open('/etc/beat/environment.json', 'r') as config_file:
config = simplejson.load(config_file)
name = config.get('name', name)
version = config.get('version', version)
databases = config.get('databases', None)
# print the result
retval = collections.OrderedDict()
retval['name'] = name
retval['version'] = version
retval['os'] = platform.uname()
if databases is not None:
retval['databases'] = databases
print(simplejson.dumps(retval, indent=2))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment