Index: /branches/0.4/jobarchived/jobarchived.py
===================================================================
--- /branches/0.4/jobarchived/jobarchived.py	(revision 772)
+++ /branches/0.4/jobarchived/jobarchived.py	(revision 773)
@@ -48,8 +48,8 @@
 def processArgs( args ):
 
-        SHORT_L    = 'p:hvc:'
-        LONG_L    = [ 'help', 'config=', 'pidfile=', 'version' ]
-
-        config_filename = '/etc/jobarchived.conf'
+    SHORT_L    = 'p:hvc:'
+    LONG_L    = [ 'help', 'config=', 'pidfile=', 'version' ]
+
+    config_filename = '/etc/jobarchived.conf'
 
     global PIDFILE
@@ -57,18 +57,18 @@
     PIDFILE    = None
 
-        try:
-
-                opts, args = getopt.getopt( args, SHORT_L, LONG_L )
-
-        except getopt.error, detail:
-
-                print detail
-                sys.exit(1)
-
-        for opt, value in opts:
-
-                if opt in [ '--config', '-c' ]:
-
-                        config_filename = value
+    try:
+
+        opts, args = getopt.getopt( args, SHORT_L, LONG_L )
+
+    except getopt.error, detail:
+
+        print detail
+        sys.exit(1)
+
+    for opt, value in opts:
+
+        if opt in [ '--config', '-c' ]:
+
+            config_filename = value
 
         if opt in [ '--pidfile', '-p' ]:
@@ -175,5 +175,5 @@
     ARCHIVE_XMLSOURCE    = cfg.get( 'DEFAULT', 'ARCHIVE_XMLSOURCE' )
 
-        ARCHIVE_DATASOURCES    = getlist( cfg.get( 'DEFAULT', 'ARCHIVE_DATASOURCES' ) )
+    ARCHIVE_DATASOURCES    = getlist( cfg.get( 'DEFAULT', 'ARCHIVE_DATASOURCES' ) )
 
     ARCHIVE_EXCLUDE_METRICS    = getlist( cfg.get( 'DEFAULT', 'ARCHIVE_EXCLUDE_METRICS' ) )
@@ -209,21 +209,10 @@
 
 try:
-    from pyPgSQL import PgSQL
+    import psycopg2
 
 except ImportError, details:
 
-    print "FATAL ERROR: pyPgSQL python module not found"
+    print "FATAL ERROR: psycopg2 python module not found"
     sys.exit( 1 )
-
-# Orginal from Andre van der Vlies <andre@vandervlies.xs4all.nl> for MySQL. Changed
-# and added some more functions for postgres.
-#       
-#
-# Changed by: Bas van der Vlies <basv@sara.nl>
-#       
-# SARA API for Postgres Database
-#
-# Changed by: Ramon Bastiaans for Job Monarch
-#
 
 class InitVars:
@@ -274,81 +263,81 @@
 #
 class DB:
-        def __init__(self, db_vars):
-
-                self.dict = db_vars
-
-                if self.dict.has_key('User'):
-                        self.user = self.dict['User']
-                else:
-                        self.user = 'postgres'
-
-                if self.dict.has_key('Host'):
-                        self.host = self.dict['Host']
-                else:
-                        self.host = 'localhost'
-
-                if self.dict.has_key('Password'):
-                        self.passwd = self.dict['Password']
-                else:
-                        self.passwd = ''
-
-                if self.dict.has_key('DataBaseName'):
-                        self.db = self.dict['DataBaseName']
-                else:
-                        self.db = 'uva_cluster_db'
-
-                # connect_string = 'host:port:database:user:password:
-                dsn = "%s::%s:%s:%s" %(self.host, self.db, self.user, self.passwd)
-
-                try:
-                        self.SQL = PgSQL.connect(dsn)
-                except PgSQL.Error, details:
-                        str = "%s" %details
-                        raise DBError(str)
-
-        def __repr__(self):
-                return repr(self.result)
-
-        def __nonzero__(self):
-                return not(self.result == None)
-
-        def __len__(self):
-                return len(self.result)
-
-        def __getitem__(self,i):
-                return self.result[i]
-
-        def __getslice__(self,i,j):
-                return self.result[i:j]
-
-        def Get(self, q_str):
-                c = self.SQL.cursor()
-                try:
-                        c.execute(q_str)
-                        result = c.fetchall()
-                except PgSQL.Error, details:
-                        c.close()
-                        str = "%s" %details
-                        raise DBError(str)
-
-                c.close()
-                return result
-
-        def Set(self, q_str):
-                c = self.SQL.cursor()
-                try:
-                        c.execute(q_str)
-                        result = c.oidValue
-
-                except PgSQL.Error, details:
-                        c.close()
-                        str = "%s" %details
-                        raise DBError(str)
-
-                c.close()
-                return result
-
-        def Commit(self):
-                self.SQL.commit()
+    def __init__(self, db_vars):
+
+        self.dict = db_vars
+
+        if self.dict.has_key('User'):
+            self.user = self.dict['User']
+        else:
+            self.user = 'postgres'
+
+        if self.dict.has_key('Host'):
+            self.host = self.dict['Host']
+        else:
+            self.host = 'localhost'
+
+        if self.dict.has_key('Password'):
+            self.passwd = self.dict['Password']
+        else:
+            self.passwd = ''
+
+        if self.dict.has_key('DataBaseName'):
+            self.db = self.dict['DataBaseName']
+        else:
+            self.db = 'jobarchive'
+
+        # connect_string = 'host:port:database:user:password:
+        dsn = "host='%s' dbname='%s' user='%s' password='%s'" %(self.host, self.db, self.user, self.passwd)
+
+        try:
+            self.SQL = psycopg2.connect(dsn)
+        except psycopg2.Error, details:
+            str = "%s" %details
+            raise DBError(str)
+
+    def __repr__(self):
+        return repr(self.result)
+
+    def __nonzero__(self):
+        return not(self.result == None)
+
+    def __len__(self):
+        return len(self.result)
+
+    def __getitem__(self,i):
+        return self.result[i]
+
+    def __getslice__(self,i,j):
+        return self.result[i:j]
+
+    def Get(self, q_str):
+        c = self.SQL.cursor()
+        try:
+            c.execute(q_str)
+            result = c.fetchall()
+        except psycopg2.Error, details:
+            c.close()
+            str = "%s" %details
+            raise DBError(str)
+
+        c.close()
+        return result
+
+    def Set(self, q_str):
+        c = self.SQL.cursor()
+        try:
+            c.execute(q_str)
+            result = c.oidValue
+
+        except psycopg2.Error, details:
+            c.close()
+            str = "%s" %details
+            raise DBError(str)
+
+        c.close()
+        return result
+
+    def Commit(self):
+        self.SQL.commit()
 
 class DataSQLStore:
@@ -1186,14 +1175,14 @@
                 continue
 
-                try:
+            try:
 
                 self.s.connect( sa )
 
-                except ( socket.error, socket.gaierror, socket.herror, socket.timeout ), msg:
+            except ( socket.error, socket.gaierror, socket.herror, socket.timeout ), msg:
 
                 self.disconnect()
                 continue
 
-                break
+            break
 
         if self.s is None:
@@ -1207,10 +1196,10 @@
 
             my_fp            = self.s.makefile( 'r' )
-            my_data            = my_fp.readlines()
-            my_data            = string.join( my_data, '' )
+            my_data          = my_fp.readlines()
+            my_data          = string.join( my_data, '' )
 
             self.data        = my_data
 
-            self.LAST_UPDATE    = time.time()
+            self.LAST_UPDATE = time.time()
 
         self.slot.release()
