Index: src/mlx/update.py
===================================================================
--- src/mlx/update.py	(revision 788)
+++ src/mlx/update.py	(revision 919)
@@ -1,9 +1,9 @@
 
-from config import Config
-from util import utf2unicode
+from .config import Config
+from .util import utf2unicode
 
 import os
 import sys
-import urllib2
+import urllib.request, urllib.error, urllib.parse
 import tempfile
 import socket
@@ -57,5 +57,5 @@
 
         Each file is returned as a 3-tuple with items as in the file."""
-        for (path, (size, sum)) in self._files.iteritems():
+        for (path, (size, sum)) in self._files.items():
             yield (path, size, sum)
 
@@ -99,5 +99,5 @@
     def writeInto(self, file):
         """Write the manifest into the file at the given path."""
-        for (path, (size, sum)) in self._files.iteritems():
+        for (path, (size, sum)) in self._files.items():
             file.write("%s\t%d\t%s\n" % (path, size, sum))
 
@@ -207,6 +207,6 @@
         with open(manifestPath, "rt") as f:
             manifest.readFrom(f)
-    except Exception, e:
-        print "Error reading the manifest, ignoring:", utf2unicode(str(e))
+    except Exception as e:
+        print("Error reading the manifest, ignoring:", utf2unicode(str(e)))
         manifest = Manifest()
 
@@ -226,10 +226,10 @@
     try:
         updateManifest = Manifest()
-        f= urllib2.urlopen(updateURL + "/" + manifestName)
+        f= urllib.request.urlopen(updateURL + "/" + manifestName)
         updateManifest.readFrom(f)
 
-    except Exception, e:
+    except Exception as e:
         error = utf2unicode(str(e))
-        print >> sys.stderr, "Error downloading manifest:", error
+        print("Error downloading manifest:", error, file=sys.stderr)
         listener.failed(error)
         return None
@@ -298,6 +298,6 @@
                 pass
             os.rename(path, targetPath)
-        except Exception, e:
-            print "Cannot remove file " + path + ": " + utf2unicode(str(e))
+        except Exception as e:
+            print("Cannot remove file " + path + ": " + utf2unicode(str(e)))
 
 #------------------------------------------------------------------------------
@@ -359,5 +359,5 @@
                 
             with open(targetFile, "wb") as fout:
-                fin = urllib2.urlopen(updateURL + "/" + path)
+                fin = urllib.request.urlopen(updateURL + "/" + path)
                 while True:
                     data = fin.read(4096)
@@ -391,10 +391,10 @@
         
         listener.done()
-    except Exception, e:
+    except Exception as e:
         exc = traceback.format_exc()
-        print >> sys.stderr, utf2unicode(exc)
+        print(utf2unicode(exc), file=sys.stderr)
         
         error = utf2unicode(str(e))
-        print >> sys.stderr, "Error:", error
+        print("Error:", error, file=sys.stderr)
 
         listener.failed(error)
@@ -409,5 +409,5 @@
         f.close()
         return True
-    except Exception, e:
+    except Exception as e:
         return False
     finally:
@@ -439,8 +439,8 @@
                 listener.downloadedManifest()
             elif command=="setTotalSize":
-                listener.setTotalSize(int(words[1]), long(words[2]),
+                listener.setTotalSize(int(words[1]), int(words[2]),
                                       int(words[3]), int(words[4]))
             elif command=="setDownloaded":
-                listener.setDownloaded(long(words[1]))
+                listener.setDownloaded(int(words[1]))
             elif command=="startRenaming":
                 listener.startRenaming()
@@ -457,7 +457,7 @@
             elif command=="failed":
                 listener.failed(words[1])
-        except Exception, e:
-            print >> sys.stderr, "Failed to parse line '%s': %s" % \
-                  (line, utf2unicode(str(e)))
+        except Exception as e:
+            print("Failed to parse line '%s': %s" % \
+                  (line, utf2unicode(str(e))), file=sys.stderr)
 
     return buffer
@@ -514,7 +514,7 @@
             process.wait()
         
-    except Exception, e:
+    except Exception as e:
         error = utf2unicode(str(e))
-        print >> sys.stderr, "Failed updating:", error
+        print("Failed updating:", error, file=sys.stderr)
         listener.failed(error)
     finally:
@@ -563,10 +563,10 @@
             updateFiles(directory, updateURL, listener, updateManifest,
                         modifiedAndNew, removed, localRemoved)
-    except Exception, e:
+    except Exception as e:
         exc = traceback.format_exc()
-        print >> sys.stderr, utf2unicode(exc)
+        print(utf2unicode(exc), file=sys.stderr)
         
         error = utf2unicode(str(e))
-        print >> sys.stderr, "Update error:", error
+        print("Update error:", error, file=sys.stderr)
         
         listener.failed(error)
@@ -596,5 +596,5 @@
     except:
         exc = traceback.format_exc()
-        print >> sys.stderr, utf2unicode(exc)
+        print(utf2unicode(exc), file=sys.stderr)
 
 #------------------------------------------------------------------------------
