Add a simple LP OpenId reverse lookup utility
Change-Id: Ibe1705bc53a48aa6c23f095ae9118d2d367aea78
This commit is contained in:
		
							
								
								
									
										33
									
								
								tools/lp_openid_lookup
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								tools/lp_openid_lookup
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					#!/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.openstack.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]))
 | 
				
			||||||
		Reference in New Issue
	
	Block a user