Mercurial > traipse
comparison orpg/mapper/images.py @ 27:51428d30c59e ornery-orc
Traipse 'OpenRPG' {091003-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:
Adds menu changes to draw attention to important updates, errors, or other events.
Traipse URL is now 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 | Sat, 03 Oct 2009 18:49:37 -0500 |
parents | 97265586402b |
children | ff154cf3350c |
comparison
equal
deleted
inserted
replaced
22:8b168989c344 | 27:51428d30c59e |
---|---|
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")) |
96 | 94 |
97 def flushCache(self): | 95 def flushCache(self): |
98 """This function will flush all images contained within the image cache.""" | 96 """This function will flush all images contained within the image cache.""" |
99 self.__lock.acquire() | 97 self.__lock.acquire() |
100 try: | 98 try: |
101 keyList = self.__cache.keys() | 99 self.__cache = {} |
102 for key in keyList: del self.__cache[key] | 100 self.__fetching = {} |
103 finally: self.__lock.release() | 101 finally: |
104 urllib.urlcleanup() | 102 self.__lock.release() |
103 urllib.urlcleanup() | |
105 | 104 |
106 """Private Methods""" | 105 """Private Methods""" |
107 def __loadThread(self, path, image_type, imageId): | 106 def __loadThread(self, path, image_type, imageId): |
108 uriPath = urllib.unquote(path) | 107 uriPath = urllib.unquote(path) |
109 self.__lock.acquire() | 108 self.__lock.acquire() |
112 """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 |
113 it was an image that we got back.""" | 112 it was an image that we got back.""" |
114 if d[0] and d[1].getmaintype() == "image": | 113 if d[0] and d[1].getmaintype() == "image": |
115 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) | 114 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) |
116 self.__queue.put((self.__cache[path], image_type, imageId)) | 115 self.__queue.put((self.__cache[path], image_type, imageId)) |
117 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] |
118 else: | 117 else: |
119 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) |
120 component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path +"</font>") | |
121 del self.__fetching[path] | 119 del self.__fetching[path] |
122 except IOError: | 120 except IOError: |
123 del self.__fetching[path] | 121 del self.__fetching[path] |
124 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) |
125 component.get('chat').InfoPost("<font color='#FF0000'> Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") | |
126 finally: self.__lock.release() | 123 finally: self.__lock.release() |
127 | 124 |
128 def __loadCacheThread(self, path, image_type, imageId): | 125 def __loadCacheThread(self, path, image_type, imageId): |
129 if self.__cache.has_key(path): | 126 try: |
130 try: | 127 st = time.time() |
131 st = time.time() | 128 while self.__fetching.has_key(path) and self.__fetching[path] is not False: |
132 while self.__fetching.has_key(path) and self.__fetching[path] is not False: | 129 time.sleep(0.025) |
133 time.sleep(0.025) | 130 if (time.time()-st) > 120: |
134 if (time.time()-st) > 120: | 131 logger.general("Timeout: " + path) |
135 logger.general("Timeout: " + path) | 132 break |
136 break | 133 except: |
137 except: | 134 del self.__fetching[path] |
138 del self.__fetching[path] | 135 logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True) |
139 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) | 136 return |
140 component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") | 137 self.__lock.acquire() |
141 return | 138 try: |
142 self.__lock.acquire() | 139 logger.info("Adding Image to Queue from Cache: " + str(self.__cache[path]), True) |
143 try: | 140 self.__queue.put((self.__cache[path], image_type, imageId)) |
144 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path])) | 141 finally: self.__lock.release() |
145 component.debug('chat').InfoPost("<font color='#FF0000'>Adding Image to Queue from Cache: " + str(self.__cache[path]) + "</font>") | |
146 self.__queue.put((self.__cache[path], image_type, imageId)) | |
147 finally: self.__lock.release() | |
148 | 142 |
149 """Property Methods""" | 143 """Property Methods""" |
150 def _getCache(self): | 144 def _getCache(self): |
151 return self.__cache | 145 return self.__cache |
152 | 146 |
156 """Properties""" | 150 """Properties""" |
157 Cache = property(_getCache) | 151 Cache = property(_getCache) |
158 Queue = property(_getQueue) | 152 Queue = property(_getQueue) |
159 | 153 |
160 ImageHandler = singleton(ImageHandlerClass) | 154 ImageHandler = singleton(ImageHandlerClass) |
155 component.add('ImageHandler', ImageHandler) |