Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
nrm
Commits
55997380
Commit
55997380
authored
Dec 11, 2018
by
Valentin Reis
Browse files
[fix] Formatting the daemon file according to standard flake8 rules.
parent
5a3b9fc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/daemon
View file @
55997380
...
...
@@ -7,78 +7,85 @@ import nrm
import
nrm.daemon
import
os
def
main
(
argv
=
None
):
if
argv
is
None
:
argv
=
sys
.
argv
if
argv
is
None
:
argv
=
sys
.
argv
conf_parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
add_help
=
False
)
conf_parser
.
add_argument
(
"-c"
,
"--configuration"
,
help
=
"Specify a config json-formatted config file to override
\
any of the available CLI options. If an option is
\
actually provided on the command-line, it overrides
\
its corresponding value from the configuration file."
,
metavar
=
"FILE"
)
conf_parser
.
add_argument
(
"-d"
,
"--print_defaults"
,
action
=
'store_true'
,
help
=
"Print the default configuration file."
)
args
,
remaining_argv
=
conf_parser
.
parse_known_args
()
conf_parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
add_help
=
False
)
conf_parser
.
add_argument
(
"-c"
,
"--configuration"
,
help
=
"Specify a config json-formatted config file to override
"
"
any of the available CLI options. If an option is
"
"
actually provided on the command-line, it overrides
"
"
its corresponding value from the configuration file."
,
metavar
=
"FILE"
)
conf_parser
.
add_argument
(
"-d"
,
"--print_defaults"
,
action
=
'store_true'
,
help
=
"Print the default configuration file."
)
args
,
remaining_argv
=
conf_parser
.
parse_known_args
()
defaults
=
{
"nrm_log"
:
"/tmp/nrm.log"
,
"hwloc"
:
"hwloc"
,
"perf"
:
"perf"
,
"argo_perf_wrapper"
:
"argo-perf-wrapper"
,
"argo_nodeos_config"
:
"argo_nodeos_config"
}
defaults
=
{
"nrm_log"
:
"/tmp/nrm.log"
,
"hwloc"
:
"hwloc"
,
"perf"
:
"perf"
,
"argo_perf_wrapper"
:
"argo-perf-wrapper"
,
"argo_nodeos_config"
:
"argo_nodeos_config"
}
if
args
.
print_defaults
:
print
defaults
return
(
0
)
if
args
.
print_defaults
:
print
defaults
return
(
0
)
if
args
.
configuration
:
defaults
.
update
(
json
.
load
(
open
(
args
.
configuration
)))
if
args
.
configuration
:
defaults
.
update
(
json
.
load
(
open
(
args
.
configuration
)))
parser
=
argparse
.
ArgumentParser
(
parents
=
[
conf_parser
])
parser
.
set_defaults
(
**
defaults
)
parser
.
add_argument
(
"--nrm_log"
,
help
=
"Main log file. Override default with the NRM_LOG."
"environment variable"
,
default
=
os
.
environ
.
get
(
'NRM_LOG'
,
'/tmp/nrm.log'
))
parser
.
add_argument
(
'--hwloc'
,
help
=
"Path to the hwloc to use. This path can be "
"relative and makes uses of the $PATH if necessary."
"Override default with the HWLOC environment"
"variable."
,
default
=
os
.
environ
.
get
(
'HWLOC'
,
'hwloc'
))
parser
.
add_argument
(
'--argo_nodeos_config'
,
help
=
"Path to the argo_nodeos_config to use. This path "
"can be relative and makes uses of the $PATH if "
"necessary. Override default with the "
"ARGO_NODEOS_CONFIG environment variable."
,
default
=
os
.
environ
.
get
(
'ARGO_NODEOS_CONFIG'
,
'argo_nodeos_config'
))
parser
.
add_argument
(
'--perf'
,
help
=
"Path to the linux perf tool to use. This path can be"
"relative and makes uses of the $PATH if necessary."
"Override default with the PERF environment"
"variable."
,
default
=
os
.
environ
.
get
(
'PERF'
,
'perf'
))
parser
.
add_argument
(
'--argo_perf_wrapper'
,
help
=
"Path to the linux perf tool to use. This path can"
"be relative and makes uses of the $PATH if "
"necessary. Override default with the PERFWRAPPER "
"environment variable."
,
default
=
os
.
environ
.
get
(
'ARGO_PERF_WRAPPER'
,
'argo-perf-wrapper'
))
args
=
parser
.
parse_args
(
remaining_argv
)
nrm
.
daemon
.
runner
(
config
=
args
)
return
(
0
)
parser
=
argparse
.
ArgumentParser
(
parents
=
[
conf_parser
])
parser
.
set_defaults
(
**
defaults
)
parser
.
add_argument
(
"--nrm_log"
,
help
=
"Main log file. Override default with the NRM_LOG.
\
environment variable"
,
default
=
os
.
environ
.
get
(
'NRM_LOG'
,
'/tmp/nrm.log'
))
parser
.
add_argument
(
'--hwloc'
,
help
=
"Path to the hwloc to use. This path can be
\
relative and makes uses of the $PATH if necessary.
\
Override default with the HWLOC environment
\
variable."
,
default
=
os
.
environ
.
get
(
'HWLOC'
,
'hwloc'
))
parser
.
add_argument
(
'--argo_nodeos_config'
,
help
=
"Path to the argo_nodeos_config to use. This path
\
can be relative and makes uses of the $PATH if
\
necessary. Override default with the
\
ARGO_NODEOS_CONFIG environment variable."
,
default
=
os
.
environ
.
get
(
'ARGO_NODEOS_CONFIG'
,
'argo_nodeos_config'
))
parser
.
add_argument
(
'--perf'
,
help
=
"Path to the linux perf tool to use. This path can be
\
relative and makes uses of the $PATH if necessary.
\
Override default with the PERF environment
\
variable."
,
default
=
os
.
environ
.
get
(
'PERF'
,
'perf'
))
parser
.
add_argument
(
'--argo_perf_wrapper'
,
help
=
"Path to the linux perf tool to use. This path can
\
be relative and makes uses of the $PATH if
\
necessary. Override default with the PERFWRAPPER
\
environment variable."
,
default
=
os
.
environ
.
get
(
'ARGO_PERF_WRAPPER'
,
'argo-perf-wrapper'
))
args
=
parser
.
parse_args
(
remaining_argv
)
nrm
.
daemon
.
runner
(
config
=
args
)
return
(
0
)
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
sys
.
exit
(
main
())
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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