Skip to content

Commit 198a4c3

Browse files
committed
try again
1 parent 6db75ce commit 198a4c3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def cleanup(*args):
5050

5151
DUMP_CMD = 'mysqldump -h {host} -P {port} -u {user} --password={password} {db} {table} ' \
5252
'--default-character-set=utf8 -X'.format(**config['mysql'])
53+
REMOVE_INVALID_PIPE = "sed 's/[^[:print:]]//g'"
5354

5455
BINLOG_CFG = {key: config['mysql'][key] for key in ['host', 'port', 'user', 'password', 'db']}
5556
BULK_SIZE = config.get('elastic').get('bulk_size')
@@ -310,9 +311,15 @@ def xml_dump_loader():
310311
stdout=subprocess.PIPE,
311312
stderr=subprocess.DEVNULL,
312313
close_fds=True)
313-
stream = codecs.EncodedFile(mysqldump.stdout, data_encoding='utf-8',
314-
file_encoding='utf-8', errors='replace')
315-
return stream
314+
315+
remove_invalid_pipe = subprocess.Popen(
316+
shlex.split(REMOVE_INVALID_PIPE),
317+
stdin=mysqldump.stdout,
318+
stdout=subprocess.PIPE,
319+
stderr=subprocess.DEVNULL,
320+
close_fds=True)
321+
322+
return remove_invalid_pipe.stdout
316323

317324

318325
def xml_file_loader(filename):

0 commit comments

Comments
 (0)