annotate orpg/mapper/images.py @ 112:61fc775862f7 alpha

Traipse Alpha 'OpenRPG' {091009-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: {091006} 00: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! 03: Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. {091008} 00: Fix to remote admin commands 01: Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! {091009} 00: Fix to Splitter Nodes not being created. Plugin Control panel works with images now Fix to massive amounts of images loading; from Core
author sirebral
date Fri, 09 Oct 2009 23:26:21 -0500
parents a647e0e8f520
children 217fb049bd00
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 #
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
28 from __future__ import with_statement
0
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
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
35 from orpg.orpg_wx import *
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
36 from orpg.orpgCore import *
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
37
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 22
diff changeset
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
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
40 from orpg.tools.orpg_settings import settings
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42 class ImageHandlerClass(object):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
43 __cache = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
44 __fetching = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 __queue = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46 __lock = Lock()
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
47
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
48 def __new__(cls):
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
49 it = cls.__dict__.get("__it__")
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
50 if it is not None:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
51 return it
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
52 cls.__it__ = it = object.__new__(cls)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
53 return it
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 def load(self, path, image_type, imageId):
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
56 # Load an image, with a intermideary fetching image shown while it loads in a background thread
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
57 if self.__cache.has_key(path):
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
58 return wx.ImageFromMime(self.__cache[path][1],
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
59 self.__cache[path][2]).ConvertToBitmap()
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
60 if path not in self.__fetching:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 self.__fetching[path] = True
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
62 #Start Image Loading Thread
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
63 thread.start_new_thread(self.__loadThread,
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
64 (path, image_type, imageId))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 else:
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
66 if self.__fetching[path]:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
67 thread.start_new_thread(self.__loadCacheThread,
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
68 (path, image_type, imageId))
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
69 return wx.Bitmap(dir_struct["icon"] + "fetching.png",
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
70 wx.BITMAP_TYPE_PNG)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 def directLoad(self, path):
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
73 # Directly load an image, no threads
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
74 if path in self.__cache:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
75 return wx.ImageFromMime(self.__cache[path][1],
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
76 self.__cache[path][2]).ConvertToBitmap()
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
77
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 uriPath = urllib.unquote(path)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 d = urllib.urlretrieve(uriPath)
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
81 # We have to make sure that not only did we fetch something, but that
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
82 # 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
83 if d[0] and d[1].getmaintype() == "image":
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
84 with self.__lock:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
85 self.__cache[path] = (path, d[0], d[1].gettype(), None)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
86 return wx.ImageFromMime(self.__cache[path][1],
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
87 self.__cache[path][2]).ConvertToBitmap()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 else:
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
89 logger.general("Image refused to load or URI did not "
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
90 "reference a valid image: " + path, True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 except IOError:
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
93 logger.general("Unable to resolve/open the specified URI; "
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
94 "image was NOT loaded: " + path, True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 return None
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 cleanCache(self):
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
98 # Shrinks the Cache down to the proper size
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
99 try:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
100 cacheSize = int(settings.get("ImageCacheSize"))
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
101 except:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
102 cacheSize = 32
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 cache = self.__cache.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 cache.sort()
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
105 for key in cache[cacheSize:]:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
106 del self.__cache[key]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 def flushCache(self):
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
109 # This function will flush all images contained within the image cache.
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
110 with self.__lock:
88
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 77
diff changeset
111 self.__cache = {}
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 77
diff changeset
112 self.__fetching = {}
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 77
diff changeset
113 urllib.urlcleanup()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
115 #Private Methods
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116 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
117 uriPath = urllib.unquote(path)
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
118
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
119 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 d = urllib.urlretrieve(uriPath)
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
121 # We have to make sure that not only did we fetch something, but that
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
122 # 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
123 if d[0] and d[1].getmaintype() == "image":
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
124 with self.__lock:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
125 self.__cache[path] = (path, d[0], d[1].gettype(), imageId)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
126 self.__queue.put((self.__cache[path], image_type, imageId))
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
127
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
128 if path in self.__fetching:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
129 del self.__fetching[path]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130 else:
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
131 logger.general("Image refused to load or URI did not "
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
132 "reference a valid image: " + path, True)
15
cab94a90f9dc Added 1.8.0 fix to log. Fixed problem with images that do not load the first
sirebral
parents: 3
diff changeset
133 del self.__fetching[path]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134 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
135 del self.__fetching[path]
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
136 logger.general("Unable to resolve/open the specified URI; "
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
137 "image was NOT laoded: " + path, True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
138
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139 def __loadCacheThread(self, path, image_type, imageId):
99
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
140 try:
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
141 st = time.time()
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
142 while path in self.__fetching and self.__fetching[path] is not False:
99
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
143 time.sleep(0.025)
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
144 if (time.time()-st) > 120:
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
145 logger.general("Timeout: " + path, True)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
146 del self.__fetching[path]
99
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
147 break
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
148 except:
a647e0e8f520 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 88
diff changeset
149 del self.__fetching[path]
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
150 logger.general("Unable to resolve/open the specified URI; "
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
151 "image was NOT loaded: " + path, True)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
152 return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
154 with self.__lock:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
155 if path in self.__cache:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
156 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path]))
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
157 self.__queue.put((self.__cache[path], image_type, imageId))
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
158 else:
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
159 self.__loadThread(path, image_type, imageId)
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
160
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
161 #Property Methods
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
162 def _getCache(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 return self.__cache
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 def _getQueue(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 return self.__queue
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
168 #Properties
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 Cache = property(_getCache)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 Queue = property(_getQueue)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171
112
61fc775862f7 Traipse Alpha 'OpenRPG' {091009-00}
sirebral
parents: 99
diff changeset
172 ImageHandler = ImageHandlerClass()