IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33517 for trunk


Ignore:
Timestamp:
Mar 13, 2012, 4:25:53 PM (14 years ago)
Author:
rhenders
Message:

added method to get info from client table; added method to remove client by id; pause and kill methods now accept a range of client IDs

File:
1 edited

Legend:

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

    r33490 r33517  
    724724
    725725    '''
    726     Pause all loading clients
    727     '''
    728     def pauseAllLoaders(self, bool):
    729         self.setColForAllLoaders("paused", bool)
    730 
    731     '''
    732     Kill all loading clients
    733     '''
    734     def killAllLoaders(self, bool):
    735         self.setColForAllLoaders("killed", bool)
     726    Pause loading clients
     727    '''
     728    def pauseLoaders(self, bool, ids):
     729        self.setColForLoaders("paused", bool, ids)
     730
     731    '''
     732    Kill loading clients
     733    '''
     734    def killLoaders(self, bool, ids):
     735        self.setColForLoaders("killed", bool, ids)
    736736
    737737    '''
    738738    Sets the value for a given column in the clients table
    739739    '''
    740     def setColForAllLoaders(self, col, bool):
     740    def setColForLoaders(self, col, bool, ids):
     741
    741742        if bool: value = 1
    742743        else: value = 0
    743         self.execute("UPDATE clients SET " + col + " = " + str(value) + " WHERE type = 'loader.py' AND config = '" + self.config.name + "'")
     744
     745        for id in ids:
     746            self.execute("UPDATE clients SET " + col + " = " + str(value) + " \
     747                    WHERE type = 'loader.py' \
     748                    AND id = " + str(id))
     749
     750    '''
     751    Remove client by id
     752    '''
     753    def removeClientsByIds(self, ids):
     754        for id in ids:
     755            self.execute("DELETE FROM clients WHERE id = " + str(id))
    744756
    745757    '''
     
    9961008               WHERE ra_center = " + str(raCenter) + " \
    9971009               AND batch_type = '" + batchType + "' \
    998                AND config = '" + self.config.name + "'"
     1010               AND config = '" + self.config.name + "' \
     1011               ORDER BY dec_center DESC"
    9991012
    10001013        try:
     
    11871200
    11881201    '''
     1202    Gets client info
     1203    '''
     1204    def getClientInfo(self):
     1205
     1206        sql = "SELECT id, host, started, timestamp, ra_center, paused, killed \
     1207               FROM stripe \
     1208               JOIN clients ON (client_id = id) \
     1209               WHERE clients.config = '" + self.config.name + "' \
     1210               ORDER BY host, started"
     1211
     1212        rows = []
     1213        try:
     1214            rs = self.executeQuery(sql)
     1215            while (rs.next()):
     1216                rows.append([rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getFloat(5), rs.getInt(6), rs.getInt(7)])
     1217            rs.close()
     1218        except:
     1219            self.logger.errorPair("Can't query for client data", sql)
     1220
     1221        return rows
     1222
     1223    '''
    11891224    Destructor
    11901225    '''
Note: See TracChangeset for help on using the changeset viewer.