Index: apt.py
===================================================================
--- apt.py	(revision 1181)
+++ apt.py	(working copy)
@@ -36,6 +36,7 @@
 import hashlib
 import subprocess
 import shlex
+import locale 
 #@-<<imports>>
 #@+others
 #@+node:maphew.20100223163802.3718: ** usage
@@ -203,12 +204,13 @@
 
     # make sure we md5 the *file* not the *filename*
     # kudos to http://www.peterbe.com/plog/using-md5-to-check-equality-between-files
-    localFile = file(os.path.join(downloads, url), 'rb')
+    filename = os.path.join(downloads, url)
+    localFile = file(filename, 'rb')
     my_md5 = hashlib.md5(localFile.read()).hexdigest()
 
     print '%s  %s - local' % (my_md5, ball)
     if md5 != my_md5:
-        raise 'file md5 does not match for ' + ball
+        raise Exception('file md5 does not match for ' + filename)
 
 #@+node:maphew.20100223163802.3727: *3* missing
 def missing ():
@@ -422,7 +424,7 @@
     pipe.extractall()
     pipe.close()
     if pipe.close ():
-        raise 'urg'
+        raise Exception('urg')
 
    # record list of files installed
     write_filelist (lst)
@@ -451,7 +453,7 @@
             sys.stderr.write ('warning: %s no such file\n' % file)
         elif not os.path.isdir (file):
             if os.remove (file):
-                raise 'urg'
+                raise Exception('urg')
             else:
                 sys.stdout.write('removed: %s\n' % file)
 
@@ -483,7 +485,7 @@
     pipe = gzip.open (config + packagename + '.lst.gz', 'r')
     lst = map (string.strip, pipe.readlines ())
     if pipe.close ():
-        raise 'urg'
+        raise Exception('urg')
     return lst
 
 #@+node:maphew.20100223163802.3746: *3* get_installed
@@ -576,12 +578,12 @@
     # ''' Fetch paths of Windows special folders: Program Files, Desktop, Startmenu, etc. '''
     #Written by Luke Pinner, 2010. Code is public domain, do with it what you will...
     import ctypes
-    from ctypes.wintypes import HWND , HANDLE ,DWORD ,LPCWSTR ,MAX_PATH , create_unicode_buffer
+    from ctypes.wintypes import HWND, HANDLE, DWORD, LPCWSTR, MAX_PATH, create_unicode_buffer
     SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
     SHGetFolderPath.argtypes = [HWND, ctypes.c_int, HANDLE, DWORD, LPCWSTR]
     auPathBuffer = create_unicode_buffer(MAX_PATH)
     exit_code=SHGetFolderPath(0, intFolder, 0, 0, auPathBuffer)
-    return auPathBuffer.value
+    return auPathBuffer.value.encode( locale.getpreferredencoding() )
 
 #@+node:maphew.20100223163802.3756: *3* get_url
 def get_url ():
@@ -656,7 +658,7 @@
     for i in values:
         pipe.write (i)
     if pipe.close ():
-        raise 'urg'
+        raise Exception('urg')
 #@+node:maphew.20100223163802.3764: *3* write_installed
 def write_installed ():
     # ''' Record package in install.db '''
@@ -665,7 +667,7 @@
     file.writelines (map (lambda x: '%s %s 0\n' % (x, installed[0][x]),
                   installed[0].keys ()))
     if file.close ():
-        raise 'urg'
+        raise Exception('urg')
 
 #@+node:maphew.20100223163802.3766: *3* write_filelist
 def write_filelist (lst):
@@ -677,7 +679,7 @@
         pipe.write (i)
         pipe.write ('\n')
     if pipe.close ():
-        raise 'urg'
+        raise Exception('urg')
 #@+node:maphew.20100308085005.1382: ** Parsers
 #@+node:maphew.20100223163802.3754: *3* get_setup_ini
 def get_setup_ini ():
@@ -711,7 +713,7 @@
                       string.split (lines[j], ': ', 1))
             except:
                 print lines[j]
-                raise 'URG'
+                raise Exception('urg')
             if value[0] == '"' and value.find ('"', 1) == -1:
                 while 1:
                     j = j + 1
@@ -730,9 +732,9 @@
     # ''' Parse version number from package archive name ''' 
     # mc-4.6.0a-20030721-1.tar.bz2
     #m = re.match ('^([^.]*)-([0-9][^-/]*-[0-9][0-9]*)(.tar.bz2)?$', p)
-    m = re.match ('^([^.]*)-([0-9].*-[0-9][0-9]*)(.tar.bz2)?$', p)
+    m = re.match ('^([^.]*)-([0-9].*-[0-9][0-9]*)(-devel)?(.tar.bz2)?$', p)
     if not m:
-        print '\n\n*** Error parsing version numer from "%s"\n\n' % (p)
+        print '\n\n*** Error parsing version number from "%s"\n\n' % (p)
     return (m.group (1), string_to_version (m.group (2)))
 
 #@+node:maphew.20100223163802.3762: *3* string_to_version
@@ -851,20 +853,20 @@
     pipe = os.popen ('tar -C %s -xjvf %s' % (SRC, ball), 'r')
     lst = map (string.strip, pipe.readlines ())
     if pipe.close ():
-        raise 'urg1'
+        raise Exception('urg1')
     print ('%s/%s' % (SRC, packagename))
     if not os.path.exists ('%s/%s' % (SRC, packagename)):
-        raise 'urg2'
+        raise Exception('urg2')
 
 #@+node:maphew.20100223163802.3768: *3* do_build
 def do_build ():
     src = '%s/%s' % (SRC, packagename)
     if not os.path.exists (src):
-        raise 'urg'
+        raise Exception('urg')
 
     m = re.match ('^(.*)-([0-9]*)$', packagename)
     if not m:
-        raise 'urg'
+        raise Exception('urg')
     namever = m.group (1)
 
     package = split_ball (packagename)
