IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 16, 2012, 3:33:46 PM (14 years ago)
Author:
rhenders
Message:

lots of new methods to deal with clients table, inserting a new client, removing a client checking whether paused or killed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/ipptopspsdb.py

    r33266 r33293  
    717717
    718718    '''
     719    Remove client
     720    '''
     721    def removeClient(self, host, pid):
     722        self.execute("DELETE FROM clients WHERE host = '" + host + "' AND pid = " + str(pid))
     723
     724    '''
     725    Insert client
     726    '''
     727    def insertClient(self, host, pid):
     728        self.execute("INSERT INTO clients (timestamp, host, pid) VALUES (now(), '" + host + "', " + str(pid) + ")")
     729
     730    '''
     731    Update clients, or inserts it for the first time
     732    '''
     733    def updateClient(self, host, pid):
     734
     735        try:
     736            self.insertClient(host, pid)
     737        except:
     738            self.execute("UPDATE clients SET timestamp = now() WHERE host = '" + host + "' AND pid = " + str(pid))
     739
     740    '''
     741    Is this client paused?
     742    '''
     743    def isPaused(self, host, pid):
     744        return self.getClientsColumnBoolean("paused", host, pid)
     745
     746    '''
     747    Is this client killed?
     748    '''
     749    def isKilled(self, host, pid):
     750        return self.getClientsColumnBoolean("killed", host, pid)
     751
     752    '''
     753    Returns boolean value for this column in clients table
     754    '''
     755    def getClientsColumnBoolean(self, col, host, pid):
     756
     757        sql = "SELECT " + col + " \
     758               FROM clients \
     759               WHERE host = '" + host + "' AND pid = " + str(pid)
     760
     761        try:
     762            rs = self.executeQuery(sql)
     763            rs.first()
     764            if rs.getInt(1) == 1: return True
     765            else: return False
     766        except:
     767            self.logger.exception("Unable to check whether " + col + " is true or false in clients table")
     768
     769        return False
     770
     771
     772    '''
    719773    Destructor
    720774    '''
Note: See TracChangeset for help on using the changeset viewer.