andreasscherbaum / ansible-lxc-ssh

Ansible connection plugin using ssh + lxc-attach
45 stars 22 forks source link

[WIP]fix upload of binary data with ansible copy module in python3 #19

Closed TuxCoder closed 4 years ago

TuxCoder commented 5 years ago

this is not tested with python2 but it should work

andreasscherbaum commented 5 years ago

@TuxCoder Wouldn't it make sense to use "wb" in fetch_file() as well?

TuxCoder commented 5 years ago

@andreasscherbaum Thanks for the review, of course it makes sense, only not run into that issue :)

will update the PR

TuxCoder commented 5 years ago

updated the code but not sure about handling, because fd=open('','wb') fd.write(b'..') # requeires binary string

andreasscherbaum commented 5 years ago

Ifit's not a binary object, then Python (at least on Windows) might adjust for line endings, right?

TuxCoder commented 5 years ago

probably I will add a check, if data type is binary use 'wb' else 'w'.

I think we can read always binary? Because the amount of windows user should be not so big

currently I have no other Idea

andreasscherbaum commented 5 years ago

@TuxCoder What I meant is that if you don't use binary, Python on Windows might "adjust" the line endings for you in text files. Usually you don't want that, but you want to copy the file 1:1 instead. That's why "binary mode" should be a good change here, in both ways.

andreasscherbaum commented 5 years ago

@TuxCoder Is this PR still WIP?