-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_media_update.py
More file actions
37 lines (30 loc) · 1.18 KB
/
run_media_update.py
File metadata and controls
37 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from datetime import date
from py_dataset import dataset
from ames.harvesters import get_caltechdata, get_caltechdata_files
from ames.matchers import update_datacite_media
password = os.environ["DATACITE"]
prefix = "10.14291"
user = "CALTECH.LIBRARY"
token = os.environ["INVENIO_TOKEN"]
with open("mediaupdate", "r") as infile:
last_date = infile.readline().strip()
query = 'metadata.subjects.subject:"TCCON"'
records = get_caltechdata(query, token=token, date=last_date, datacite=False)
for record in records:
print(f"Processing {record['id']}")
files = get_caltechdata_files(record, token=token)
update_datacite_media(user, password, record, files, prefix)
password = os.environ["CALTECHDATA_DATACITE"]
prefix = "10.22002"
user = "CALTECH.DATA"
records = get_caltechdata(token=token, date=last_date, datacite=False)
for record in records:
print(f"Processing {record['id']}")
collection_files = get_caltechdata_files(record, token=token)
print("Running media update")
update_datacite_media(user, password, record, collection_files, prefix)
# Save date in file
today = date.today().isoformat()
with open("mediaupdate", "w") as outfile:
outfile.write(today)