try: objects.execute(query) refname = objects.fetchone() result.append([t, refname]) except: raise return "findrefnames error" return result if __name__ == "__main__": from cswaUtils import getConfig config = getConfig("ucbgLocationReport.cfg") print getplants("Velleia rosea", "", 1, config, "locreport") sys.exit() config = getConfig("sysinvProd.cfg") print "\nrefnames\n" print getrefname("concepts_common", "zzz", config) print getrefname("concepts_common", "", config) print getrefname("concepts_common", "Yurok", config) print findrefnames("places_common", ["zzz", "Sudan, Northern Africa, Africa"], config) print "\ncurrentlocation\n" print findcurrentlocation("c65b2ffa-6e5f-4a6d-afa4-e0b57fc16106", config) print "\nset of locations\n" for loc in getloclist("set", "Kroeber, 20A, W B", "", 10, config): print loc
return records, len(values) except IOError: message = 'Could not read (or maybe parse) rows from %s' % rawFile return message, -1 except: raise if __name__ == "__main__": print "MEDIA: config file: %s" % sys.argv[2] print "MEDIA: input file: %s" % sys.argv[1] try: form = {'webapp': CONFIGDIRECTORY + sys.argv[2]} config = getConfig(form) except: print "MEDIA: could not get configuration" sys.exit() # print 'config',config records, columns = getRecords(sys.argv[1]) if columns == -1: print 'MEDIA: Error! %s' % records sys.exit() print 'MEDIA: %s columns and %s lines found in file %s' % (columns, len(records), sys.argv[1]) outputFile = sys.argv[1].replace('.step2.csv', '.step3.csv') outputfh = csv.writer(open(outputFile, 'wb'), delimiter="\t") for i, r in enumerate(records):
WHERE REGEXP_REPLACE(pog.anthropologyplaceowner, '^.*\)''(.*)''$', '\\1') ILIKE '%""" + owner + """%' OR (pog.anthropologyplaceowner IS NULL AND pog.anthropologyplaceownershipnote ILIKE '%""" + owner + """%') GROUP BY cc.objectnumber, cp.sortableobjectnumber, cc.numberofobjects, ong.objectname, fcd.datedisplaydate, fcp.item, pog.anthropologyplaceowner, pog.anthropologyplaceownershipnote, pc.placenote ORDER BY REGEXP_REPLACE(fcp.item, '^.*\)''(.*)''$', '\\1'), pog.anthropologyplaceownershipnote, cp.sortableobjectnumber """ objects.execute(query) return objects.fetchall() if __name__ == "__main__": from cswaUtils import getConfig form = {'webapp': 'ucbgLocationReportV321'} config = getConfig(form) allplants = getplants('Pteridophyta', '', 1, config, 'getalltaxa', 'alive') print 'array:',len(allplants) sys.exit() form = {'webapp': 'barcodeprintDev'} config = getConfig(form) print getobjinfo('1-504', config) print '\nkeyinfo\n' # Kroeber, 20A, X 1, 1 # Kroeber, 20AMez, 128 A for i, loc in enumerate(getlocations('Kroeber, 20A, X 1, 3', '', 1, config, 'keyinfo','pahma')): print 'location', i + 1, loc[0:12]
#!/usr/bin/python import sys from cswaUtils import getConfig import cswaGetAuthorityTree config = getConfig({'webapp': 'pahma_Packinglist_Dev'}) place = sys.argv[1] print 'place:', place places = cswaGetAuthorityTree.getAuthority( 'places', 'Placeitem', place, config.get('connect', 'connect_string')) if len(places) < 200: for placeitem in places: print placeitem else: print place, ':', len(places)
try: objects.execute(query) refname = objects.fetchone() result.append([t, refname]) except: raise return "findrefnames error" return result if __name__ == "__main__": from cswaUtils import getConfig config = getConfig('sysinvProd.cfg') print '\nrefnames\n' print getrefname('concepts_common', 'zzz', config) print getrefname('concepts_common', '', config) print getrefname('concepts_common', 'Yurok', config) print findrefnames('places_common', ['zzz', 'Sudan, Northern Africa, Africa'], config) print '\ncurrentlocation\n' print findcurrentlocation('c65b2ffa-6e5f-4a6d-afa4-e0b57fc16106', config) print '\nset of locations\n' for loc in getloclist('set', 'Kroeber, 20A, W B', '', 10, config): print loc print '\nlocations by prefix\n' for loc in getloclist('prefix', 'Kroeber, 20A, W B', '', 1000, config):
if objmedia != None: for image in objmedia: #/blobs/be903851-a2a8-4eee-bf15/derivatives/Thumbnail/content #link = "http://pahma.cspace.berkeley.edu:8180/cspace-services/blobs/%s/derivatives/%s/content" # use spiffy, new "public image service", to avoid having to re-authenticate user link = "http://dev.cspace.berkeley.edu/pahma_project/imageserver/blobs/%s/derivatives/%s/content" thumb = link % (image[1], 'Thumbnail') original = link % (image[1], 'OriginalJpeg') print '<div class="imagecell"><a href="%s" target="_blank"><img src="%s"></a></div>' % ( original, thumb) else: print "no related media" print "</div>" print '<div style="width: 100%; float:left;"><hr/></div>' # print "<script>getLastFormElem().focus();</script>" if __name__ == "__main__": # to test this module on the command line you have to pass in two cgi values: # $ python cswaOjbectDetails.py "ob.objectnumber=11-11&webapp=objectInfoDev" # this will load the config file and attempt to update some records in server identified # in that config file! import cgi from cswaUtils import getConfig form = cgi.FieldStorage() config = getConfig(form) doObjectDetails(form, config)
#!/usr/bin/python import sys from cswaUtils import getConfig import cswaGetAuthorityTree config = getConfig({'webapp': 'pahma_Packinglist_Dev'}) place = sys.argv[1] print 'place:', place places = cswaGetAuthorityTree.getAuthority('places', 'Placeitem', place, config.get('connect', 'connect_string')) if len(places) < 200: for placeitem in places: print placeitem else: print place, ':', len(places)
#!/usr/bin/python import sys from cswaUtils import getConfig import cswaGetAuthorityTree config = getConfig({'webapp': 'omca_Packinglist_Dev'}) place = sys.argv[1] print 'place:', place places = cswaGetAuthorityTree.getAuthority('places', 'Placeitem', place, config.get('connect', 'connect_string')) if len(places) < 200: for placeitem in places: print placeitem else: print place, ':', len(places)