Oi,

I tried the new imdb-module yesterday, which is really nice, and got some small 
problems/crash which normally wont show. 

At first the resolv.conf was corrupt so the domain imd.com couldn't be found -> crash, 

and after that I forgot that the disks was nfs-mountad as readonly and the image & fxd 
file couldnt be written -> crash

This patch avoids the crashes which we don't fancy.





Then I wonder if the:

<file id="p1">filepath</file>

needs to be a absolutepath?



My problem is that I use two Freevos where the files have different nfs-mount-paths, 
and to avoid strange behavious I have set this path to the relative:

<file id="p1">file</file> 

and this works for me.

Since the imdb.py creates a fxd in the same directory as the movies wouldn't it be 
better if this path is relative?



// Bj�rn
--- imdb.py     Wed Jun 25 12:55:26 2003
+++ imdb.py.bugfix      Wed Jun 25 12:54:04 2003
@@ -63,11 +63,18 @@
 
     conn = httplib.HTTPConnection("www.imdb.com")
     headers = { 'User-Agent': 'freevo %s (%s)' % (freevo_version, sys.platform) }
-
     results = []
     params = urllib.urlencode({'title': name, 'restrict': 'Movies and TV'})
 
-    conn.request("GET", '/Tsearch?%s' % params, params, headers)
+    try:
+        conn.request("GET", '/Tsearch?%s' % params, params, headers)
+    except httplib.socket.gaierror, msg:
+        print 'Unable to connect to host: %s' % msg
+        return results
+    except httplib.socket.error, msg:
+        print 'Connection refused: %s' % msg
+        return results
+
     response = conn.getresponse()
 
     if response.status == 302 and response.getheader('Location', ''):
@@ -162,7 +169,15 @@
     # Get and parse the information from the site
     #
     
-    conn.request("GET", "/Title?"+id, "", headers)
+    try:
+        conn.request("GET", "/Title?"+id, "", headers)
+    except httplib.socket.gaierror, msg:
+        print 'Unable to connect to host: %s' % msg
+        return None
+    except httplib.socket.error, msg:
+        print 'Connection refused: %s' % msg
+        return None
+
     r = conn.getresponse()
     if r.status != 200:
         print r.status
@@ -213,7 +228,15 @@
         if m: image_urls += [ m.group(1) ]
 
     if dvd:
-        conn.request("GET", "/DVD?"+id, "", headers)
+        try:
+            conn.request("GET", "/DVD?"+id, "", headers)
+        except httplib.socket.gaierror, msg:
+            print 'Unable to connect to host: %s' % msg
+            return None
+        except httplib.socket.error, msg:
+            print 'Connection refused: %s' % msg
+            return None
+
         r = conn.getresponse()
         if r.status != 200:
             print r.status
@@ -245,12 +268,27 @@
 
     conn = httplib.HTTPConnection(url[0])
     headers = { 'User-Agent': 'freevo %s (%s)' % (freevo_version, sys.platform) }
-    conn.request("GET", "/"+url[1], "", headers)
+
+    try:
+        conn.request("GET", "/"+url[1], "", headers)
+    except httplib.socket.gaierror, msg:
+        print 'Unable to connect to host: %s' % msg
+        return None
+    except httplib.socket.error, msg:
+        print 'Connection refused: %s' % msg
+        return None
+
     r = conn.getresponse()
     if r.status == 200:
-        i = open(filename, 'w')
-        i.write(r.read())
-        i.close()
+        try:
+            i = open(filename, 'w')
+            i.write(r.read())
+            i.close()
+        except IOError:
+            print "Writing image failed"
+            conn.close()
+            return None
+
         conn.close()
 
         # try to crop the image to avoid borders by imdb
@@ -318,7 +357,12 @@
 
     title, info, None = imdb_data
     
-    i = codecs.open('%s.fxd' % filename, 'w', encoding='utf-8')
+    try:
+        i = codecs.open('%s.fxd' % filename, 'w', encoding='utf-8')
+    except IOError:
+        print "Writing .fxd failed"
+        return 
+
     i.write("<?xml version=\"1.0\" ?>\n<freevo>\n")
     i.write("  <copyright>\n" +
             "    The information in this file are from the Internet " +

Reply via email to