system-config/tools/lp_openid_lookup

34 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright (c) 2016 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Simple wrapper for the OpenId reverse lookup method in the LP API,
# useful when you need to determine the LP account associated with a
# login.launchpad.net OpenId. Pass the OpenId URL in question as the
# only command-line parameter, and run this in the gerrit2 homedir on
# review.opendev.org (or hack it to use your own LP API key instead).
import os
import sys
from launchpadlib import launchpad
from launchpadlib import uris
lp = launchpad.Launchpad.login_with(
'Gerrit User Sync', uris.LPNET_SERVICE_ROOT,
os.path.expanduser('~/.launchpadlib/cache'),
credentials_file=os.path.expanduser('~/.launchpadlib/creds'),
version='devel')
print(lp.people.getByOpenIDIdentifier(identifier=sys.argv[1]))