Skip to content

Commit

Permalink
formatted python
Browse files Browse the repository at this point in the history
  • Loading branch information
SelfhostedPro committed Oct 29, 2020
1 parent 8b5f3c3 commit 5a2746c
Show file tree
Hide file tree
Showing 24 changed files with 252 additions and 233 deletions.
2 changes: 1 addition & 1 deletion backend/api/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .apps import *
from .compose import *
from .resources import *
from .resources import *
10 changes: 5 additions & 5 deletions backend/api/actions/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_running_apps():

return apps_list


def check_app_update(app_name):
dclient = docker.from_env()
try:
Expand All @@ -33,7 +34,7 @@ def check_app_update(app_name):
raise HTTPException(
status_code=exc.response.status_code, detail=exc.explanation
)

if app.attrs["Config"]["Image"]:
if _update_check(app.attrs["Config"]["Image"]):
app.attrs.update(conv2dict("isUpdatable", True))
Expand All @@ -42,6 +43,7 @@ def check_app_update(app_name):
app.attrs.update(conv2dict("short_id", app.short_id))
return app.attrs


def get_apps():
apps_list = []
dclient = docker.from_env()
Expand Down Expand Up @@ -118,9 +120,7 @@ def deploy_app(template: schemas.DeployForm):
conv_caps2data(template.cap_add),
)
except HTTPException as exc:
raise HTTPException(
status_code=exc.status_code, detail=exc.detail
)
raise HTTPException(status_code=exc.status_code, detail=exc.detail)
except Exception as exc:
raise HTTPException(
status_code=exc.response.status_code, detail=exc.explanation
Expand Down Expand Up @@ -307,4 +307,4 @@ def check_self_update():
status_code=exc.response.status_code, detail=exc.explanation
)

return _update_check(yacht.image.tags[0])
return _update_check(yacht.image.tags[0])
10 changes: 4 additions & 6 deletions backend/api/actions/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ def compose_action(name, action):


def compose_app_action(
name,
action,
app,
name, action, app,
):

files = find_yml_files(settings.COMPOSE_DIR)
compose = get_compose(name)
print('docker-compose -f ' + compose["path"] + ' ' + action + ' ' + app)
print("docker-compose -f " + compose["path"] + " " + action + " " + app)
if action == "up":
try:
_action = docker_compose(
Expand Down Expand Up @@ -193,4 +191,4 @@ def write_compose(compose):
f.write(compose.content)
f.close()

return get_compose(name=compose.name)
return get_compose(name=compose.name)
2 changes: 1 addition & 1 deletion backend/api/actions/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@ def prune_resources(resource):
deleted_resource = action.prune(filters={"dangling": False})
else:
deleted_resource = action.prune()
return deleted_resource
return deleted_resource
7 changes: 1 addition & 6 deletions backend/api/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ class UserTable(Base, SQLAlchemyBaseUserTable):
app = FastAPI()

fastapi_users = FastAPIUsers(
user_db,
auth_backends,
User,
UserCreate,
UserUpdate,
UserDB,
user_db, auth_backends, User, UserCreate, UserUpdate, UserDB,
)


Expand Down
27 changes: 16 additions & 11 deletions backend/api/db/crud/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,31 @@

def export_settings(db: Session):
file_export = {}
file_export['templates'] = db.query(models.Template).all()
file_export['variables'] = db.query(models.TemplateVariables).all()
return(file_export)
file_export["templates"] = db.query(models.Template).all()
file_export["variables"] = db.query(models.TemplateVariables).all()
return file_export


def import_settings(db: Session, upload):
import_file = upload.file.read()
decoded_import = import_file.decode('utf-8')
decoded_import = import_file.decode("utf-8")
import_contents = json.loads(decoded_import)

_templates = import_contents['templates']
_variables = import_contents['variables']
_templates = import_contents["templates"]
_variables = import_contents["variables"]

_template_list = []
_var_list = []

for template in _templates:
template_model = models.Template(id=template['id'], title=template['title'], url=template['url'], updated_at=datetime.fromisoformat(
template['updated_at']), created_at=datetime.fromisoformat(template['created_at']))
for item in template['items']:
template_model = models.Template(
id=template["id"],
title=template["title"],
url=template["url"],
updated_at=datetime.fromisoformat(template["updated_at"]),
created_at=datetime.fromisoformat(template["created_at"]),
)
for item in template["items"]:
_item = models.TemplateItem(**item)
template_model.items.append(_item)
_template_list.append(template_model)
Expand All @@ -49,5 +54,5 @@ def import_settings(db: Session, upload):
db.add_all(_template_list)
db.add_all(_var_list)
db.commit()
response = {'success': 'Import Successful'}
return(response)
response = {"success": "Import Successful"}
return response
Loading

0 comments on commit 5a2746c

Please sign in to comment.