Skip to content

Commit

Permalink
Merge pull request #4 from IQSS/3-versions
Browse files Browse the repository at this point in the history
show versions of Dataverse from installations on map #3
  • Loading branch information
pdurbin authored Sep 26, 2019
2 parents 9095567 + 0cc58de commit 716f1dc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
import urllib.request as urlrequest
import json
from urllib.parse import urlparse
onmetrics = 'https://dataversemetrics.odum.unc.edu/dataverse-metrics/config.json'
response = urlrequest.urlopen(onmetrics)
metrics_json = json.loads(response.read().decode(response.info().get_param('charset') or 'utf-8'))
onmap = 'https://services.dataverse.harvard.edu/miniverse/map/installations-json'
response = urlrequest.urlopen(onmap)
map_json = json.loads(response.read().decode(response.info().get_param('charset') or 'utf-8'))
for i in map_json['installations']:
url = i['url']
o = urlparse(url)
hostname = o.netloc
basename = 'https://' + hostname
polled = False
if basename in metrics_json['installations']:
polled = True
version_url = basename + '/api/info/version'
try:
response = urlrequest.urlopen(version_url)
json_out = json.loads(response.read().decode(response.info().get_param('charset') or 'utf-8'))
version = json_out['data']['version']
print(basename, version, polled)
except:
print(basename, 'UNKNOWN', polled)

0 comments on commit 716f1dc

Please sign in to comment.