Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1213  / 1 Year ago, wed, january 25, 2023, 4:29:39

Is there any way without running:



sudo apt-add-repository [PPA]


That you can get the description (and possibly some other additional information) of a PPA through Terminal?


More From » command-line

 Answers
2

A quick hack (needs package python3-launchpadlib):



#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys,re

from launchpadlib.launchpad import Launchpad
import httplib2
import lazr.restfulclient.errors

if len(sys.argv) < 2:
print('Syntax: {cmd} ppa'.format(cmd=sys.argv[0]))
print()
print('For example: {cmd} ppa://diesch/testing'.format(cmd=sys.argv[0]))
sys.exit(2)


try:
lp = Launchpad.login_anonymously('foo', 'production', None)
except httplib2.HttpLib2Error as e:
print('Error connection to launchpad.net:', e)
sys.exit(1)


ppa_name = sys.argv[1].strip()

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)
sys.exit(1)

try:
owner = lp.people[user]
ppa = owner.getPPAByName(name=name)

print('PPA {name} at {url}'.format(name=ppa_name, url=ppa.web_link))
print()
print('Owner: {owner} ({url})'.format(owner=owner.display_name,
url=owner.web_link))
print()
print(ppa.description)
except lazr.restfulclient.errors.RestfulError as e:
print('Error getting PPA info:', e)
exit(1)


Save this as e.g. ppa-info, make it executable and run it like



ppa-info ppa:diesch/testing


If the PPA exists, you will get some information, like owner and description, otherwise you'll get an error message.


[#18156] Friday, January 27, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rtbrbab

Total Points: 461
Total Questions: 126
Total Answers: 117

Location: Saudi Arabia
Member since Fri, Jul 1, 2022
2 Years ago
;