mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
manifestv2: moar attempts to fix mypy errors
This commit is contained in:
parent
0610a1808b
commit
564c2de815
1 changed files with 34 additions and 5 deletions
|
@ -22,8 +22,7 @@ import os
|
||||||
import copy
|
import copy
|
||||||
import shutil
|
import shutil
|
||||||
import random
|
import random
|
||||||
from typing import Optional, Dict, List, Union, Any, Mapping, Callable, no_type_check
|
from typing import Optional, Dict, List, Union, Any, Mapping, Callable
|
||||||
|
|
||||||
|
|
||||||
from moulinette.utils.process import check_output
|
from moulinette.utils.process import check_output
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
@ -124,6 +123,7 @@ class AppResourceManager:
|
||||||
|
|
||||||
class AppResource:
|
class AppResource:
|
||||||
|
|
||||||
|
type: str = ""
|
||||||
default_properties: Dict[str, Any] = None
|
default_properties: Dict[str, Any] = None
|
||||||
|
|
||||||
def __init__(self, properties: Dict[str, Any], app: str, manager=None):
|
def __init__(self, properties: Dict[str, Any], app: str, manager=None):
|
||||||
|
@ -318,6 +318,9 @@ class SystemuserAppResource(AppResource):
|
||||||
"allow_sftp": False
|
"allow_sftp": False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allow_ssh: bool = False
|
||||||
|
allow_sftp: bool = False
|
||||||
|
|
||||||
def provision_or_update(self, context: Dict={}):
|
def provision_or_update(self, context: Dict={}):
|
||||||
|
|
||||||
# FIXME : validate that no yunohost user exists with that name?
|
# FIXME : validate that no yunohost user exists with that name?
|
||||||
|
@ -367,7 +370,6 @@ class SystemuserAppResource(AppResource):
|
||||||
# fi
|
# fi
|
||||||
#
|
#
|
||||||
|
|
||||||
@no_type_check
|
|
||||||
class InstalldirAppResource(AppResource):
|
class InstalldirAppResource(AppResource):
|
||||||
"""
|
"""
|
||||||
is_provisioned -> setting install_dir exists + /dir/ exists
|
is_provisioned -> setting install_dir exists + /dir/ exists
|
||||||
|
@ -393,10 +395,18 @@ class InstalldirAppResource(AppResource):
|
||||||
"group": "__APP__:rx",
|
"group": "__APP__:rx",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir: str = ""
|
||||||
|
owner: str = ""
|
||||||
|
group: str = ""
|
||||||
|
|
||||||
# FIXME: change default dir to /opt/stuff if app ain't a webapp ...
|
# FIXME: change default dir to /opt/stuff if app ain't a webapp ...
|
||||||
|
|
||||||
def provision_or_update(self, context: Dict={}):
|
def provision_or_update(self, context: Dict={}):
|
||||||
|
|
||||||
|
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
||||||
|
assert self.owner.strip()
|
||||||
|
assert self.group.strip()
|
||||||
|
|
||||||
current_install_dir = self.get_setting("install_dir") or self.get_setting("final_path")
|
current_install_dir = self.get_setting("install_dir") or self.get_setting("final_path")
|
||||||
|
|
||||||
# If during install, /var/www/$app already exists, assume that it's okay to remove and recreate it
|
# If during install, /var/www/$app already exists, assume that it's okay to remove and recreate it
|
||||||
|
@ -427,13 +437,17 @@ class InstalldirAppResource(AppResource):
|
||||||
self.delete_setting("final_path") # Legacy
|
self.delete_setting("final_path") # Legacy
|
||||||
|
|
||||||
def deprovision(self, context: Dict={}):
|
def deprovision(self, context: Dict={}):
|
||||||
|
|
||||||
|
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
||||||
|
assert self.owner.strip()
|
||||||
|
assert self.group.strip()
|
||||||
|
|
||||||
# FIXME : check that self.dir has a sensible value to prevent catastrophes
|
# FIXME : check that self.dir has a sensible value to prevent catastrophes
|
||||||
if os.path.isdir(self.dir):
|
if os.path.isdir(self.dir):
|
||||||
rm(self.dir, recursive=True)
|
rm(self.dir, recursive=True)
|
||||||
# FIXME : in fact we should delete settings to be consistent
|
# FIXME : in fact we should delete settings to be consistent
|
||||||
|
|
||||||
|
|
||||||
@no_type_check
|
|
||||||
class DatadirAppResource(AppResource):
|
class DatadirAppResource(AppResource):
|
||||||
"""
|
"""
|
||||||
is_provisioned -> setting data_dir exists + /dir/ exists
|
is_provisioned -> setting data_dir exists + /dir/ exists
|
||||||
|
@ -459,8 +473,16 @@ class DatadirAppResource(AppResource):
|
||||||
"group": "__APP__:rx",
|
"group": "__APP__:rx",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir: str = ""
|
||||||
|
owner: str = ""
|
||||||
|
group: str = ""
|
||||||
|
|
||||||
def provision_or_update(self, context: Dict={}):
|
def provision_or_update(self, context: Dict={}):
|
||||||
|
|
||||||
|
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
||||||
|
assert self.owner.strip()
|
||||||
|
assert self.group.strip()
|
||||||
|
|
||||||
current_data_dir = self.get_setting("data_dir")
|
current_data_dir = self.get_setting("data_dir")
|
||||||
|
|
||||||
if not os.path.isdir(self.dir):
|
if not os.path.isdir(self.dir):
|
||||||
|
@ -482,6 +504,11 @@ class DatadirAppResource(AppResource):
|
||||||
self.set_setting("data_dir", self.dir)
|
self.set_setting("data_dir", self.dir)
|
||||||
|
|
||||||
def deprovision(self, context: Dict={}):
|
def deprovision(self, context: Dict={}):
|
||||||
|
|
||||||
|
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
||||||
|
assert self.owner.strip()
|
||||||
|
assert self.group.strip()
|
||||||
|
|
||||||
# FIXME: This should rm the datadir only if purge is enabled
|
# FIXME: This should rm the datadir only if purge is enabled
|
||||||
pass
|
pass
|
||||||
#if os.path.isdir(self.dir):
|
#if os.path.isdir(self.dir):
|
||||||
|
@ -517,7 +544,6 @@ class DatadirAppResource(AppResource):
|
||||||
# return
|
# return
|
||||||
#
|
#
|
||||||
|
|
||||||
@no_type_check
|
|
||||||
class AptDependenciesAppResource(AppResource):
|
class AptDependenciesAppResource(AppResource):
|
||||||
"""
|
"""
|
||||||
is_provisioned -> package __APP__-ynh-deps exists (ideally should check the Depends: but hmgn)
|
is_provisioned -> package __APP__-ynh-deps exists (ideally should check the Depends: but hmgn)
|
||||||
|
@ -542,6 +568,9 @@ class AptDependenciesAppResource(AppResource):
|
||||||
"extras": {}
|
"extras": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packages: List = []
|
||||||
|
extras: Dict[str: Any] = {}
|
||||||
|
|
||||||
def __init__(self, properties: Dict[str, Any], *args, **kwargs):
|
def __init__(self, properties: Dict[str, Any], *args, **kwargs):
|
||||||
|
|
||||||
for key, values in properties.get("extras", {}).items():
|
for key, values in properties.get("extras", {}).items():
|
||||||
|
|
Loading…
Add table
Reference in a new issue