-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 Cron-job that dumps files required in the filesystem to make pggit work.
 import os
 import shutil
 import psycopg2
-import ConfigParser
-import urllib
+import configparser
+import urllib.parse
 import filecmp
 from util.LockFile import LockFile
 
             for key in sshkey.split("\n"):
                 f.write("command=\"%s %s\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n" % (self.conf.get("paths", "pggit"), userid, key))
         f.close()
-        os.chmod("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), 0600)
+        os.chmod("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), 0o600)
         os.rename("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), "%s/.ssh/authorized_keys" % self.conf.get("paths", "githome"))
 
     def dumprepos(self):
 
                 os.environ['GIT_DIR'] = repopath
                 if initialclone:
-                    print "Initializing git into %s (cloned repo %s)" % (name, initialclone)
+                    print("Initializing git into %s (cloned repo %s)" % (name, initialclone))
                     if initialclone.startswith('git://'):
                         # Just use the raw URL, expect approver to have validated it
                         oldrepo = initialclone
                         self.conf.get("paths", "githome"), name,
                     ))
                 else:
-                    print "Initializing new git repository %s" % name
+                    print("Initializing new git repository %s" % name)
                     os.system("git init --bare --shared")
                 del os.environ['GIT_DIR']
 
             # Check for publishing options here
             if web:
-                f.write("%s.git %s\n" % (urllib.quote_plus(name), urllib.quote_plus(owner)))
+                f.write("%s.git %s\n" % (urllib.parse.quote_plus(name), urllib.parse.quote_plus(owner)))
                 df = open("%s/description" % repopath, "w")
                 df.write(description)
                 df.close()
                 # Check if we need to change the tab width (default is 8)
-                repoconf = ConfigParser.ConfigParser()
+                repoconf = configparser.ConfigParser()
                 repoconf.readfp(TabRemover("%s/config" % repopath))
                 tabwidth_mod = False
                 if repoconf.has_option('gitweb', 'tabwidth'):
                     os.remove(anonfile)
 
         f.close()
-        os.chmod("%s.tmp" % self.conf.get("paths", "gitweblist"), 0644)
+        os.chmod("%s.tmp" % self.conf.get("paths", "gitweblist"), 0o644)
         os.rename("%s.tmp" % self.conf.get("paths", "gitweblist"), self.conf.get("paths", "gitweblist"))
 
         accessfile.write(")\n")
         if not dl:
             # Nothing in there, perhaps we need to remove it?
             if relativepath != '/':
-                print "Removing container directory %s" % rootpath
+                print("Removing container directory %s" % rootpath)
                 try:
                     os.rmdir("%s" % rootpath)
-                except Exception, e:
-                    print "FAIL: unable to remove container directory: %s" % e
+                except Exception as e:
+                    print("FAIL: unable to remove container directory: %s" % e)
                 return
 
         for d in dl:
                 # be here.
                 d = d[:-4]
                 if os.path.join(relativepath, d)[1:] not in allrepos:
-                    print "Removing repository %s" % os.path.join(relativepath, d)
+                    print("Removing repository %s" % os.path.join(relativepath, d))
                     try:
                         shutil.rmtree("%s.git" % os.path.join(rootpath, d))
-                    except Exception, e:
-                        print "FAIL: unable to remove directory: %s" % e
+                    except Exception as e:
+                        print("FAIL: unable to remove directory: %s" % e)
 
 
 if __name__ == "__main__":
-    c = ConfigParser.ConfigParser()
+    c = configparser.ConfigParser()
     c.read("pggit.settings")
     lock = LockFile("%s/repos/.gitdump_interlock" % c.get("paths", "githome"))
     db = psycopg2.connect(c.get('database', 'db'))
 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 Hook to be called when attempting to access the git repository through
 import os.path
 import psycopg2
 import subprocess
-import ConfigParser
+import configparser
 from datetime import datetime
 
 ALLOWED_COMMANDS = ('git-upload-pack', 'git-receive-pack')
                 mod = __import__(modname)
                 c = getattr(mod, classname)
                 self.pushtrigger = c(self.cfg)
-            except Exception, e:
+            except Exception as e:
                 raise InternalException("Failed to load push trigger class: %s" % e)
         else:
             self.pushtrigger = None
                 if self.command in WRITE_COMMANDS:
                     self.pushtrigger.pushtrigger(self.subpath, self.user)
 
-        except InternalException, e:
+        except InternalException as e:
             try:
                 self.logger.log(e)
-            except Exception, e:
+            except Exception as e:
                 pass
             sys.stderr.write("%s\n" % e)
             sys.exit(1)
-        except Exception, e:
+        except Exception as e:
             try:
                 self.logger.log(e)
-            except Exception, e:
+            except Exception as e:
                 # If we failed to log, try once more with a new logger, otherwise,
                 # just accept that we failed.
                 try:
 
 
 if __name__ == "__main__":
-    c = ConfigParser.ConfigParser()
+    c = configparser.ConfigParser()
     c.read("%s/pggit.settings" % os.path.abspath(sys.path[0]))
     PgGit(c).run()
 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # vim: ai ts=4 sts=4 sw=4
 
 """
 import os
 import shutil
 import psycopg2
-import ConfigParser
+import configparser
 from util.LockFile import LockFile
 
 
 """)
         for id, name, repotype, remoteurl, remotemodule, lastsynced in curs:
             if name.find('/') > 0:
-                print "Subdirectories not supported when synchronizing"
+                print("Subdirectories not supported when synchronizing")
                 continue
             s = SyncMethod.get(repotype)
             s.init(self.conf, name, remoteurl, remotemodule)
 
 
 if __name__ == "__main__":
-    c = ConfigParser.ConfigParser()
+    c = configparser.ConfigParser()
     c.read("pggit.settings")
     lock = LockFile("%s/repos/.reposync_interlock" % c.get("paths", "githome"))
     db = psycopg2.connect(c.get('database', 'db'))