Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.backend.python
Commits
6af74906
Commit
6af74906
authored
Mar 16, 2017
by
Philip ABBET
Browse files
[scripts] 'describe.py' can now be configured using a file
parent
8577d403
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/backend/python/scripts/describe.py
View file @
6af74906
...
...
@@ -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
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment