comparison orpg/mapper/images.py @ 100:7ed4979cc1cf beta

Traipse Beta 'OpenRPG' {090925-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: 090925-00: Adds menu changes to draw attention to important updates, errors, or other events. (image info coming soon) Traipse URL is not included in the repos tab and is set as default. Fixes Copy for Windows and Linux (finally!!) users. Fixes incomplete update to Grid and List nodes. Fixes incomplete update to Chat Commands. Fixes problems with Remote Image Upload. Fixes Drop and Drag of Minis to Map. CherryPy can now use any image in the webfiles/ folder and sub-folders. CherryPy can now Drop and Drag Minis to the Map. Minor changes to Update Manager's GUI. Expert recommendation warning added to Revision Update. Step down compatibility with open_rpg & component added to orpgCore. Fixes CherryPit misspelling. Makes Traipse Suite 'Attention' item portable, and executes it on 'Critical' debug notices. Adds incomplete Shift + Enter to Text Entry, currently creates a 'Critical' warning. New default Lobby Map, designed for Traipse. Feel free to change it. Updates to Server GUI: * Admin can Ban from Backend. * Admin can Modify Ban List and Un Ban users. * Server GUI finds your Lobby Name * New users default as Lurker unless a Role is set Cleaner TraipseSuiteAttention portability and clean up in Main. Die Roll Commands addition from Core code allowing Math Ordering with ()'s New About Dialog. A more uniform About Dialog. Corrects image loading of duplicate images.
author sirebral
date Fri, 25 Sep 2009 20:46:02 -0500
parents 68c7bd272f27
children 61fc775862f7 dcf4fbe09b70
comparison
equal deleted inserted replaced
94:118fbe111922 100:7ed4979cc1cf
76 it was an image that we got back.""" 76 it was an image that we got back."""
77 if d[0] and d[1].getmaintype() == "image": 77 if d[0] and d[1].getmaintype() == "image":
78 self.__cache[path] = (path, d[0], d[1].gettype(), None) 78 self.__cache[path] = (path, d[0], d[1].gettype(), None)
79 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap() 79 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap()
80 else: 80 else:
81 logger.general("Image refused to load or URI did not reference a valid image: " + path) 81 logger.exception(str("Image refused to load or URI did not reference a valid image: " + path), True)
82 component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path + "</font>")
83 return None 82 return None
84 except IOError: 83 except IOError:
85 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) 84 logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
86 component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
87 return None 85 return None
88 86
89 def cleanCache(self): 87 def cleanCache(self):
90 """Shrinks the Cache down to the proper size""" 88 """Shrinks the Cache down to the proper size"""
91 try: cacheSize = int(component.get('settings').get_setting("ImageCacheSize")) 89 try: cacheSize = int(component.get('settings').get_setting("ImageCacheSize"))
113 """We have to make sure that not only did we fetch something, but that 111 """We have to make sure that not only did we fetch something, but that
114 it was an image that we got back.""" 112 it was an image that we got back."""
115 if d[0] and d[1].getmaintype() == "image": 113 if d[0] and d[1].getmaintype() == "image":
116 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) 114 self.__cache[path] = (path, d[0], d[1].gettype(), imageId)
117 self.__queue.put((self.__cache[path], image_type, imageId)) 115 self.__queue.put((self.__cache[path], image_type, imageId))
118 if self.__fetching.has_key(path): self.__fetching[path] = False #Fix for failed multi-load? 116 if self.__fetching.has_key(path): del self.__fetching[path]
119 else: 117 else:
120 logger.general("Image refused to load or URI did not reference a valid image: " + path) 118 logger.exception(str("Image refused to load or URI did not reference a valid image: " + path), True)
121 component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path +"</font>")
122 del self.__fetching[path] 119 del self.__fetching[path]
123 except IOError: 120 except IOError:
124 del self.__fetching[path] 121 del self.__fetching[path]
125 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) 122 logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
126 component.get('chat').InfoPost("<font color='#FF0000'> Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
127 finally: self.__lock.release() 123 finally: self.__lock.release()
128 124
129 def __loadCacheThread(self, path, image_type, imageId): 125 def __loadCacheThread(self, path, image_type, imageId):
130 if self.__cache.has_key(path): 126 try:
131 try: 127 st = time.time()
132 st = time.time() 128 while self.__fetching.has_key(path) and self.__fetching[path] is not False:
133 while self.__fetching.has_key(path) and self.__fetching[path] is not False: 129 time.sleep(0.025)
134 time.sleep(0.025) 130 if (time.time()-st) > 120:
135 if (time.time()-st) > 120: 131 logger.general("Timeout: " + path)
136 logger.general("Timeout: " + path) 132 break
137 break 133 except:
138 except: 134 del self.__fetching[path]
139 del self.__fetching[path] 135 logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
140 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) 136 return
141 component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") 137 self.__lock.acquire()
142 return 138 try:
143 self.__lock.acquire() 139 logger.info("Adding Image to Queue from Cache: " + str(self.__cache[path]), True)
144 try: 140 self.__queue.put((self.__cache[path], image_type, imageId))
145 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path])) 141 finally: self.__lock.release()
146 component.debug('chat').InfoPost("<font color='#FF0000'>Adding Image to Queue from Cache: " + str(self.__cache[path]) + "</font>")
147 self.__queue.put((self.__cache[path], image_type, imageId))
148 finally: self.__lock.release()
149 142
150 """Property Methods""" 143 """Property Methods"""
151 def _getCache(self): 144 def _getCache(self):
152 return self.__cache 145 return self.__cache
153 146