lofar-astron / RMextract

extract TEC, vTEC, Earthmagnetic field and Rotation Measures from GPS and WMM data for radio interferometry observations
GNU General Public License v3.0
31 stars 22 forks source link

RMextract not downloading through ftp proxy #24

Closed amisk closed 5 years ago

amisk commented 5 years ago

Hi,

I have the issue that in our network you can not download stuff via ftp without using a proxyserver.

In order to fix that, I added a bit of code to getIONEX.py and getRM.py. getIONEx.py got a second function as an alternative to _get_IONEX_file. This uses urllib2 instead of ftplib, because ftplib does not provide any options for proxy servers.

And in getRM I check if the prefactor pipeline uses a proxy server. If yes, the get_urllib_IONEXfile function is called, otherwise _get_IONEX_file is called.

It also accepts usernames and passwords for the server, although I can not test that since our proxy does not need it.

For this, the PySocks package has to be installed on the machine.

Can I commit it here? Or send it by email? This will probably only affect one or two people, but could still be good to have that option.

maaijke commented 5 years ago

THanks for solving this. Can you do a pull request?

gheald commented 5 years ago

I think that this addition has broken getRM.py (at least) in the case where a proxy server is not required - I now get an error: local variable 'use_proxy' referenced before assignment This seems to originate on line 161: https://github.com/lofar-astron/RMextract/blob/530993fbee1fb2e5c8aa94930d144d6aec30f0c0/RMextract/getRM.py#L161 Indeed there is no place where use_proxy can be set to False if proxy_server is never caught on line 84.

gheald commented 5 years ago

So, to be more specific, I suggest adding: use_proxy = False after line 53 in getRM.py

amisk commented 5 years ago

Yes, you are right. I was sure I had it in when I tested it without a proxy. Pull request is made.

maaijke commented 5 years ago

I submitted a fix