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 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 = {}
|
||||
|
|
Loading…
Reference in a new issue