4 from constants import CONFIG_DIR
6 def portrait_filename( char_id, img_size ):
8 err_img = "/usr/share/mevemon/imgs/error.jpg"
10 img_dir = os.path.join(CONFIG_DIR, "imgs/")
13 # if asked for the large version, save it under a diff name --danny
15 filename = os.path.join(img_dir, "%s.jpg" % char_id)
17 filename = os.path.join(img_dir, "%s_lg.jpg" % char_id)
19 # we can only accept 64 or 256... I know an exclamation point is not an error message, but I'll come back to this. FIXME --danny
22 if not os.path.exists(img_dir):
24 elif os.path.isfile( filename ):
27 # specify size and cid --danny
28 img_url = "http://image.eveonline.com/Character/%s_%s.jpg" % ( str( char_id ), img_size )
30 # fetch it, and hit the road. --danny
32 urllib.urlretrieve( img_url, filename, report_handler )
33 except urllib.ContentTooShortError:
37 def report_handler( *a ):
38 ( blocks_transferred, block_size, total_size ) = a