Skip to content

Commit

Permalink
Merge pull request #273 from SelfhostedPro/projects
Browse files Browse the repository at this point in the history
Misc Fixes
  • Loading branch information
SelfhostedPro authored Feb 8, 2021
2 parents 5d7abce + 62a01c7 commit 76a8c61
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion backend/api/actions/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 29 additions & 8 deletions backend/api/actions/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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():
Expand All @@ -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'}

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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():
Expand Down

0 comments on commit 76a8c61

Please sign in to comment.