python.py (1303:248eeec4c272) python.py (1490:cecf6b11a1e3)
1import shutil
2import os
3
1from unit.applications.proto import TestApplicationProto
2
3
4class TestApplicationPython(TestApplicationProto):
5 application_type = "python"
6
7 def load(self, script, name=None, **kwargs):
8 if name is None:
9 name = script
10
4from unit.applications.proto import TestApplicationProto
5
6
7class TestApplicationPython(TestApplicationProto):
8 application_type = "python"
9
10 def load(self, script, name=None, **kwargs):
11 if name is None:
12 name = script
13
11 script_path = self.current_dir + '/python/' + script
14 if script[0] == '/':
15 script_path = script
16 else:
17 script_path = self.current_dir + '/python/' + script
12
18
19 if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'):
20 rootfs = kwargs['isolation']['rootfs']
21
22 if not os.path.exists(rootfs + '/app/python/'):
23 os.makedirs(rootfs + '/app/python/')
24
25 if not os.path.exists(rootfs + '/app/python/' + name):
26 shutil.copytree(script_path, rootfs + '/app/python/' + name)
27
28 script_path = '/app/python/' + name
29
13 self._load_conf(
14 {
15 "listeners": {"*:7080": {"pass": "applications/" + name}},
16 "applications": {
17 name: {
18 "type": self.application_type,
19 "processes": {"spare": 0},
20 "path": script_path,
21 "working_directory": script_path,
22 "module": "wsgi",
23 }
24 },
25 },
26 **kwargs
27 )
30 self._load_conf(
31 {
32 "listeners": {"*:7080": {"pass": "applications/" + name}},
33 "applications": {
34 name: {
35 "type": self.application_type,
36 "processes": {"spare": 0},
37 "path": script_path,
38 "working_directory": script_path,
39 "module": "wsgi",
40 }
41 },
42 },
43 **kwargs
44 )