This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_doi(socrata_4x4, temp_table, draft=True): | |
"""Updates existing DOI's metadata""" | |
url = 'https://api.datacite.org/dois/' | |
datacite_user = os.environ['datacite_user'] | |
datacite_pass = os.environ['datacite_pass'] | |
print('Updating: ' + socrata_4x4) | |
doi_assets = pd.read_json(assets_filename) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
payload = {'data': | |
{'type': | |
'dois', | |
'attributes': | |
{'doi': | |
'{}'.format(doi), | |
'url': | |
'{}'.format(metadata['permalink'].item()), | |
'xml': | |
'{}'.format(xml_encoded) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update socrata asset's DOI metadata | |
headers = {'Host': 'data.austintexas.gov', | |
'Accept': """*/*""", | |
'Content-Length': '6000', | |
'Content-Type': 'application/json', | |
'X-App-Token': os.environ['socrata_doi_app_token']} | |
url = 'https://data.austintexas.gov/api/views/metadata/v1/{}'.format(socrata_4x4) | |
data = {"customFields": {"Digital Object Identifer (DOI)": {"DOI Number": "https://doi.org/{}".format(doi)}}} | |
r2 = requests.patch(url, json=data, auth=(os.environ['socrata_doi_user'], os.environ['socrata_doi_pass']), headers=headers) | |
print(r2.content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gather_socrata_assets(): | |
"""Gathers assets from socrata for metadata generation and returns a list of dictionaries. Dictionaries keys are | |
field names as required by DataCite and values are from Socrata""" | |
global count | |
global assets | |
# limits query to 2000 results | |
url = 'http://api.us.socrata.com/api/catalog/v1?limit=2000&domains=data.austintexas.gov' | |
r = requests.get(url).json() | |
for item in r['results']: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if update is False: | |
# figure out next doi suffix to use if new | |
department_dois = doi_assets.loc[doi_assets['department'] == metadata['department'].item()] | |
if len(department_dois) != 0: | |
# add 1 to highest suffix value and use zfill to pad w/zeros to 6 chars | |
doi_suffix = str((department_dois['doi_suffix'].max()+1)).zfill(6) | |
else: | |
# new doi for dept, start at 000001 | |
doi_suffix = str(1).zfill(6) | |
# zfill dept prefix to 3 chars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head><meta charset="utf-8" /> | |
<title>vehicle_location</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<style type="text/css"> | |
/*! | |
* | |
* Twitter Bootstrap |