-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path__init__.py
80 lines (70 loc) · 1.86 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import logging
import os
import shutil
from .. import Component
from zygoat.utils.shell import multi_docker_run
from zygoat.constants import Projects, Images
from .dockerfile import dockerfile
from .settings import settings
from .gitignore import gitignore
from .black import black
from .flake8 import flake8
from .banditrc import banditrc
from .pytest import pytest
from .dependencies import dependencies
from .reformat import reformat
log = logging.getLogger()
class Backend(Component):
def create(self):
log.info("Generating the django project")
multi_docker_run(
[
[
"pip",
"install",
"--upgrade",
"django",
],
[
"django-admin",
"startproject",
Projects.BACKEND,
],
],
self.docker_image(Images.PYTHON),
".",
)
multi_docker_run(
[
[
"pip",
"install",
"--upgrade",
"pip",
"poetry",
],
["poetry", "init", "-n", "--name", "backend"],
],
self.docker_image(Images.PYTHON),
Projects.BACKEND,
)
def delete(self):
log.warning(f"Deleting the {Projects.BACKEND} project")
shutil.rmtree(Projects.BACKEND)
@property
def installed(self):
return os.path.exists(Projects.BACKEND)
backend = Backend(
sub_components=[
settings,
dockerfile,
dependencies,
gitignore,
black,
banditrc,
flake8,
pytest,
# It is important that this comes last, so all relevant items can be reformatted
reformat,
]
)