4 def portrait_filename( char_id, img_size ):
6 err_img = '/opt/mevemon/imgs/error.jpg'
7 if not os.path.isfile(err_img):
9 err_img = "/usr/share/mevemon/imgs/error.jpg"
11 img_dir = os.path.expanduser("~/.mevemon/imgs/")
14 # if asked for the large version, save it under a diff name --danny
16 filename = os.path.join(img_dir, "%s.jpg" % char_id)
18 filename = os.path.join(img_dir, "%s_lg.jpg" % char_id)
20 # 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
23 if not os.path.exists(img_dir):
25 elif os.path.isfile( filename ):
28 # specify size and cid --danny
29 img_url = "http://img.eve.is/serv.asp?s=%s&c=%s" % ( str( img_size ), char_id )
31 # fetch it, and hit the road. --danny
33 urllib.urlretrieve( img_url, filename, report_handler )
34 except urllib.ContentTooShortError:
38 def report_handler( *a ):
39 ( blocks_transferred, block_size, total_size ) = a