vikstrous / pirate-get

A command line interface for The Pirate Bay
GNU Affero General Public License v3.0
337 stars 53 forks source link

Trouble running pirate-get in docker container #108

Closed danradom closed 7 years ago

danradom commented 7 years ago

Any tips on getting this running in my Ubuntu docker container would be very much appreciated. I've tried as non-root user as well and get the same error.

Python 3.4.3

root@1e74e843de66:/# pirate-get foo Trying https://thepiratebay.org/... Ok Traceback (most recent call last): File "/usr/local/bin/pirate-get", line 9, in load_entry_point('pirate-get==0.2.11', 'console_scripts', 'pirate-get')() File "/usr/local/lib/python3.4/dist-packages/pirate/pirate.py", line 425, in main pirate_main(args) File "/usr/local/lib/python3.4/dist-packages/pirate/pirate.py", line 339, in pirate_main printer.search_results(results, local=args.source == 'local_tpb') File "/usr/local/lib/python3.4/dist-packages/pirate/print.py", line 98, in search_results self.print(table) File "/usr/local/lib/python3.4/dist-packages/pirate/print.py", line 37, in print return builtins.print(*args, **kwargs) UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 162: ordinal not in range(128)

vikstrous commented 7 years ago

Seems to work fine for me: https://gist.github.com/vikstrous/5cbcb22ee3e72387750229d0ac52c4d2 How are you running it?

vikstrous commented 7 years ago

Ah, just tried it on ubuntu and I can see the same error. I'll look into it.

danradom commented 7 years ago

Thanks! I basically started my openvpn-transmission container and installed it via pip3 and ran it getting the error. I'm pretty new to docker.

vikstrous commented 7 years ago

It you want a quick solution, you can try alpine. It's much smaller and you can see the steps to install pirate-get in my gist.

The problem seems to be around using print to print non-ascii characters. This also fails with sys.stdout.write()...

>>> print(chr(0xa0))
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 0: ordinal not in range(128)

However, this works for me on arch linux... I'll finish the investigation later, but maybe someone reading this has an idea? Maybe it's about the python version? 3.6.1 works, 3.5.2 fails.

danradom commented 7 years ago

I was able to install python 3.6. after editing the pirate-get script to run it with the 3.6 version i get the following error. I will look into trying alpine, but I'm not sure how to manage all the openvpn and transmission stuff.

root@080d4f8a5d6b:/data# pirate-get foo Traceback (most recent call last): File "/usr/local/bin/pirate-get", line 5, in from pkg_resources import load_entry_point File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

How can I get it to use the /usr/lib/python3.6 libs?

danradom commented 7 years ago

Thanks for looking into this. I was able to get it all working just the way I want with alpine container. Cheers!

rnhmjoj commented 7 years ago

This is an issue with your terminal character encoding. You will have problems with every python program that outputs something other than plain ASCII. Previously reported here

danradom commented 7 years ago

duplicate of #77