-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_missing_paths.py
33 lines (25 loc) · 1018 Bytes
/
list_missing_paths.py
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
import sys, os
from os.path import expanduser
from pynux import utils
import requests
import json
from datetime import datetime
PYNUXRC = os.environ.get('PYNUXRC')
''' reads in the output of the nuxeo esync tool: https://github.com/nuxeo/esync
outputs a json file with uid, path, and title of documents that esync reported missing from elasticsearch
'''
with open('nuxeo-esync-20220209.txt') as f:
missing = [{'uid': line.split()[4][:-1], 'type': line.split()[6]} for line in f if line.split()[2] == '[MissingListener]']
print(f"number of missing records {len(missing)}")
nx = utils.Nuxeo(rcfile=open(expanduser(PYNUXRC), 'r'))
now = datetime.now()
datestring = now.strftime("%Y%m%d")
for m in missing:
try:
metadata = nx.get_metadata(uid=m['uid'])
except requests.exceptions.HTTPError:
path = "NONE"
m['path'] = metadata['path']
m['dc:title'] = metadata['properties']['dc:title']
with open(f"all_missing_{datestring}.json", 'w') as f:
f.write(json.dumps(missing))