Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Support ? #508

Open
bousqi opened this issue Sep 14, 2018 · 1 comment
Open

Proxy Support ? #508

bousqi opened this issue Sep 14, 2018 · 1 comment

Comments

@bousqi
Copy link

bousqi commented Sep 14, 2018

I'm facing issue to use Stino Package as my computer must pass through a proxy.
When I pick a board after the installation, the package tries to fetch all missing dependencies but without any success :

[http://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-i686-mingw32.zip] Waiting for download...
[http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i686-w64-mingw32.zip] Waiting for download...
[http://downloads.arduino.cc/tools/arduinoOTA-1.1.1-windows_386.zip] Waiting for download...

In fact, it internally fails.
Is there any simple solution to add proxy support ?

I've been looking into package sources, and I feel (not sure at all) that downloader.py must be modified to fix it.

@bousqi
Copy link
Author

bousqi commented Sep 14, 2018

I managed to make a quick and DIRTY, MEGA DIRTY workaround.
If someone is inspired to make something better :

def download(url, target_dir,
             message_consumer=sys.stdout.write, mode='resume'):
    """."""
    is_done = False
    trunk_size = 1024
    done_size = 0
    is_msg_quiet = True

    file_name = os.path.basename(url)
    target_file_path = os.path.join(target_dir, file_name)
    tmp_file_path = target_file_path + '.stino-down'

    proxies = {'http': 'http://IP.IP.IP.IP:PORT',
               'https': 'https://IP.IP.IP.IP:PORT'}
           
    proxy_handler = urllib.request.ProxyHandler(proxies)
    opener = urllib.request.build_opener(proxy_handler)
    urllib.request.install_opener(opener)

    remote_info = get_remote_file_info(url)
    remote_size = int(remote_info.get('Content-Length', '0'))

Main issue with that solution is that it can't work with HTTPS urls as a install_opener will replace the proxy handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant