def test_download_get(): "occurrences.download_get - basic test" key = "0000066-140928181241064" res = occurrences.download_get(key) assert 'dict' == res.__class__.__name__ assert len(res) == 3 assert key == res['key']
def test_download_get(): "occurrences.download_get - basic test" key = "0089857-160910150852091" res = occ.download_get(key) assert 'dict' == res.__class__.__name__ assert len(res) == 3 assert key == res['key']
print(sp_name) gbifSpcInfo = species.name_backbone(name=sp_name) try: print(gbifSpcInfo['usageKey']) except: print(sp_name, "not found") continue taxonKeySel = "taxonKey = %s" % gbifSpcInfo['usageKey'] print(taxonKeySel) dl = occ.download([ taxonKeySel, 'basisOfRecord = HUMAN_OBSERVATION', 'hasCoordinate = True', latmin, longmin, latmax, longmax ]) dlMeta = occ.download_meta(dl[0]) print(dlMeta) while dlMeta['status'] != 'SUCCEEDED' and dlMeta['status'] != 'KILLED': time.sleep(30) dlMeta = occ.download_meta(dl[0]) print(dlMeta) if dlMeta['status'] == 'SUCCEEDED': dlList.append(dl) for dl in dlList: try: occ.download_get(dl[0]) except: pass
finally: sys.exit(0) if args.download_list is True: try: result = occ.download_list(user=user, pwd=pwd, limit=20, offset=0) print_out(result) except: handle_error() finally: sys.exit(0) if args.download_get is True: try: if args.dKey is not None: result = occ.download_get(key=args.dKey, path=args.path) print_out(result) else: print " --dKey argument is required [--path]" except: handle_error() finally: sys.exit(0) ### SEARCH ############################################################################## if args.search is True: try: if args.sTaxonKey is not None or args.sRepatriated is not None or args.sKingdomKey is not None or \ args.sPhylumKey is not None or args.sClassKey is not None or args.sOrderKey is not None or \ args.sFamilyKey is not None or args.sGenusKey is not None or args.sSubgenusKey is not None or \ args.sScientificName is not None or args.sCountry is not None or args.sPublishingCountry is not None or \
NOTE: The download can take a while to generate and is not immediately available once the download_get command has been issued. Use a while and try loop to make sure the download has succeeded. The zipdownload variable will be a dictionary of the path, the file size, and the download key unique code. It can be used to change the file name, unzip the file, etc. ''' print( "Attempting to download the Darwin Core Archive zip file for this species ....." ) gotit = None while gotit is None: try: zipdownload = occ.download_get(key=dkey, path=downDir) gotit = 1 except: pass t1 = datetime.now() print("\n\n+++++ Download time was", t1 - t0, '+++++') ''' Now try reading the "occurrence.txt" file into a Pandas dataframe using the DWCA Reader Python package. pip install python-dwca-reader ''' print('\n' + '=' * 55) with DwCAReader(downDir + dkey + '.zip') as dwca: