|
|
|
@ -42,11 +42,12 @@ class Project(YamlSerializable):
@@ -42,11 +42,12 @@ class Project(YamlSerializable):
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def absulute_path(self): |
|
|
|
|
if not hasattr(self, 'production_path') or not self.relative_production_path: |
|
|
|
|
if not hasattr(self, 'relative_production_path') or not self.relative_production_path: |
|
|
|
|
return None |
|
|
|
|
return Path(config['production_path'].get()) / self.relative_production_path |
|
|
|
|
|
|
|
|
|
def update(self): |
|
|
|
|
"""Update project's local repoistory""" |
|
|
|
|
# pylint: disable=no-member |
|
|
|
|
self._make_sure_production_path_exists() |
|
|
|
|
path = self.absulute_path |
|
|
|
@ -77,16 +78,24 @@ class Project(YamlSerializable):
@@ -77,16 +78,24 @@ class Project(YamlSerializable):
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
def delete_files(self): |
|
|
|
|
self._make_sure_production_path_exists() |
|
|
|
|
if self._production_path_exists(): |
|
|
|
|
path = self.absulute_path |
|
|
|
|
app.logger.info(f"Deleting {path}") |
|
|
|
|
rmtree(path) |
|
|
|
|
self.relative_production_path = None |
|
|
|
|
self.save() |
|
|
|
|
|
|
|
|
|
def _production_path_exists(self): |
|
|
|
|
"""Return True if project's the production directory path exists""" |
|
|
|
|
prod_path_dir = Path(config['production_path'].get()) |
|
|
|
|
if hasattr(self, 'relative_production_path') and self.relative_production_path: |
|
|
|
|
full_path = prod_path_dir / self.relative_production_path |
|
|
|
|
return full_path.is_dir() |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
def _make_sure_production_path_exists(self): |
|
|
|
|
prod_path_dir = Path(config['production_path'].get()) |
|
|
|
|
if hasattr(self, 'production_path') and self.relative_production_path: |
|
|
|
|
if hasattr(self, 'relative_production_path') and self.relative_production_path: |
|
|
|
|
full_path = prod_path_dir / self.relative_production_path |
|
|
|
|
if not full_path.is_dir(): |
|
|
|
|
full_path.mkdir(parents=True) |
|
|
|
|