diff options
author | Oliver Smith <osmith@sysmocom.de> | 2022-09-20 14:28:10 +0200 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2022-09-21 14:17:37 +0000 |
commit | 910cf0622012624161f7162f5dc4b04c65931f37 (patch) | |
tree | 293bbc1cd0a0c0b2d7c1674275ec8f946b8a3dbe | |
parent | 34b97c7aa6684972441691bc9f8e45e6ff8a498f (diff) |
obs: update_obs_project: check if oscrc exists
Check if the oscrc exists, as otherwise the osc command will
interactively prompt for the credentials. If running without verbose
mode (the default), the command output is hidden and so it would just
appear to be hanging without this patch if the config doesn't exist.
Change-Id: I6f140b2c1d171d3019fd259399e6a46da9c6451f
-rw-r--r-- | scripts/obs/README | 2 | ||||
-rw-r--r-- | scripts/obs/lib/osc.py | 12 | ||||
-rwxr-xr-x | scripts/obs/update_obs_project.py | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/scripts/obs/README b/scripts/obs/README index 67d2a2b..cd0955d 100644 --- a/scripts/obs/README +++ b/scripts/obs/README @@ -29,7 +29,7 @@ Verify that it worked: libosmo-pfcp osmo-hnbgw -FYI, the config file will look like this: +FYI, the config file (oscrc) will look like this: [general] apiurl = https://obs.osmocom.org diff --git a/scripts/obs/lib/osc.py b/scripts/obs/lib/osc.py index 2fcdbc6..51e2f5f 100644 --- a/scripts/obs/lib/osc.py +++ b/scripts/obs/lib/osc.py @@ -20,6 +20,18 @@ def check_proj(obs_project): exit(1) +def check_oscrc(): + configdir = os.environ.get("XDG_CONFIG_HOME", "~/.config") + paths = ["~/.oscrc", f"{configdir}/osc/oscrc"] + for path in paths: + if os.path.exists(os.path.expanduser(path)): + return + + print("ERROR: oscrc does not exist, please create one as explained in the" + " README.") + exit(1) + + def set_apiurl(url): global apiurl apiurl = url diff --git a/scripts/obs/update_obs_project.py b/scripts/obs/update_obs_project.py index 02db7ce..61691f6 100755 --- a/scripts/obs/update_obs_project.py +++ b/scripts/obs/update_obs_project.py @@ -200,6 +200,7 @@ def main(): lib.docker.run_in_docker_and_exit(__file__, args, True) lib.osc.check_proj(proj) + lib.osc.check_oscrc() lib.osc.set_apiurl(args.apiurl) lib.check_required_programs() lib.remove_temp() |