Commit 9275552a authored by Arnaud Fontaine's avatar Arnaud Fontaine

mysql: With universal_newlines, python3 subprocess assumes that communicate()...

mysql: With universal_newlines, python3 subprocess assumes that communicate() parameter is str() (not bytes()).

But mysql_script_file was opened as a binary files and thus a bytes() was returned:
    File "etc/run/mariadb_update", line 51, in <module>
      sys.exit(slapos.recipe.generic_mysql.mysql.updateMysql(mysql_upgrade_binary='/srv/slapgrid/slappart3/bin/mysql_upgrade', mysql_binary='/srv/slapgrid/slappart3/bin/mysql', mysql_script_file='/srv/slapgrid/slappart3/etc/mariadb_initial_setup.sql'))
    File "parts/slapos.cookbook-repository/slapos/recipe/generic_mysql/mysql.py", line 31, in updateMysql
      result = mysql.communicate(mysql_script)[0]
    File "parts/python3/lib/python3.7/subprocess.py", line 964, in communicate
      stdout, stderr = self._communicate(input, endtime, timeout)
    File "parts/python3/lib/python3.7/subprocess.py", line 1692, in _communicate
      self._save_input(input)
    File "parts/python3/lib/python3.7/subprocess.py", line 1774, in _save_input
      self._input = self._input.encode(self.stdin.encoding,
  AttributeError: 'bytes' object has no attribute 'encode'
parent 222c9b73
......@@ -8,7 +8,7 @@ import pytz
def updateMysql(mysql_upgrade_binary, mysql_binary, mysql_script_file):
sleep = 0
with open(mysql_script_file, 'rb') as script_file:
with open(mysql_script_file, 'r') as script_file:
mysql_script = script_file.read()
mysql_list = mysql_binary, '-B'
mysql_tzinfo_to_sql_list = (
......
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