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: ...@@ -28,8 +28,20 @@ try:
except ImportError: except ImportError:
additional_install_requires.append('argparse') additional_install_requires.append('argparse')
if sys.version_info[0] < 3: extras_require = {
additional_install_requires.append('subprocess32') 'docs': (
'Sphinx',
'repoze.sphinx.autointerface',
'sphinxcontrib.programoutput',
),
'ipython_console': ('ipython',),
'bpython_console': ('bpython',),
'test': (
'pyflakes',
'mock',
'httmock',
),
}
setup(name=name, setup(name=name,
version=version, version=version,
...@@ -63,20 +75,10 @@ setup(name=name, ...@@ -63,20 +75,10 @@ setup(name=name,
'cachecontrol', 'cachecontrol',
'lockfile', 'lockfile',
'uritemplate', # used by hateoas navigator 'uritemplate', # used by hateoas navigator
'subprocess32; python_version<"3"'
] + additional_install_requires, ] + additional_install_requires,
extras_require={ extras_require=extras_require,
'docs': ( tests_require=extras_require['test'],
'Sphinx',
'repoze.sphinx.autointerface',
'sphinxcontrib.programoutput'
),
'ipython_console': ('ipython',),
'bpython_console': ('bpython',)},
tests_require=[
'pyflakes',
'mock',
'httmock',
],
zip_safe=False, # proxy depends on Flask, which has issues with zip_safe=False, # proxy depends on Flask, which has issues with
# accessing templates # accessing templates
entry_points={ entry_points={
......
...@@ -279,7 +279,7 @@ def slapconfig(conf): ...@@ -279,7 +279,7 @@ def slapconfig(conf):
to_replace.append(('ipv6_interface', conf.ipv6_interface)) to_replace.append(('ipv6_interface', conf.ipv6_interface))
for key, value in to_replace: 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: if not dry_run:
with open(config_path, 'w') as fout: with open(config_path, 'w') as fout:
......
...@@ -300,9 +300,9 @@ class Database: ...@@ -300,9 +300,9 @@ class Database:
self._execute(delete_sql % (table, where_clause)) self._execute(delete_sql % (table, where_clause))
vacuum = 1 vacuum = 1
if vacuum:
self._execute("VACUUM;")
self.commit() self.commit()
if vacuum:
self._execute("VACUUM")
self.close() self.close()
def getDateScopeList(self, ignore_date=None, reported=0): def getDateScopeList(self, ignore_date=None, reported=0):
......
...@@ -643,7 +643,11 @@ class StandaloneSlapOS(object): ...@@ -643,7 +643,11 @@ class StandaloneSlapOS(object):
debug_args = prog.get('debug_args', '') # pylint: disable=unused-variable debug_args = prog.get('debug_args', '') # pylint: disable=unused-variable
command = prog['command'].format(**locals()) command = prog['command'].format(**locals())
try: try:
return subprocess.check_call(command, shell=True) return subprocess.check_call(
command,
shell=True,
env=self._getSubprocessEnvironment(),
)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if e.returncode == SLAPGRID_PROMISE_FAIL: if e.returncode == SLAPGRID_PROMISE_FAIL:
self._logger.exception('Promise error when running %s', command) self._logger.exception('Promise error when running %s', command)
...@@ -706,6 +710,7 @@ class StandaloneSlapOS(object): ...@@ -706,6 +710,7 @@ class StandaloneSlapOS(object):
output = subprocess.check_output( output = subprocess.check_output(
['supervisord', '--configuration', self._supervisor_config], ['supervisord', '--configuration', self._supervisor_config],
cwd=self._base_directory, cwd=self._base_directory,
env=self._getSubprocessEnvironment(),
) )
self._logger.debug("Started new supervisor: %s", output) self._logger.debug("Started new supervisor: %s", output)
...@@ -736,3 +741,14 @@ class StandaloneSlapOS(object): ...@@ -736,3 +741,14 @@ class StandaloneSlapOS(object):
return return
time.sleep(i * .01) time.sleep(i * .01)
raise RuntimeError("SlapOS not started") 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