These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Python using Evelink - Eve-Central Calls

Author
Timballisto
Prometheus Academy
#1 - 2014-08-16 03:01:38 UTC
Hi all,
I'm having a go at writing a python script to call an item price from Eve-Central.
I am having a problem which I can't seem resolve.
Here is a simple test case:

Quote:
import evelink.thirdparty.eve_central as evelink_EC

print evelink_EC.EVECentral()

raw_input('Press Enter to exit')


From this I get the following error within eve_central.py, line 20, in __init__ (see here for source code):
elif urllib2 is not None
NameError: global name 'urllib2' is not defined

I've also tried importing urllib and urllib2 prior to the print statement without any success.
I'm using python 2.7.7 (Anaconda package to be precise) on Windows XP and have successfully installed the evelink package. (Have been able to access my wallet journal using evelink)

Any ideas?
Tim
Timballisto
Prometheus Academy
#2 - 2014-08-16 17:31:50 UTC
Problem resolved.
For anybody interested in the resolution to my problem:

I was able to import from evelink.thirdparty.six.moves import urllib in the try/except logic in eve_central.py.
This meant that urllib2 was left undefined when it cam to the if/elif/else statement in the def __init__
Hence, it couldn't resolve the elif statement.

I'm a relative python/coding noob so I am certain that there are better resolutions to this problem but for just getting it up and running I've edited eve_central.py from this (can't maintain the correct indentation):

Quote:

if url_fetch_func is not None:
self.url_fetch = url_fetch_func
elif urllib2 is not None:
self.url_fetch = self._default_fetch_func
else:
raise ValueError("urllib2 not available - specify url_fetch_func")


to this:

Quote:

if url_fetch_func is not None:
self.url_fetch = url_fetch_func
else:
self.url_fetch = self._default_fetch_func


I re-iterate, this is not ideal and down right shoddy work but as I type this I can think of two potential ways to resolve this, the best way is to fix the code by initialising the variable, perhaps by adding something like urllib2 = True to the try part of the try/except section. The alternative if you aren't confident with editing the code is to work out how to use EVECentral(url_fetch_func=*url*).
Replace *url* with the correct url, this feature eluded me but others might have better luck with it.

Cheers,
Tim