use ox.api.signin
This commit is contained in:
parent
84bfde677d
commit
7725c65aeb
1 changed files with 3 additions and 20 deletions
23
ontology/ontology.py
Normal file → Executable file
23
ontology/ontology.py
Normal file → Executable file
|
@ -1,9 +1,9 @@
|
||||||
import getpass
|
#!/usr/bin/python3
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
import ox.web.auth
|
import ox.api
|
||||||
|
|
||||||
def parse_nodes(parents, nodes):
|
def parse_nodes(parents, nodes):
|
||||||
global strings
|
global strings
|
||||||
|
@ -32,24 +32,7 @@ for string in sorted(strings):
|
||||||
|
|
||||||
# sign in
|
# sign in
|
||||||
site = 'pandora.cinemusespace.com'
|
site = 'pandora.cinemusespace.com'
|
||||||
api = ox.API('https://{}/api/'.format(site))
|
api = ox.api.signin('https://%s/api/' % 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)
|
|
||||||
|
|
||||||
# find keywords, add strings, count items for children and parents
|
# find keywords, add strings, count items for children and parents
|
||||||
child_items = {}
|
child_items = {}
|
||||||
|
|
Loading…
Reference in a new issue