def main(): travis_commit_range = os.getenv("TRAVIS_COMMIT_RANGE", "") print_checkout_info(travis_commit_range) if travis_commit_range == "": sys.exit("No TRAVIS_COMMIT_RANGE set.") emails = get_emails_for_range(travis_commit_range) if len(emails) == 0: sys.exit("No emails found in in the given commit range.") master_emails = get_emails_for_range("master") width = max(map(len, emails)) lp = None failed = False print("Need to check {} emails:".format(len(emails))) for email in emails: if static_email_check(email, master_emails, width): continue # in the normal case this isn't reached if lp is None: print("Logging into Launchpad...") lp = Launchpad.login_anonymously("check CLA", "production") cla_folks = lp.people["contributor-agreement-canonical"].participants if not lp_email_check(email, lp, cla_folks, width): failed = True if failed: sys.exit(1)
def set_authorization(self, application=None, server=None): if application is not None and server is not None: self.launchpad = Launchpad.login_with(application, server, self.__cachedir, credential_save_failed=self.__no_credential, version='devel') else: self.launchpad = Launchpad.login_anonymously('just testing', 'production', self.__cachedir, version='devel')
def get_lp_bugs(): """Get a list of bugs from Launchpad""" lp = Launchpad.login_anonymously("%s LP bug checker" % LP_SOURCE_NAME, "production", CACHEDIR, version="devel") ubuntu = lp.distributions["ubuntu"] archive = ubuntu.main_archive packages = archive.getPublishedSources(source_name=LP_SOURCE_NAME) package = ubuntu.getSourcePackage(name=packages[0].source_package_name) bug_tasks = package.searchTasks(status=[ "New", "Opinion", "Invalid", "Won't Fix", "Expired", "Confirmed", "Triaged", "In Progress", "Fix Committed", "Fix Released", "Incomplete" ]) bugs = {} for task in bug_tasks: id = str(task.bug.id) title = task.title.split(": ")[1] status = task.status closed = status in ["Invalid", "Won't Fix", "Expired", "Fix Released"] link = "https://bugs.launchpad.net/ubuntu/+source/{}/+bug/{}".format( LP_SOURCE_URL_NAME, id) bugs[id] = { "title": title, "link": link, "status": status, "closed": closed } return bugs
def get_bugs(status, tag=None, previous_days=None): launchpad = Launchpad.login_anonymously('OOOQ Ruck Rover', 'production', cachedir, version='devel') project = launchpad.projects['tripleo'] # Filter by Status and Tag if tag is not None and previous_days is None: bugs = project.searchTasks(status=status, tags=tag) # Filter by Status only elif tag is None and previous_days is None: bugs = project.searchTasks(status=status) # Filter by Status and Number of Days elif tag is None and previous_days is not None: days_to_search = datetime.utcnow() - timedelta(days=int(previous_days)) bugs = project.searchTasks(status=status, created_since=days_to_search) # Filter by Tag, Status and Number of Days elif tag is not None and previous_days is not None: days_to_search = datetime.utcnow() - timedelta(days=int(previous_days)) bugs = project.searchTasks(status=status, created_since=days_to_search, tags=tag) else: print("invalid combination of parameters") sys.exit(1) return bugs
def ppa_info(self, _ppa): if self._MyOS == 'ubuntu': from launchpadlib.launchpad import Launchpad import httplib2 import lazr.restfulclient.errors try: lp = Launchpad.login_anonymously('foo', 'production', None) except httplib2.HttpLib2Error as e: print(('Error connection to launchpad.net:', e)) exit(1) ppa_name = _ppa m = re.search(r'^(ppa:)?(?P<user>[^/]+)/(?P<name>.+)', ppa_name) if m: _user, name = m.group('user', 'name') else: print(('Unvalid PPA name:', _ppa)) exit(1) try: owner = lp.people[_user] ppa = owner.getPPAByName(name=name) print(('PPA is Valid. Source URL:\n%s' % (ppa))) return True except lazr.restfulclient.errors.RestfulError as e: print(('Error getting PPA info:', e)) return False exit(1)
def _get_launchpad_bug(self, type, cache_dir): if not self.summary: from launchpadlib.launchpad import Launchpad lp = Launchpad.login_anonymously( 'qa-reports.linaro.org', 'production', cache_dir, version='devel' ) lp_bug = lp.bugs[int(self.alias)] lp_severity = '' lp_status = '' for task in lp_bug.bug_tasks: lp_severity += "%s: %s | " % (task.bug_target_display_name, task.importance) lp_status += "%s: %s | " % (task.bug_target_display_name, task.status) self.summary = lp_bug.title self.status = lp_status self.severity = lp_severity self.web_link = lp_bug.web_link self.save() return { 'alias': self.alias, 'description': self.summary, 'weblink': self.web_link, 'severity': self.severity, 'status': self.status }
def build_lp_bugs(project, update=True, limit=-1): """Top level routine to download bug related data from Launchpad Update determines whether incremental update is used. True = incremental Special case with update is list, then specific list of bugno's are fetched """ global ALL_BUGS ALL_BUGS = {} global lp lp = Launchpad.login_anonymously('just testing', 'production', get_lpcache_dir(project)) existing_file = False pname = project_to_fname(project) prior = {} # see if prior version exists if update: try: prior = jload(pname) existing_file = True print 'Total prior bugs:', len(prior) except Exception, e: prior = {} existing_file = False
def _get_suggested_ppa_message(user): try: msg = [] from launchpadlib.launchpad import Launchpad lp = Launchpad.login_anonymously(lp_application_name, "production") try: user_inst = lp.people[user] entity_name = _("team") if user_inst.is_team else _("user") if len(user_inst.ppas) > 0: # Translators: %(entity)s is either "team" or "user" msg.append(_("The %(entity)s named '%(user)s' has no PPA named '%(ppa)s'") % { 'entity' : entity_name, 'user' : user, 'ppa' : ppa_name}) msg.append(_("Please choose from the following available PPAs:"******" * '%(name)s': %(displayname)s") % { 'name' : ppa.name, 'displayname' : ppa.displayname}) else: # Translators: %(entity)s is either "team" or "user" msg.append(_("The %(entity)s named '%(user)s' does not have any PPA") % { 'entity' : entity_name, 'user' : user}) return '\n'.join(msg) except KeyError: return '' except ImportError: return _("Please check that the PPA name or format is correct.")
def _update_launchpad_buglist(self, bug_id_list, username=None, password=None, **kwargs): from launchpadlib.launchpad import Launchpad log.debug("updating {0} bugs".format(self.tracker_name)) cachedir = "/tmp/launchpadcache" lp = Launchpad.login_anonymously('qa-reports.linaro.org', 'production', cachedir, version='devel') for bug_id in bug_id_list: log.debug("updating {0}".format(bug_id)) lp_bug = lp.bugs[int(bug_id)] lp_severity = '' lp_status = '' for task in lp_bug.bug_tasks: lp_severity += "%s: %s | " % (task.bug_target_display_name, task.importance) lp_status += "%s: %s | " % (task.bug_target_display_name, task.status) bug_defaults = { 'summary': lp_bug.title, 'status': lp_status, 'severity': lp_severity, } db_bug, created = Bug.objects.get_or_create( alias=bug_id, tracker=self.tracker_name, defaults=bug_defaults) if not created: for attr, value in bug_defaults.iteritems(): setattr(db_bug, attr, value) db_bug.save()
def run(): if len(sys.argv) != 2: sys.exit('Expected a single argument of an email address') email = sys.argv[1] print('Logging into Launchpad...') launchpad = Launchpad.login_anonymously('check CLA', 'production') print( 'Checking for a Launchpad account associated with this email address...' ) contributor = launchpad.people.getByEmail(email=email) if not contributor: sys.exit('The contributor does not have a Launchpad account.') print('Contributor: {}'.format(contributor)) print('Checking if the contributor has signed the CLA...') if contributor in launchpad.people[ 'contributor-agreement-canonical'].participants: print('The contributor has signed the CLA.') else: sys.exit( 'The contributor has a Launchpad account, but has not signed the CLA.' )
def main(): try: master, proposed = get_commit_range() except Exception as exc: sys.exit("Could not determine commit range: {}".format(exc)) commit_range = "{}..{}".format(master, proposed) print_checkout_info(commit_range) emails = get_emails_for_range(commit_range) if len(emails) == 0: sys.exit("No emails found in in the given commit range.") master_emails = get_emails_for_range(master) width = max(map(len, emails)) lp = None failed = False print("Need to check {} emails:".format(len(emails))) for email in emails: if static_email_check(email, master_emails, width): continue # in the normal case this isn't reached if lp is None: print("Logging into Launchpad...") lp = Launchpad.login_anonymously("check CLA", "production") cla_folks = lp.people["contributor-agreement-canonical"].participants if not lp_email_check(email, lp, cla_folks, width): failed = True if failed: sys.exit(1)
def new_bug_notify_ircbot_process_hook(config, log, irc): """ Monitor LaunchPad for new bugs, and post to irc. """ lp_ids = [] first_run = True while True: log.debug('checking LaunchPad for new bugs') lp = Launchpad.login_anonymously('ius-tools', 'production') ius = lp.projects.search(text='ius')[0] tasks = ius.searchTasks() for task in tasks: bugid = task.bug.id if first_run and bugid not in lp_ids: # just append all ids to the list log.debug('Adding %s to known ids' % bugid) lp_ids.append(bugid) elif not first_run and bugid not in lp_ids: # if not first run post to channel url = shorten_url(unicode(task.web_link)) reply = "New %s - %s" % (task.title, url) irc.send_to_channel(reply) log.debug('Adding %s to known ids' % bugid) lp_ids.append(bugid) first_run = False sleep(300)
def main(): parser = argparse.ArgumentParser(description="") parser.add_argument( "commit_range", help="Commit range in format <upstream-head>..<fork-head>") opts = parser.parse_args() master, _ = opts.commit_range.split("..") print_checkout_info(opts.commit_range) emails = get_emails_for_range(opts.commit_range) if len(emails) == 0: sys.exit("No emails found in in the given commit range.") master_emails = get_emails_for_range(master) width = max(map(len, emails)) lp = None failed = False cla_folks = set() print("Need to check {} emails:".format(len(emails))) for email in emails: if static_email_check(email, master_emails, width): continue # in the normal case this isn't reached if lp is None: print("Logging into Launchpad...") lp = Launchpad.login_anonymously("check CLA", "production") cla_folks = lp.people[ "contributor-agreement-canonical"].participants if not lp_email_check(email, lp, cla_folks, width): failed = True if failed: sys.exit(1)
def get_bug_status(bug_id): lp = Launchpad.login_anonymously('juju-docs', 'production') status = [] for task in lp.bugs[1223325].bug_tasks.entries: status.append({task['bug_target_name']: task['status']}) return status
def __init__(self, *args, **kwargs): IBugtracker.__init__(self, *args, **kwargs) self.lp = None # A word to the wise: # The Launchpad API is much better than the /+text interface we currently use, # it's faster and easier to get the information we need. # The current /+text interface is not really maintained by Launchpad and most, # or all, of the Launchpad developers hate it. For this reason, we are dropping # support for /+text in the future in favour of launchpadlib. # Terence Simpson (tsimpson) 2010-04-20 try: # Attempt to use launchpadlib, python bindings for the Launchpad API from launchpadlib.launchpad import Launchpad cachedir = os.path.join(conf.supybot.directories.data.tmp(), 'lpcache') if hasattr(Launchpad, 'login_anonymously'): self.lp = Launchpad.login_anonymously("Ubuntu Bots - Bugtracker", 'production', cachedir) else: #NOTE: Most people should have a launchpadlib new enough for .login_anonymously self.lp = Launchpad.login("Ubuntu Bots - Bugtracker", '', '', 'production', cahedir) except ImportError: # Ask for launchpadlib to be installed supylog.warning("Please install python-launchpadlib, the old interface is deprecated") except Exception: # Something unexpected happened self.lp = None supylog.exception("Unknown exception while accessing the Launchpad API")
def fetch_gui_release(origin, version): """Retrieve a Juju GUI release. Return the release tarball local path. The release file can be retrieved from: - an arbitrary URL (if origin is "url"); - the local releases repository (if origin is "local" or if a release version is specified and the corresponding file is present locally); - Launchpad (in all the other cases). """ log('Retrieving Juju GUI release.') if origin == 'url': # "version" is a url. _, _, extension = version.rpartition('.') if extension not in ('tgz', 'xz'): extension = 'xz' return download_release(version, 'url-release.' + extension) if origin == 'local': path = get_release_file_path() log('Using a local release: {}'.format(path)) return path # Handle "stable" if version is not None: # If the user specified a version, before attempting to download the # requested release from Launchpad, check if that version is already # stored locally. path = get_release_file_path(version) if path is not None: log('Using a local release: {}'.format(path)) return path # Retrieve a release from Launchpad. launchpad = Launchpad.login_anonymously('Juju GUI charm', 'production') project = launchpad.projects['juju-gui'] url, filename = get_launchpad_release(project, origin, version) return download_release(url, filename)
def is_bug_open(cls, bug_id): """Checks whether the Launchpad bug for the given bug id is open. An issue is considered open if its status is either "Fix Committed" or "Fix Released." """ config = LaunchpadTrackerConfig() log = logging.getLogger('RunnerLog') launchpad = Launchpad.login_anonymously(consumer_name='test', service_root='production') try: bug = launchpad.bugs[bug_id] except KeyError as error: # Invalid bug ID log.info('Invalid bug ID. Key Error: {0}'.format(error)) return False tasks = bug.bug_tasks entries = tasks.entries for bug_entry in entries: if bug_entry['bug_target_name'] == config.project: return bug_entry['status'] not in ('Fix Committed', 'Fix Released') log.info('Bug does not affect project {0} ' 'or project name is not correct.'.format(config.project)) return False
def show(self, message, bug): """show lp ____: Show details of bug ___ on Launchpad""" launchpad = Launchpad.login_anonymously('just testing', 'production') self.say( self.render_lp(launchpad.bugs[bug]), message=message, html=True ) jira = JIRA( basic_auth=(settings.JIRA_USER, settings.JIRA_PASS), server=settings.JIRA_HOST, validate=False, options={'verify': False} ) issues = jira.search_issues(self.SEARCH_PATTERN % ( settings.JIRA_PROJ, bug, bug)) if len(issues) > 0: self.say("I also found a jira ticket for that", message=message) for issue in issues: self.say( self.render_jira(issue), message=message, html=True )
def get_npm_cache_archive_url(Launchpad=Launchpad): """Figure out the URL of the most recent NPM cache archive on Launchpad.""" launchpad = Launchpad.login_anonymously('Juju GUI charm', 'production') project = launchpad.projects['juju-gui'] # Find the URL of the most recently created NPM cache archive. npm_cache_url = get_release_file_url(project, 'npm-cache', None) return npm_cache_url
def get_yaru_launchpad_bugs(): """Get a list of active bugs from Launchpad""" lp = Launchpad.login_anonymously("Yaru LP bug checker", "production", CACHEDIR, version="devel") ubuntu = lp.distributions["ubuntu"] archive = ubuntu.main_archive packages = archive.getPublishedSources(source_name="yaru") package = ubuntu.getSourcePackage(name=packages[0].source_package_name) bug_tasks = package.searchTasks() bugs = {} for task in bug_tasks: id = str(task.bug.id) title = task.title.split(": ")[1] link = "https://bugs.launchpad.net/ubuntu/+source/yaru-theme/+bug/" + str( id) bugs[id] = {"title": title, "link": link} return bugs
def _run(self): global lxml try: from launchpadlib.launchpad import Launchpad import lxml.html except ImportError: sys.stderr.write("For this developer profile to work, you need launchpadlib and lxml to be installed.\n") return a = raw_input("Please only use this script if you want to update the openteacherAuthors module, since this script puts a lot of load on launchpad and your internet connection, and takes a lot of time to execute. Continue (y/n)? ") if a != "y": return lp = Launchpad.login_anonymously("Get OpenTeacher translators", "production", "~/.launchpadlib/cache/") links = self._translationFileLinks(lp) persons = dict( (href, info) for link in links for href, info in self._personsForFile(link) ) print "\nResults:\n" for l, p in sorted(persons.values()): print ' r.add(a.registerAuthor(_("Translator (%%s)") %% "%s", u"%s"))' % (l, p)
def main(project, state): """Get versions and print""" cachedir = os.path.join('/home', getpass.getuser(), '.launchpadlib/cache/') launchpad = Launchpad.login_anonymously( 'ubuntu-server merge proposal lookup', 'production', cachedir, version='devel') if project.startswith('lp:'): branch = launchpad.branches.getByUrl(url=project) else: branch = launchpad.git_repositories.getByPath( path=project.replace('lp:', '')) if not branch: print('No branch named %s found' % project) return for merge in branch.landing_candidates: if state: if merge.queue_status in state: print('%s' % merge) else: print('%s' % merge)
def get_npm_cache_archive_url(Launchpad=Launchpad): """Figure out the URL of the most recent NPM cache archive on Launchpad.""" launchpad = Launchpad.login_anonymously('Juju GUI charm', 'production') project = launchpad.projects['juju-gui'] # Find the URL of the most recently created NPM cache archive. npm_cache_url, _ = get_launchpad_release(project, 'npm-cache', None) return npm_cache_url
def fetch_gui_release(origin, version): """Retrieve a Juju GUI release. Return the release tarball local path. The release file can be retrieved from: - an arbitrary URL (if origin is "url"); - the local releases repository (if origin is "local" or if a release version is specified and the corresponding file is present locally); - Launchpad (in all the other cases). """ log('Retrieving Juju GUI release.') if origin == 'url': # "version" is a url. _, _, extension = version.rpartition('.') if extension not in ('tgz', 'xz'): extension = 'xz' return download_release(version, 'url-release.' + extension) if origin == 'local': path = get_release_file_path() log('Using a local release: {}'.format(path)) return path # Handle "stable" and "trunk" origins. if version is not None: # If the user specified a version, before attempting to download the # requested release from Launchpad, check if that version is already # stored locally. path = get_release_file_path(version) if path is not None: log('Using a local release: {}'.format(path)) return path # Retrieve a release from Launchpad. launchpad = Launchpad.login_anonymously('Juju GUI charm', 'production') project = launchpad.projects['juju-gui'] url, filename = get_launchpad_release(project, origin, version) return download_release(url, filename)
def main(): travis_commit_range = os.getenv("TRAVIS_COMMIT_RANGE", "") print_checkout_info(travis_commit_range) if travis_commit_range == "": sys.exit("No TRAVIS_COMMIT_RANGE set.") emails = get_emails_for_range(travis_commit_range) if len(emails) == 0: sys.exit("No emails found in in the given commit range.") master_emails = get_emails_for_range("master") width = max(map(len, emails)) lp = None failed = False print("Need to check {} emails:".format(len(emails))) for email in emails: if static_email_check(email, master_emails, width): continue # in the normal case this isn't reached if lp is None: print("Logging into Launchpad...") lp = Launchpad.login_anonymously("check CLA", "production") cla_folks = lp.people[ "contributor-agreement-canonical"].participants if not lp_email_check(email, lp, cla_folks, width): failed = True if failed: sys.exit(1)
def connect_launchpad(): """Using the launchpad module connect to launchpad anonymously""" cachedir = os.path.join('/home', getpass.getuser(), '.launchpadlib/cache/') return Launchpad.login_anonymously('proposed_query', 'production', cachedir, version='devel')
def main(): # This is just to have information in case things go wrong print("Remotes:") sys.stdout.flush() check_call(["git", "remote", "-v"]) print("Branches:") sys.stdout.flush() check_call(["git", "branch", "-v"]) travis_commit_range = os.getenv("TRAVIS_COMMIT_RANGE", "") commits = get_commits_for_range(travis_commit_range) emails = get_emails_from_commits(commits) if not emails: print("No emails to verify") return print("Logging into Launchpad...") lp = Launchpad.login_anonymously("check CLA", "production") cla_folks = lp.people["contributor-agreement-canonical"].participants print("Amount of emails to check the CLA for {}".format(len(emails))) for email in emails: print("Checking the CLA for {!r}".format(email)) if email.endswith("@canonical.com"): print("Skipping @canonical.com account {}".format(email)) continue contributor = lp.people.getByEmail(email=email) if not contributor: sys.exit("The contributor does not have a Launchpad account.") print("Contributor account for {}: {}".format(email, contributor)) if contributor in cla_folks: print("The contributor has signed the CLA.") else: sys.exit("The contributor {} has not signed the CLA.".format(email))
def generate(self): bugs_with_alerts_open = {} bugs_with_alerts_closed = {} launchpad = Launchpad.login_anonymously('Red Hat Status Bot', 'production', '.cache', version='devel') bug_statuses_open = ['Confirmed', 'Triaged', 'In Progress', 'Fix Committed'] bug_statuses_closed = ['Fix Released'] for label, config_string in self.bugs.items(): c = config_string.split(',') project = launchpad.projects[c[0]] filter_re = c[1] for milestone in project.all_milestones: if re.match(filter_re, milestone.name): for task in project.searchTasks(milestone=milestone, status=bug_statuses_open, tags='promotion-blocker'): now = datetime.datetime.now(pytz.UTC) delay = int(self.config.get('Bug', 'delay')) delay_time = now - timedelta(hours=delay) if delay_time > task.date_created: bugs_with_alerts_open[task.bug.id] = task.bug for task in project.searchTasks(milestone=milestone, status=bug_statuses_closed, importance='Critical', tags='alert'): bugs_with_alerts_closed[task.bug.id] = task.bug return bugs_with_alerts_open, bugs_with_alerts_closed
def __init__(self, categorizer, **kwargs): self.gerrit_port = kwargs.pop("gerrit_port") self.trusted = kwargs.get("trusted", []) self.tag = kwargs.get("tag") query = kwargs.get("query") if not query: project = kwargs.get("project") if project: self.query = "status:open project:%s" % project else: self.query = "status:open" message_text = kwargs.pop("message_text") if message_text: self.query = "%s message:%s" % (self.query, message_text) else: self.query = query self.launchpad = Launchpad.login_anonymously("anon", "https://api.launchpad.net/", CACHE_DIR) self.categorizer = categorizer self.gerrit = datasources.gerrit.Gerrit(self.query, self.gerrit_port, self.categorizer) self._data = []
def __init__(self, config_filename): with open(config_filename, "r") as f: self.config = yaml.load(f.read()) self.teams = self.config['teams'] self.trunc = self.config['trunc_report'] cache_dir = self.config['cache_dir'] if self.config['use_auth']: lp = Launchpad.login_with( 'lp-report-bot', 'production', cache_dir, version='devel' ) else: lp = Launchpad.login_anonymously( 'lp-report-bot', 'production', version='devel' ) #import pdb; pdb.set_trace() self.projects = [lp.projects[prj] for prj in self.config['project']] # for backward compatibility #self.project = lp.projects[self.config['project'][0]] self.blueprint_series = {}
def install_testing_packages(self, metapackage_name, source_list, skip_update): arch = self.get_arch_string() matching_sources = [] launchpad = Launchpad.login_anonymously('pkgswitch', 'production', os.path.join(os.getenv("HOME"), ".launchpadlib", "cache")) ppa = launchpad.load("https://api.launchpad.net/1.0/~gwendal-lebihan-dev/+archive/cinnamon-nightly") ppa_sources = ppa.getPublishedSources(status = "Published") # Make sure all our metapackage sources are available, for our series (code name) for source in ppa_sources: if source.source_package_name in source_list and SERIES_MAP[self.CODE_NAME] in source.distro_series_link: matching_sources.append(source) if len(matching_sources) != len(source_list): print "Could not find all source packages required for this metapackage. Aborting!" return False # Figure out provided package names and their latest published/built versions print "\nFinding packages, please wait...\n" resolved_packages = [] for source in matching_sources: for bin in source.getPublishedBinaries(): if bin.distro_arch_series_link.endswith(arch): resolved_packages.append((bin.binary_package_name, bin.binary_package_version)) print "Found: %s_%s" % (bin.binary_package_name, bin.binary_package_version) # Add the PPA print "\n\nAdding Cinnamon nightly PPA...\n\n" if os.system("sudo add-apt-repository -y %s" % PPA) > 0: print "Something went wrong trying to add the repository: %s" % PPA return False # Refresh if not skip_update: print "\n\nUpdating repositories...\n\n" os.system("sudo apt-get update") # Install print "\n\nInstalling testing packages. Please wait...\n\n" pkg_string = "" for name, version in resolved_packages: pkg_string += "%s/%s " % (name, SERIES_MAP[self.CODE_NAME]) if os.system("sudo apt-get install %s" % pkg_string) > 0: print "Something went wrong trying to install the testing packages.\n" print "You should immediately run:\n\npkgswitch -n %s stable" % metapackage_name return False return True
def lap(self): """ The Launchpad Object.""" if not self._lap: self._lap = Launchpad.login_anonymously( f'{self.__module__}.{self.__class__.__name__}', service_root='production', version='devel') return self._lap
def _login(): global MG5 if MG5 is None: lp = Launchpad.login_anonymously('just testing', 'production', LP_CACHEDIR, version='devel') MG5 = lp.projects['mg5amcnlo']
def link(self, message, bug): """link lp ____: Get Launchpad web link for bug ___""" launchpad = Launchpad.login_anonymously('just testing', 'production') try: launchpad.bugs[bug] self.reply(message, launchpad.bugs[bug].web_link) except KeyError: self.reply(message, "That issue does not exist in Launchpad")
def get_lp(login=True): if not login: return Launchpad.login_anonymously('review-queue', 'production') return Launchpad.login_with( 'review-queue', 'production', credentials_file='lp-creds', credential_save_failed=lambda: None)
def login_anonymously(self, service=service, api_version=api_version): '''Enforce an anonymous login.''' if not self.logged_in: self.__lp = LP.login_anonymously('ubuntu-dev-tools', service, version=api_version) else: raise AlreadyLoggedInError('Already logged in to Launchpad.')
def inform_about_launchpad_bug(self, message, bug): launchpad = Launchpad.login_anonymously('just testing', 'production') self.say( self.render_lp(launchpad.bugs[bug]), html=True, message=message )
def bug_link_info(bot, trigger, match=None): match = match or trigger search_for_raw = match.group(1) launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir) bug = launchpad.bugs[search_for_raw] bot.say(bug.title)
def get_all_display_names(): lp = Launchpad.login_anonymously("webteam.canonical.com", "production", ".", version="devel") team = lp.people["canonical-webmonkeys"] return [person.display_name for person in team.members]
def get_project_client(): cache_dir = os.path.expanduser("~/.launchpadlib/cache/") if not os.path.exists(cache_dir): os.makedirs(cache_dir, 0o700) launchpad = Launchpad.login_anonymously(PROJECT_NAME + '-bugs', 'production', cache_dir) project = launchpad.projects[PROJECT_NAME] return project
def get_project_client(project_name): cachedir = os.path.expanduser("~/.launchpadlib/cache/") if not os.path.exists(cachedir): os.makedirs(cachedir, 0o700) launchpad = Launchpad.login_anonymously(project_name + '-bugs', 'production', cachedir) project = launchpad.projects[project_name] return project
def bug_titles(): '''Get titles for all bugs in the IUS Projects Launchpad''' titles = [] launchpad = Launchpad.login_anonymously(os.path.basename(sys.argv[0]), 'production') ius = launchpad.projects.search(text='ius')[0] tasks = ius.searchTasks() for task in tasks: titles.append(task.bug.title) return titles
def fetchtask(): try: launchpad = Launchpad.login_anonymously(os.path.basename(sys.argv[0]), 'production') ius = launchpad.projects.search(text='ius')[0] except: print 'Failed to make connection' else: task = ius.searchTasks() return task
def main(): args = _parse_args() lp = Launchpad.login_anonymously('openstack-proactive_backports', 'production') bugs = [line.strip() for line in sys.stdin.readlines()] for bug in _filter_bugs(lp, args.project, args.importance, bugs): print(bug)
def get_project_client(): cache_dir = os.path.expanduser("~/.launchpadlib/cache/") if not os.path.exists(cache_dir): os.makedirs(cache_dir, 0o700) launchpad = Launchpad.login_anonymously(PROJECT_NAME + '-bugs-stats', 'production', cache_dir) project = launchpad.projects[PROJECT_NAME] return project
def lp_login(lp_instance='production'): cachedir = os.path.join(PROJECT_PATH, 'lp_cache') client_ident = "Launchpad Slack" try: launchpad = Launchpad.login_anonymously(client_ident, lp_instance, cachedir) except: return None return launchpad
def login(self): """ Log into the production Launchpad instance version='devel' is important, otherwise no task will be returned """ self.lp = lp.login_anonymously('sts_tags', 'production', version='devel')
def __init__(self, consumer): lp = Launchpad.login_anonymously(config.bot_name, 'production', config.cache_dir) self.elementary_prj = lp.projects[config.project_name] self.last_checked = datetime.utcnow() self.consumer = consumer self.funcs = compose(self.send_to_consumer, self.transform)
def lp_login(lp_instance='production'): cachedir = os.path.join(PROJECT_PATH, 'lp_cache') client_ident = "Launchpad Slack" try: launchpad = Launchpad.login_anonymously( client_ident, lp_instance, cachedir) except: return None return launchpad
def __init__(self, project_name): self.project_name = project_name cachedir = os.path.expanduser("~/.launchpadlib/cache/") if not os.path.exists(cachedir): os.makedirs(cachedir, 0o700) launchpad = Launchpad.login_anonymously('bugstats', 'production', cachedir) self.project = launchpad.projects[self.project_name]
def __init__(self, consumer): # the API is stateless so loging in once is enough lp = Launchpad.login_anonymously(config.bot_name, "production", config.lp_cache_dir) # we are only interested in elementary bugs self.project = lp.projects[config.lp_project] self.last_checked = datetime.utcnow() self.consumer = consumer
def login(self, id, mode, version): """ login anonymously (read-only) to the launchpad API via the launchpad client instance, specifying id, mode and API version """ __launchpad = Launchpad.login_anonymously(id, mode, self.cache_dir, version=version)
def get_urgent_bugs(): launchpad = Launchpad.login_anonymously('OOOQ Ruck Rover', 'production', cachedir, version='devel') project = launchpad.projects['tripleo'] # We can filter by status too bugs = project.searchTasks(tags='alert') return bugs
def get_lp(login=False): def no_creds(): pass if not login: return Launchpad.login_anonymously('review-queue', 'production') return Launchpad.login_with('review-queue', 'production', credentials_file='lp-creds', credential_save_failed=no_creds)