11673St.nateldemoura@f5.comimport os 21673St.nateldemoura@f5.comimport shutil 31673St.nateldemoura@f5.com 41019Szelenkov@nginx.comfrom unit.applications.proto import TestApplicationProto 51730Szelenkov@nginx.comfrom unit.option import option 61019Szelenkov@nginx.com 71019Szelenkov@nginx.com 81019Szelenkov@nginx.comclass TestApplicationPHP(TestApplicationProto): 91116Szelenkov@nginx.com application_type = "php" 101116Szelenkov@nginx.com 111381St.nateldemoura@f5.com def load(self, script, index='index.php', **kwargs): 121596Szelenkov@nginx.com script_path = option.test_dir + '/php/' + script 131019Szelenkov@nginx.com 141673St.nateldemoura@f5.com if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'): 151673St.nateldemoura@f5.com rootfs = kwargs['isolation']['rootfs'] 161673St.nateldemoura@f5.com 171673St.nateldemoura@f5.com if not os.path.exists(rootfs + '/app/php/'): 181673St.nateldemoura@f5.com os.makedirs(rootfs + '/app/php/') 191673St.nateldemoura@f5.com 201673St.nateldemoura@f5.com if not os.path.exists(rootfs + '/app/php/' + script): 211673St.nateldemoura@f5.com shutil.copytree(script_path, rootfs + '/app/php/' + script) 221673St.nateldemoura@f5.com 231673St.nateldemoura@f5.com script_path = '/app/php/' + script 241673St.nateldemoura@f5.com 25*2000Smax.romanov@nginx.com app = { 26*2000Smax.romanov@nginx.com "type": self.get_application_type(), 27*2000Smax.romanov@nginx.com "processes": kwargs.pop('processes', {"spare": 0}), 28*2000Smax.romanov@nginx.com "root": script_path, 29*2000Smax.romanov@nginx.com "working_directory": script_path, 30*2000Smax.romanov@nginx.com "index": index, 31*2000Smax.romanov@nginx.com } 32*2000Smax.romanov@nginx.com 33*2000Smax.romanov@nginx.com for attr in ( 34*2000Smax.romanov@nginx.com 'environment', 35*2000Smax.romanov@nginx.com 'limits', 36*2000Smax.romanov@nginx.com 'options', 37*2000Smax.romanov@nginx.com 'targets', 38*2000Smax.romanov@nginx.com ): 39*2000Smax.romanov@nginx.com if attr in kwargs: 40*2000Smax.romanov@nginx.com app[attr] = kwargs.pop(attr) 41*2000Smax.romanov@nginx.com 421050Szelenkov@nginx.com self._load_conf( 431019Szelenkov@nginx.com { 441041Svbart@nginx.com "listeners": {"*:7080": {"pass": "applications/" + script}}, 45*2000Smax.romanov@nginx.com "applications": {script: app}, 461303St.nateldemoura@f5.com }, 471303St.nateldemoura@f5.com **kwargs 481019Szelenkov@nginx.com ) 49