예제 #1
0
파일: libProduct.py 프로젝트: testkalos/gmp
 def __init__(self,init='#'):
     if init=='#':
         print "product ID is missing"
         return
     self.productid=init
     self.db=dbif.gencur()
     self.getProduct(init)
     pass
예제 #2
0
파일: libQueue.py 프로젝트: testkalos/gmp
    def __init__(self, itemID, closeStatus='#'):
        self.db = dbif.gencur("select 'none';")
        qry = "SELECT ID, STATUS, pid, agentid, targetid, note, LAST_UPDATE FROM queue where ID='%s';" % itemID
        self.db.cur.execute(qry)
        rec = self.db.cur.fetchone()
        if rec == None:
            #no record found
            self.id = "#"
            return
        self.id = rec[0]
        self.status = rec[1]
        self.pid = rec[2]
        self.agentid = rec[3]
        self.targetid = rec[4]
        self.note = rec[5]
        try:
            self.note = json.loads(self.note)
        except:
            pass
        self.last_update = rec[6]
        self.closeStatus = closeStatus
        self.emergencyDataset = "#"

        #Get the target characteristic
        self.connection = dbif.getTargetList("id='%s'" % self.targetid)[0]
        self.targettype = self.connection['type']
        self.rep = self.connection['rep'].replace('$PRJ', prjFolder)
        self.fullpath = self.rep + os.sep + self.id

        #Get the download agent characteristic
        qry = "SELECT ID, cli FROM agent where id='%s';" % self.agentid
        self.db.cur.execute(qry)
        rec = self.db.cur.fetchone()
        if rec != None:
            self.agentcli = rec[1]
        else:
            self.agentcli = "ERROR: Agent CLI not found!"

        #Get the list of files to be downloaded
        qry = "SELECT ID, filename, url, dwnstatus FROM files where qid='%s';" % itemID
        self.db.cur.execute(qry)
        rec = self.db.cur.fetchall()
        if rec == None:
            #no record found
            return
        self.files = list()
        for i in rec:
            x = dict()
            x['fileid'] = i[0]
            x['filename'] = i[1]
            x['url'] = i[2]
            x['dwnstatus'] = i[3]
            self.files.append(x)

        #Get the product characteristic
        self.product = libProduct.product(itemID)

        return
예제 #3
0
def comparedb(x):
    wkt=x.coordinatesWKT
    qry="SELECT id,`name`, AsText(geom) FROM country WHERE MBRContains(GeomFromText('%s'),geom);" % wkt
    db=dbif.gencur(qry)
    res=db.cur.fetchall()
    #print len(res)
    #import pprint
    #pprint.pprint(res)
    for icountry in res:
        print "adding tag %s" % icountry[1]
        x.addTag(icountry[1])
예제 #4
0
파일: libProduct.py 프로젝트: testkalos/gmp
 def catalogue(self):
     wkt=self.footprint
     qry="SELECT DISTINCT id,`name`, AsText(geom) FROM area WHERE MBRContains(GeomFromText('%s'),geom);" % wkt
     db=dbif.gencur(qry)
     res=db.cur.fetchall()
     for icountry in res:
         print "adding tag %s" % icountry[1]
         try:
             self.addTag(icountry[1])
         except:
             print "ERROR: Failed to add tag %s" % icountry[1]
             traceback.print_exc(file=sys.stdout)
예제 #5
0
def main():
    db = dbif.gencur('SELECT * FROM queue')
    for isql in sql:
        out = isql.strip().replace('\n', ' ')[:50]
        start = datetime.datetime.now()
        try:
            db.exe(isql)
            out += ' OK'
        except:
            out += ' ERROR'
        duration = datetime.datetime.now() - start
        print out + ' (%s sec)' % duration.seconds
    pass
예제 #6
0
파일: dbcron.py 프로젝트: SercoSPA/gmp
def main():
    db=dbif.gencur('SELECT * FROM queue')
    for isql in sql:
        out=isql.strip().replace('\n',' ')[:50]
        start = datetime.datetime.now()
        try:
            db.exe(isql)
            out+= ' OK'
        except:
            out+= ' ERROR'
        duration = datetime.datetime.now() - start
        print out + ' (%s sec)' % duration.seconds
    pass
예제 #7
0
파일: libQueue.py 프로젝트: testkalos/gmp
 def getqueue(self):
     self.db = dbif.gencur('SELECT * FROM queue limit 1;')