Mercurial > traipse_dev
annotate orpg/mapper/images.py @ 76:37a11fea3304 ornery-dev
More clean up. Images now posts a Chat Info post if image doesn't load.
author | sirebral |
---|---|
date | Sat, 22 Aug 2009 04:02:14 -0500 |
parents | 449a8900f9ac |
children | 6226a5f9a4b3 |
rev | line source |
---|---|
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
1 # Copyright (C) 2000-2001 The OpenRPG Project |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
2 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
3 # openrpg-dev@lists.sourceforge.net |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
4 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
5 # This program is free software; you can redistribute it and/or modify |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
6 # it under the terms of the GNU General Public License as published by |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
7 # the Free Software Foundation; either version 2 of the License, or |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
8 # (at your option) any later version. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
9 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
10 # This program is distributed in the hope that it will be useful, |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
13 # GNU General Public License for more details. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
14 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
15 # You should have received a copy of the GNU General Public License |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
16 # along with this program; if not, write to the Free Software |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
18 # -- |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
19 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
20 # File: mapper/images.py |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
21 # Author: OpenRPG |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
22 # Maintainer: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
23 # Version: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
24 # $Id: images.py,v 1.21 2007/12/11 04:07:15 digitalxero Exp $ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
25 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
26 # Description: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
27 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
28 __version__ = "$Id: images.py,v 1.21 2007/12/11 04:07:15 digitalxero Exp $" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
29 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
30 import urllib |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
31 import Queue |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
32 import thread |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
33 from threading import Lock |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
34 import time |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
35 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
36 from orpg.orpg_wx import * |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
37 from orpg.orpgCore import component |
66 | 38 from orpg.dirpath import dir_struct |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
39 from orpg.tools.orpg_log import logger |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
40 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
41 def singleton(cls): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
42 instances = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
43 def getinstance(): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
44 if cls not in instances: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
45 instances[cls] = cls() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
46 return instances[cls] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
47 return getinstance() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
48 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
49 class ImageHandlerClass(object): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
50 __cache = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
51 __fetching = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
52 __queue = Queue.Queue(0) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
53 __lock = Lock() |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
54 chat = component.get("chat") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
55 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
56 def load(self, path, image_type, imageId): |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
57 """Load an image, with a intermideary fetching image shown while it loads in a background thread""" |
20 | 58 if self.__cache.has_key(path): return wx.ImageFromMime(self.__cache[path][1], |
59 self.__cache[path][2]).ConvertToBitmap() | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
60 if not self.__fetching.has_key(path): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
61 self.__fetching[path] = True |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
62 """Start Image Loading Thread""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
63 thread.start_new_thread(self.__loadThread, (path, image_type, imageId)) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
64 else: |
20 | 65 if self.__fetching[path] is True: thread.start_new_thread(self.__loadCacheThread, (path, image_type, imageId)) |
66 | 66 return wx.Bitmap(dir_struct["icon"] + "fetching.png", wx.BITMAP_TYPE_PNG) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
67 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
68 def directLoad(self, path): |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
69 """Directly load an image, no threads""" |
20 | 70 if self.__cache.has_key(path): return wx.ImageFromMime(self.__cache[path][1], |
71 self.__cache[path][2]).ConvertToBitmap() | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
72 uriPath = urllib.unquote(path) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
73 try: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
74 d = urllib.urlretrieve(uriPath) |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
75 """We have to make sure that not only did we fetch something, but that |
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
76 it was an image that we got back.""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
77 if d[0] and d[1].getmaintype() == "image": |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
78 self.__cache[path] = (path, d[0], d[1].gettype(), None) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
79 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
80 else: |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
81 logger.general("Image refused to load or URI did not reference a valid image: " + path) |
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
82 component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path + "</font>") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
83 return None |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
84 except IOError: |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
85 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) |
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
86 component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
87 return None |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
88 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
89 def cleanCache(self): |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
90 """Shrinks the Cache down to the proper size""" |
66 | 91 try: cacheSize = int(component.get('settings').get_setting("ImageCacheSize")) |
20 | 92 except: cacheSize = 32 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
93 cache = self.__cache.keys() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
94 cache.sort() |
20 | 95 for key in cache[cacheSize:]: del self.__cache[key] |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
96 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
97 def flushCache(self): |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
98 """This function will flush all images contained within the image cache.""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
99 self.__lock.acquire() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
100 try: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
101 keyList = self.__cache.keys() |
20 | 102 for key in keyList: del self.__cache[key] |
103 finally: self.__lock.release() | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
104 urllib.urlcleanup() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
105 |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
106 """Private Methods""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
107 def __loadThread(self, path, image_type, imageId): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
108 uriPath = urllib.unquote(path) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
109 self.__lock.acquire() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
110 try: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
111 d = urllib.urlretrieve(uriPath) |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
112 """We have to make sure that not only did we fetch something, but that |
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
113 it was an image that we got back.""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
114 if d[0] and d[1].getmaintype() == "image": |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
115 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
116 self.__queue.put((self.__cache[path], image_type, imageId)) |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
117 if self.__fetching.has_key(path): self.__fetching[path] = False #Fix for failed multi-load? |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
118 else: |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
119 logger.general("Image refused to load or URI did not reference a valid image: " + path) |
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
120 component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path +"</font>") |
15
cab94a90f9dc
Added 1.8.0 fix to log. Fixed problem with images that do not load the first
sirebral
parents:
3
diff
changeset
|
121 del self.__fetching[path] |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
122 except IOError: |
15
cab94a90f9dc
Added 1.8.0 fix to log. Fixed problem with images that do not load the first
sirebral
parents:
3
diff
changeset
|
123 del self.__fetching[path] |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
124 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) |
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
125 component.get('chat').InfoPost("<font color='#FF0000'> Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") |
20 | 126 finally: self.__lock.release() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
127 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
128 def __loadCacheThread(self, path, image_type, imageId): |
22
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
129 if self.__cache.has_key(path): |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
130 try: |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
131 st = time.time() |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
132 while self.__fetching.has_key(path) and self.__fetching[path] is not False: |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
133 time.sleep(0.025) |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
134 if (time.time()-st) > 120: |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
135 logger.general("Timeout: " + path) |
22
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
136 break |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
137 except: |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
138 del self.__fetching[path] |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
139 logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) |
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
140 component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>") |
22
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
141 return |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
142 self.__lock.acquire() |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
143 try: |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
144 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path])) |
76
37a11fea3304
More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents:
71
diff
changeset
|
145 component.debug('chat').InfoPost("<font color='#FF0000'>Adding Image to Queue from Cache: " + str(self.__cache[path]) + "</font>) |
22
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
146 self.__queue.put((self.__cache[path], image_type, imageId)) |
88cea66228d6
Should fix Image Chache problem, does not fix memory leak.
sirebral
parents:
20
diff
changeset
|
147 finally: self.__lock.release() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
148 |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
149 """Property Methods""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
150 def _getCache(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
151 return self.__cache |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
152 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
153 def _getQueue(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
154 return self.__queue |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
155 |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
156 """Properties""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
157 Cache = property(_getCache) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
158 Queue = property(_getQueue) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
159 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
160 ImageHandler = singleton(ImageHandlerClass) |