From b483cb24dd2868b33caa7948cd2d363945b11c2f Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Mon, 8 Feb 2021 13:37:16 -0800 Subject: [PATCH 1/2] fixed DOCKER_HOST format; added error handling for docker socket on readapps --- backend/api/actions/apps.py | 5 ++++- backend/api/actions/compose.py | 37 ++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/backend/api/actions/apps.py b/backend/api/actions/apps.py index 11c8fe33..5cd2e25d 100644 --- a/backend/api/actions/apps.py +++ b/backend/api/actions/apps.py @@ -46,7 +46,10 @@ def check_app_update(app_name): def get_apps(): apps_list = [] - dclient = docker.from_env() + try: + dclient = docker.from_env() + except docker.errors.DockerException as exc: + raise HTTPException(status_code=500, detail=exc.args) try: apps = dclient.containers.list(all=True) except Exception as exc: diff --git a/backend/api/actions/compose.py b/backend/api/actions/compose.py index 74645d6d..e4884d0f 100644 --- a/backend/api/actions/compose.py +++ b/backend/api/actions/compose.py @@ -24,7 +24,10 @@ def compose_action(name, action): _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) elif action == "create": try: _action = docker_compose( @@ -34,14 +37,20 @@ def compose_action(name, action): _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) else: try: _action = docker_compose( action, _cwd=os.path.dirname(compose["path"]),_env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) if _action.stdout.decode("UTF-8").rstrip(): _output = _action.stdout.decode("UTF-8").rstrip() elif _action.stderr.decode("UTF-8").rstrip(): @@ -55,7 +64,7 @@ def compose_action(name, action): def check_dockerhost(environment): if environment.get("DOCKER_HOST"): - return environment["DOCKER_HOST"] + return {'DOCKER_HOST': environment["DOCKER_HOST"]} else: return {'clear_env': 'true'} @@ -79,7 +88,10 @@ def compose_app_action( _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) elif action == "create": try: _action = docker_compose( @@ -90,7 +102,10 @@ def compose_app_action( _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) elif action == "rm": try: _action = docker_compose( @@ -102,7 +117,10 @@ def compose_app_action( _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) else: try: _action = docker_compose( @@ -112,7 +130,10 @@ def compose_app_action( _env=check_dockerhost(env) ) except Exception as exc: - raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + if hasattr(exc, 'stderr'): + raise HTTPException(400, exc.stderr.decode("UTF-8").rstrip()) + else: + raise HTTPException(400, exc) if _action.stdout.decode("UTF-8").rstrip(): output = _action.stdout.decode("UTF-8").rstrip() elif _action.stderr.decode("UTF-8").rstrip(): From 62a01c74a3b485f508f0face37c415368c03c15b Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Mon, 8 Feb 2021 13:38:08 -0800 Subject: [PATCH 2/2] changed time format in version --- .github/workflows/build-devel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-devel.yml b/.github/workflows/build-devel.yml index a59d063a..a9a4d4ba 100644 --- a/.github/workflows/build-devel.yml +++ b/.github/workflows/build-devel.yml @@ -13,7 +13,7 @@ jobs: uses: 1466587594/get-current-time@v2 id: current-time with: - format: YYYY-MM-DD-HH + format: YYYY-MM-DD--HH - name: Checkout code uses: actions/checkout@v2