Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_1111_absolute(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -p /var -c /etc/nginx.conf', {'prefix': '/var', 'conf-path': '/foo/nginx.conf'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/etc/nginx.conf'))
def test_0101_absolute(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -p /var', {'conf-path': '/etc/nginx.conf'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/etc/nginx.conf'))
def test_0011_relative(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx', {'prefix': '/var', 'conf-path': 'dir/nginx.conf'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/var/dir/nginx.conf'))
def test_1011_relative(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -c dir/nginx.conf', {'prefix': '/var', 'conf-path': '/foo/nginx.conf'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/var/dir/nginx.conf'))
def test_1000_relative(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -c dir/nginx.conf', {}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/usr/local/nginx'))
assert_that(conf_path, equal_to('/usr/local/nginx/dir/nginx.conf'))
def test_1100_absolute(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -p /var -c /etc/nginx.conf', {}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/etc/nginx.conf'))
def test_0110(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -p /var', {'prefix': '/foo'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/var/conf/nginx.conf'))
def test_0001_relative(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx', {'conf-path': 'dir/nginx.conf'}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/usr/local/nginx'))
assert_that(conf_path, equal_to('/usr/local/nginx/dir/nginx.conf'))
def test_1100_relative(self):
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(
'nginx: master process nginx -p /var -c dir/nginx.conf', {}
)
assert_that(bin_path, equal_to('nginx'))
assert_that(prefix, equal_to('/var'))
assert_that(conf_path, equal_to('/var/dir/nginx.conf'))
gwe = re.match(r'\s*(?P\d+)\s+(?P\d+)\s+(?P.+)\s*', line)
# if not parsed - go to the next line
if not gwe:
continue
pid, ppid, cmd = int(gwe.group('pid')), int(gwe.group('ppid')), gwe.group('cmd').rstrip()
# match nginx master process
if 'nginx: master process' in cmd:
if not launch_method_supported("nginx", ppid):
continue
# get path to binary, prefix and conf_path
try:
bin_path, prefix, conf_path, version = get_prefix_and_conf_path(cmd)
except:
context.log.debug('failed to find bin_path, prefix and conf_path for %s' % cmd)
context.log.debug('', exc_info=True)
else:
# calculate local id
local_id = hashlib.sha256('%s_%s_%s' % (bin_path, conf_path, prefix)).hexdigest()
if pid not in masters:
masters[pid] = {'workers': []}
masters[pid].update({
'version': version,
'bin_path': bin_path,
'conf_path': conf_path,
'prefix': prefix,
'pid': pid,