Commit faaebbf3 authored by Jérome Perrin's avatar Jérome Perrin

software/theia: fix instance error when instance is not ASCII

b'💥' is a SyntaxError in python.

Instead, switch to accessing options from option variable and apply
this to other options from this part.

This fixes this issue:

    While:
      Installing switch-softwaretype.
      Installing favicon.ico.

    An internal error occurred due to a bug in either zc.buildout or in a
    recipe being used:
    Traceback (most recent call last):
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 2360, in main
        getattr(buildout, command)(args)
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 640, in install
        self._install_parts(install_args)
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 820, in _install_parts
        installed_files = self[part]._call(recipe.install)
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 1668, in _call
        return f()
      File "slapos.cookbook-1.0.244-py3.7.egg/slapos/recipe/switch_softwaretype.py", line 108, in install
        sub_buildout.install([])
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 640, in install
        self._install_parts(install_args)
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 820, in _install_parts
        installed_files = self[part]._call(recipe.install)
      File "zc.buildout-2.7.1+slapos019-py3.7.egg/zc/buildout/buildout.py", line 1668, in _call
        return f()
      File "slapos.recipe.build-0.54-py3.7.egg/slapos/recipe/build/__init__.py", line 268, in install
        return self._shared.install(self.__install)
      File "slapos.recipe.build-0.54-py3.7.egg/slapos/recipe/__init__.py", line 150, in install
        install()
      File "slapos.recipe.build-0.54-py3.7.egg/slapos/recipe/build/__init__.py", line 278, in __install
        self._exec(self._install)
      File "slapos.recipe.build-0.54-py3.7.egg/slapos/recipe/build/__init__.py", line 261, in _exec
        code = compile(script, self.name, 'exec')
      File "favicon.ico", line 6
    SyntaxError: bytes can only contain ASCII literal characters.
parent 70db124b
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance-theia] [instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in _update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = bdf824a8e09899d6da27b26706d177c5 md5sum = 5a0caaa7004c0af8d2e8fdc7bc96a18f
[instance] [instance]
_update_hash_filename_ = instance.cfg.in _update_hash_filename_ = instance.cfg.in
......
...@@ -336,14 +336,14 @@ install = ...@@ -336,14 +336,14 @@ install =
self.buildout['buildout']['offline'] = 'false' self.buildout['buildout']['offline'] = 'false'
try: try:
gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5( gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5(
b'''$${:seed}''' options['seed'].encode()
).hexdigest() + "?s=256&d=retro" ).hexdigest() + "?s=256&d=retro"
shutil.copy(self.download(gravatar_url), '''$${:location}''') shutil.copy(self.download(gravatar_url), options['location'])
Please register or sign in to reply
except Exception: except Exception:
# Because installation should work offline, if we can't download a favicon, # Because installation should work offline, if we can't download a favicon,
# just ignore this step. # just ignore this step.
self.logger.exception("Error while downloading favicon, using empty one") self.logger.exception("Error while downloading favicon, using empty one")
open('''$${:location}''', 'w').close() open(options['location'], 'w').close()
finally: finally:
self.buildout['buildout']['offline'] = buildout_offline self.buildout['buildout']['offline'] = buildout_offline
......
...@@ -238,6 +238,10 @@ class TestTheia(TheiaTestCase): ...@@ -238,6 +238,10 @@ class TestTheia(TheiaTestCase):
self.assertIn(b'slaprunner', self.captureSlapos('computer', 'list')) self.assertIn(b'slaprunner', self.captureSlapos('computer', 'list'))
class TestTheiaWithNonAsciiInstanceName(TestTheia):
default_partition_reference = '💥'
class TestTheiaEmbeddedSlapOSShutdown(TheiaTestCase): class TestTheiaEmbeddedSlapOSShutdown(TheiaTestCase):
def test_stopping_instance_stops_embedded_slapos(self): def test_stopping_instance_stops_embedded_slapos(self):
embedded_slapos_supervisord_socket = _getSupervisordSocketPath( embedded_slapos_supervisord_socket = _getSupervisordSocketPath(
......
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