Commit 3a33df9d authored by Julien Muchembled's avatar Julien Muchembled

Fixes for python3.6

/reviewed-on nexedi/slapos.core!146
parents 3bc0dd76 dcfbb594
......@@ -28,8 +28,20 @@ try:
except ImportError:
additional_install_requires.append('argparse')
if sys.version_info[0] < 3:
additional_install_requires.append('subprocess32')
extras_require = {
'docs': (
'Sphinx',
'repoze.sphinx.autointerface',
'sphinxcontrib.programoutput',
),
'ipython_console': ('ipython',),
'bpython_console': ('bpython',),
'test': (
'pyflakes',
'mock',
'httmock',
),
}
setup(name=name,
version=version,
......@@ -63,20 +75,10 @@ setup(name=name,
'cachecontrol',
'lockfile',
'uritemplate', # used by hateoas navigator
'subprocess32; python_version<"3"'
] + additional_install_requires,
extras_require={
'docs': (
'Sphinx',
'repoze.sphinx.autointerface',
'sphinxcontrib.programoutput'
),
'ipython_console': ('ipython',),
'bpython_console': ('bpython',)},
tests_require=[
'pyflakes',
'mock',
'httmock',
],
extras_require=extras_require,
tests_require=extras_require['test'],
zip_safe=False, # proxy depends on Flask, which has issues with
# accessing templates
entry_points={
......
......@@ -279,7 +279,7 @@ def slapconfig(conf):
to_replace.append(('ipv6_interface', conf.ipv6_interface))
for key, value in to_replace:
cfg = re.sub('\n\s*%s\s*=.*' % key, '\n%s = %s' % (key, value), cfg)
cfg = re.sub('\n\\s*%s\\s*=.*' % key, '\n%s = %s' % (key, value), cfg)
if not dry_run:
with open(config_path, 'w') as fout:
......
......@@ -300,9 +300,9 @@ class Database:
self._execute(delete_sql % (table, where_clause))
vacuum = 1
if vacuum:
self._execute("VACUUM;")
self.commit()
if vacuum:
self._execute("VACUUM")
self.close()
def getDateScopeList(self, ignore_date=None, reported=0):
......
......@@ -643,7 +643,11 @@ class StandaloneSlapOS(object):
debug_args = prog.get('debug_args', '') # pylint: disable=unused-variable
command = prog['command'].format(**locals())
try:
return subprocess.check_call(command, shell=True)
return subprocess.check_call(
command,
shell=True,
env=self._getSubprocessEnvironment(),
)
except subprocess.CalledProcessError as e:
if e.returncode == SLAPGRID_PROMISE_FAIL:
self._logger.exception('Promise error when running %s', command)
......@@ -706,6 +710,7 @@ class StandaloneSlapOS(object):
output = subprocess.check_output(
['supervisord', '--configuration', self._supervisor_config],
cwd=self._base_directory,
env=self._getSubprocessEnvironment(),
)
self._logger.debug("Started new supervisor: %s", output)
......@@ -736,3 +741,14 @@ class StandaloneSlapOS(object):
return
time.sleep(i * .01)
raise RuntimeError("SlapOS not started")
def _getSubprocessEnvironment(self):
# Running tests with `python setup.py test` sets a PYTHONPATH that
# is suitable for current python, but problematic when this process
# runs another version of python in subprocess.
if 'PYTHONPATH' in os.environ:
self._logger.warning(
"Removing $PYTHONPATH from environment for subprocess")
env = os.environ.copy()
del env['PYTHONPATH']
return env
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment