From 7725c65aeb830646acb90f7ccd1c61de23e3bc31 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 9 Aug 2018 18:02:14 +0100 Subject: [PATCH] use ox.api.signin --- ontology/ontology.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) mode change 100644 => 100755 ontology/ontology.py diff --git a/ontology/ontology.py b/ontology/ontology.py old mode 100644 new mode 100755 index b2301e8..3e867db --- a/ontology/ontology.py +++ b/ontology/ontology.py @@ -1,9 +1,9 @@ -import getpass +#!/usr/bin/python3 import json import sys import ox -import ox.web.auth +import ox.api def parse_nodes(parents, nodes): global strings @@ -32,24 +32,7 @@ for string in sorted(strings): # sign in site = 'pandora.cinemusespace.com' -api = ox.API('https://{}/api/'.format(site)) -update = False -try: - credentials = ox.web.auth.get(site) -except: - print('Please enter your username and password for {}:'.format(site)) - credentials = {} - credentials['username'] = input('Username: ') - credentials['password'] = getpass.getpass('Password: ') - update = True -r = api.signin(**credentials) -if 'errors' in r.get('data', {}): - print(r['data']) - for kv in r['data']['errors'].items(): - print('{}: {}'.format(*kv)) - sys.exit(1) -if (update): - ox.web.auth.update(site, credentials) +api = ox.api.signin('https://%s/api/' % site) # find keywords, add strings, count items for children and parents child_items = {}