python.py (1527:89bc2fef480b) python.py (1596:b7e2d4d92624)
1import os
2import shutil
1import os
2import shutil
3import pytest
3
4from unit.applications.proto import TestApplicationProto
4
5from unit.applications.proto import TestApplicationProto
6from conftest import option
5
6
7class TestApplicationPython(TestApplicationProto):
8 application_type = "python"
9
10 def load(self, script, name=None, **kwargs):
7
8
9class TestApplicationPython(TestApplicationProto):
10 application_type = "python"
11
12 def load(self, script, name=None, **kwargs):
13 print()
11 if name is None:
12 name = script
13
14 if script[0] == '/':
15 script_path = script
16 else:
14 if name is None:
15 name = script
16
17 if script[0] == '/':
18 script_path = script
19 else:
17 script_path = self.current_dir + '/python/' + script
20 script_path = option.test_dir + '/python/' + script
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
21
22 if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'):
23 rootfs = kwargs['isolation']['rootfs']
24
25 if not os.path.exists(rootfs + '/app/python/'):
26 os.makedirs(rootfs + '/app/python/')
27
28 if not os.path.exists(rootfs + '/app/python/' + name):
29 shutil.copytree(script_path, rootfs + '/app/python/' + name)
30
31 script_path = '/app/python/' + name
32
33 appication_type = self.get_appication_type()
34
35 if appication_type is None:
36 appication_type = self.application_type
37
30 self._load_conf(
31 {
32 "listeners": {"*:7080": {"pass": "applications/" + name}},
33 "applications": {
34 name: {
38 self._load_conf(
39 {
40 "listeners": {"*:7080": {"pass": "applications/" + name}},
41 "applications": {
42 name: {
35 "type": self.application_type,
43 "type": appication_type,
36 "processes": {"spare": 0},
37 "path": script_path,
38 "working_directory": script_path,
39 "module": "wsgi",
40 }
41 },
42 },
43 **kwargs
44 )
44 "processes": {"spare": 0},
45 "path": script_path,
46 "working_directory": script_path,
47 "module": "wsgi",
48 }
49 },
50 },
51 **kwargs
52 )