Created
September 12, 2018 17:00
-
-
Save andreinechaev/bc276bd8b9aa1831ddc38e779d1c19f8 to your computer and use it in GitHub Desktop.
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
from nuxeo.client import Nuxeo | |
import argparse | |
# size in MB | |
def _query(client, begin, end=None): | |
query = None | |
if (end is None): | |
query = f"SELECT * FROM Document WHERE ecm:primaryType = 'Design' AND ecm:currentLifeCycleState != 'deleted' AND ecm:isVersion = 0 AND file:content/length > {begin * 1024 * 1024}" | |
else: | |
query = f"SELECT * FROM Document WHERE ecm:primaryType = 'Design' AND ecm:currentLifeCycleState != 'deleted' AND ecm:isVersion = 0 AND file:content/length > {begin * 1024 * 1024} AND file:content/length < {end * 1024 * 1024}" | |
search = client.query(query, params={'properties': 'dublincore,common', 'pageSize': 50}) | |
entries = search['entries'] | |
ids = [] | |
digests = [] | |
for entry in entries: | |
ids.append(entry['uid']) | |
digests.append(entry['properties']['file:content']['digest']) | |
return ids, digests | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Query an instance for getting binary hashes of a doc type and lifecycle state') | |
# parser.add_argument('--path', type=str, help='full path to csv file from s3', required=True) | |
parser.add_argument('--host', type=str, | |
help='address of your instance followed by `nuxeo` path segment. for instance ' | |
'http://localhost:8080/nuxeo', | |
default='http://localhost:8080/nuxeo') | |
parser.add_argument('--user', type=str, help='username', required=True) | |
parser.add_argument('--password', type=str, help='password', required=True) | |
args = parser.parse_args() | |
nuxeo = Nuxeo(host=args.host, auth=(args.user, args.password)) | |
ids, digests = _query(nuxeo.client, 100, 500) | |
print("Small\n\n") | |
print(f"ids - {ids}\n") | |
print(f"digests {digests}\n\n") | |
ids, digests = _query(nuxeo.client, 500, 900) | |
print("Medium\n\n") | |
print(f"ids - {ids}\n") | |
print(f"digests {digests}\n\n") | |
ids, digests = _query(nuxeo.client, 900) | |
print("Large\n\n") | |
print(f"ids - {ids}\n") | |
print(f"digests {digests}\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment