示例#1
0
def getobjlist(searchType, object1, object2, num2ret):
    query1 = setquery('getsortableobjno','','')

    if int(num2ret) > 1000: num2ret = 1000
    if int(num2ret) < 1:    num2ret = 1

    cursor.execute(query1 % object1)
    (object1, sortkey1) = cursor.fetchone()
    cursor.execute(query1 % object2)
    (object2, sortkey2) = cursor.fetchone()

    # 'set' means 'next num2ret objects', otherwise prefix match
    if searchType == 'set':
        whereclause = "WHERE sortableobjectnumber >= '" + sortkey1 + "'"
    elif searchType == 'prefix':
        whereclause = "WHERE sortableobjectnumber LIKE '" + sortkey1 + "%'"
    elif searchType == 'range':
        whereclause = "WHERE sortableobjectnumber >= '" + sortkey1 + "' AND sortableobjectnumber <= '" + sortkey2 + "'"

    getobjects = setquery('getobjlist','','')
    getobjects = getobjects % whereclause

    cursor.execute(getobjects)
    #for object in objects.fetchall():
    #print object
    # return objects.fetchall()
    return [list(item) for item in cursor.fetchall()]
def getplants(location1, location2, num2ret, updateType, qualifier):

    debug = False

    result = []

    getobjects = setquery(updateType, location1, qualifier)
    try:
        elapsedtime = time.time()
        cursor.execute(getobjects)
        elapsedtime = time.time() - elapsedtime
        #sys.stderr.write('query :: %s\n' % getobjects)
        if debug: sys.stderr.write('all objects: %s :: %s\n' % (location1, elapsedtime))
    except psycopg2.DatabaseError as e:
        raise
        #sys.stderr.write('getplants select error: %s' % e)
        #return result
    except:
        sys.stderr.write("some other getplants database error!")
        return result

    try:
        result = [list(item) for item in cursor.fetchall()]
        if debug: sys.stderr.write('object count: %s\n' % (len(result)))
    except psycopg2.DatabaseError as e:
        sys.stderr.write("fetchall getplants database error!")

    return result
示例#3
0
def getplants(location1, location2, num2ret, updateType, qualifier):

    debug = False

    result = []

    getobjects = setquery(updateType, location1, qualifier)
    try:
        elapsedtime = time.time()
        cursor.execute(getobjects)
        elapsedtime = time.time() - elapsedtime
        #sys.stderr.write('query :: %s\n' % getobjects)
        if debug: sys.stderr.write('all objects: %s :: %s\n' % (location1, elapsedtime))
    except psycopg2.DatabaseError, e:
        raise
def getplants(location1, location2, num2ret, updateType, qualifier):

    debug = False

    result = []

    #for loc in getloclist('set',location1,'',num2ret,config):
    getobjects = setquery(updateType, location1, qualifier, 'ucbg')
    #print "<span>%s</span>" % getobjects
    try:
        elapsedtime = time.time()
        cursor.execute(getobjects)
        elapsedtime = time.time() - elapsedtime
        #sys.stderr.write('query :: %s\n' % getobjects)
        if debug: sys.stderr.write('all objects: %s :: %s\n' % (location1, elapsedtime))
    except psycopg2.DatabaseError, e:
        raise
示例#5
0
def getplants(location1, location2, num2ret, updateType, qualifier):

    debug = False

    result = []

    #for loc in getloclist('set',location1,'',num2ret,config):
    getobjects = setquery(updateType, location1, qualifier, 'ucbg')
    #print "<span>%s</span>" % getobjects
    try:
        elapsedtime = time.time()
        cursor.execute(getobjects)
        elapsedtime = time.time() - elapsedtime
        #sys.stderr.write('query :: %s\n' % getobjects)
        if debug:
            sys.stderr.write('all objects: %s :: %s\n' %
                             (location1, elapsedtime))
    except psycopg2.DatabaseError, e:
        raise
def getlocations(location1, location2, num2ret, updateType):

    debug = True

    result = []

    for loc in getloclist('set', location1, '', num2ret):
        getobjects = setquery(updateType, loc[0], 'alive')


        #print(getobjects)

        try:
            elapsedtime = time.time()
            cursor.execute(getobjects)
            elapsedtime = time.time() - elapsedtime
            if debug: sys.stderr.write('all objects: %s :: %s\n' % (loc[0], elapsedtime))
        except psycopg2.DatabaseError as e:
            sys.stderr.write('getlocations select error: %s' % e)
            #return result
            raise
        except:
            sys.stderr.write("some other getlocations database error!")
            #return result
            raise

        try:
            rows = cursor.fetchall()
            sys.stderr.write("getloclist %s = %s\n" % (loc[0], len(rows)))
        except psycopg2.DatabaseError as e:
            sys.stderr.write("fetchall getlocations database error!")

        if debug: sys.stderr.write('number objects to be checked: %s\n' % len(rows))
        try:
            for row in rows:
                result.append(row)
        except:
            sys.stderr.write("other getobjects error: %s" % len(rows))
            raise

    return result
def getlocations(location1, location2, num2ret, updateType, institution):

    debug = False

    result = []

    for loc in getloclist('set', location1, '', num2ret):
        getobjects = setquery(updateType, loc[0], '', institution)

        sys.stderr.write("getloclist %s" % location1)

        try:
            elapsedtime = time.time()
            cursor.execute(getobjects)
            elapsedtime = time.time() - elapsedtime
            if debug: sys.stderr.write('all objects: %s :: %s\n' % (loc[0], elapsedtime))
        except psycopg2.DatabaseError, e:
            sys.stderr.write('getlocations select error: %s' % e)
            #return result
            raise
        except:
示例#8
0
def getlocations(location1, location2, num2ret, updateType):

    debug = True

    result = []

    for loc in getloclist('set', location1, '', num2ret):
        getobjects = setquery(updateType, loc[0], 'alive')


        #print getobjects

        try:
            elapsedtime = time.time()
            cursor.execute(getobjects)
            elapsedtime = time.time() - elapsedtime
            if debug: sys.stderr.write('all objects: %s :: %s\n' % (loc[0], elapsedtime))
        except psycopg2.DatabaseError, e:
            sys.stderr.write('getlocations select error: %s' % e)
            #return result
            raise
        except: