diff orpg/mapper/images.py @ 99:a647e0e8f520 alpha

Traipse Alpha '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: 00: Update forwards to the 090909-02 Server code that now works. New default Lobby Map, designed for Traipse. Feel free to change it. Updates to Server GUI: * Admin can Ban from Backend. * Prework to modify Ban List in back end. * Server GUI finds your Lobby Name * New users default as Lurker unless a Role is set New Addition to Chat Die Roll commands. Math Ordering. Ex. [(X+Y)dZ]. Currently does pairs only, no nesting either. Cleaner TraipseSuiteAttention portability and clean up in Main (Beta!) 01: Die Roll Commands addition removed in favor of Core code {090925-00}: Updates to Server GUI: *Admin can Modify Ban List and Un Ban users. New About Dialog. A more uniform About Dialog. 01: Corrects image loading of duplicate images.
author sirebral
date Fri, 25 Sep 2009 20:37:54 -0500
parents 763a04270cf6
children 61fc775862f7 dcf4fbe09b70
line wrap: on
line diff
--- a/orpg/mapper/images.py	Fri Sep 25 06:16:37 2009 -0500
+++ b/orpg/mapper/images.py	Fri Sep 25 20:37:54 2009 -0500
@@ -78,12 +78,10 @@
                 self.__cache[path] = (path, d[0], d[1].gettype(), None)
                 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap()
             else:
-                logger.general("Image refused to load or URI did not reference a valid image: " + path)
-                component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path + "</font>")
+                logger.exception(str("Image refused to load or URI did not reference a valid image: " + path), True)
                 return None
         except IOError:
-            logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
-            component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
+            logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
             return None
 
     def cleanCache(self):
@@ -115,37 +113,32 @@
             if d[0] and d[1].getmaintype() == "image":
                 self.__cache[path] = (path, d[0], d[1].gettype(), imageId)
                 self.__queue.put((self.__cache[path], image_type, imageId))
-                if self.__fetching.has_key(path): self.__fetching[path] = False #Fix for failed multi-load?
+                if self.__fetching.has_key(path): del self.__fetching[path]
             else:
-                logger.general("Image refused to load or URI did not reference a valid image: " + path)
-                component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path +"</font>")
+                logger.exception(str("Image refused to load or URI did not reference a valid image: " + path), True)
                 del self.__fetching[path]
         except IOError:
             del self.__fetching[path]
-            logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
-            component.get('chat').InfoPost("<font color='#FF0000'> Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
+            logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
         finally: self.__lock.release()
 
     def __loadCacheThread(self, path, image_type, imageId):
-        if self.__cache.has_key(path):
-            try:
-                st = time.time()
-                while self.__fetching.has_key(path) and self.__fetching[path] is not False:
-                    time.sleep(0.025)
-                    if (time.time()-st) > 120:
-                        logger.general("Timeout: " + path)
-                        break
-            except:
-                del self.__fetching[path]
-                logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
-                component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
-                return 
-            self.__lock.acquire()
-            try:
-                logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path]))
-                component.debug('chat').InfoPost("<font color='#FF0000'>Adding Image to Queue from Cache: " + str(self.__cache[path]) + "</font>")
-                self.__queue.put((self.__cache[path], image_type, imageId))
-            finally: self.__lock.release()
+        try:
+            st = time.time()
+            while self.__fetching.has_key(path) and self.__fetching[path] is not False:
+                time.sleep(0.025)
+                if (time.time()-st) > 120:
+                    logger.general("Timeout: " + path)
+                    break
+        except:
+            del self.__fetching[path]
+            logger.exception(str("Unable to resolve/open the specified URI; image was NOT loaded: " + path), True)
+            return 
+        self.__lock.acquire()
+        try:
+            logger.info("Adding Image to Queue from Cache: " + str(self.__cache[path]), True)
+            self.__queue.put((self.__cache[path], image_type, imageId))
+        finally: self.__lock.release()
 
     """Property Methods"""
     def _getCache(self):