]> code.delx.au - pymsnt/blobdiff - src/avatar.py
Catch a few more possible exceptions
[pymsnt] / src / avatar.py
index d8d1a4c4b978c51c6e12092b0477276987a7c2b3..b9f7dfc900eeb313a9a698edf7934748486b8fbd 100644 (file)
@@ -1,10 +1,10 @@
-# Copyright 2005 James Bunton <james@delx.cjb.net>
+# Copyright 2005-2006 James Bunton <james@delx.cjb.net>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
 from debug import LogEvent, INFO, WARN, ERROR
 
 from twisted.internet import reactor
-from tlib.xmlw import Element
+from twisted.words.xish.domish import Element
 
 import sha, base64, os, os.path
 
@@ -73,7 +73,7 @@ class AvatarCache:
                """ Returns the full path to the directory that a 
                particular key is in. Creates that directory if it doesn't already exist. """
                X = os.path.sep
-               d = os.path.os.path.abspath(config.spooldir) + X + config.jid + X + "avatars" + X + key[0:3] + X 
+               d = os.path.os.path.abspath(config.spooldir) + X + "avatars" + X + key[0:3] + X 
                if not os.path.exists(d):
                        os.makedirs(d)
                return d
@@ -89,7 +89,7 @@ class AvatarCache:
                        f = open(self.dir(key) + key, 'wb')
                        f.write(imageData)
                        f.close()
-               except IOError, e:
+               except (OSError, IOError), e:
                        LogEvent(WARN, "", "IOError writing to avatar %s - %s" % (key, str(e)))
                os.umask(prev_umask)
                return avatar
@@ -114,7 +114,7 @@ class AvatarCache:
                                return data
                        else:
                                LogEvent(INFO, "", "Avatar not found.")
-               except IOError:
+               except (OSError, IOError):
                        LogEvent(WARN, "", "IOError reading avatar.")
                else:
                        return None