-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate
pbench-config
and pbench-server-config
- Loading branch information
Showing
6 changed files
with
53 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
import sys | ||
|
||
from pbench.common.conf import common_main | ||
|
||
|
||
def main(): | ||
sys.exit(common_main(os.path.basename(sys.argv[0]), "_PBENCH_AGENT_CONFIG")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
import sys | ||
|
||
from pbench.common.conf import common_main | ||
|
||
|
||
def main(): | ||
sys.exit(common_main(os.path.basename(sys.argv[0]), "_PBENCH_SERVER_CONFIG")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
import os | ||
import sys | ||
|
||
from pbench.common import configtools | ||
|
||
|
||
def get_pbench_config(): | ||
"""Determine if we are using agent or server.""" | ||
agent_cfg = os.environ.get("_PBENCH_AGENT_CONFIG") | ||
server_cfg = os.environ.get("_PBENCH_SERVER_CONFIG") | ||
if agent_cfg: | ||
return "_PBENCH_AGENT_CONFIG" | ||
elif server_cfg: | ||
return "_PBENCH_SERVER_CONFIG" | ||
else: | ||
return sys.exit(1) | ||
def common_main(prog: str, env: str): | ||
"""Common entry point for agent and server pbench-config commands. | ||
Args: | ||
prog : invocation program name to use in Usage message | ||
env : environment variable for configuration file | ||
def main(): | ||
prog = os.path.basename(sys.argv[0]) | ||
Returns: | ||
Pass through of return code from `configtools.main` | ||
""" | ||
opts, args = configtools.parse_args( | ||
configtools.options, | ||
usage=f"Usage: {prog} [options] <item>|-a <section> [<section> ...]", | ||
) | ||
conf, files = configtools.init(opts, get_pbench_config()) | ||
status = configtools.main(conf, args, opts, files) | ||
sys.exit(status) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
conf, files = configtools.init(opts, env) | ||
return configtools.main(conf, args, opts, files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters