anenasa / pyppasearch Goto Github PK
View Code? Open in Web Editor NEWSimple python script for searching PPA
License: GNU Affero General Public License v3.0
Simple python script for searching PPA
License: GNU Affero General Public License v3.0
I'm using your great script in daily basis. Thank you!
And I found myself changing source code line
https://github.com/anenasa/pyppasearch/blob/main/pyppasearch.py#L17
from exact_match=True
to exact_match=False
depending on the current use-case.
If possible, please set exact_match=True
as default, and allow user to set False
from command-line argument.
First of all I would like to thank you for your application. It is useful, and may replace search on https://launchpad.net/ubuntu/+ppas which does not have the filter for searching for relevant Ubuntu version/suite.
For long time I'm using Y PPA Manager to find PPAs locally.
And what is interesting it finds more packages than your script. If I understand things correctly both applications parse output from https://launchpad.net/ubuntu/+ppas URL.
I'm running Ubuntu MATE 18.04.6 LTS with all updates and only Y PPA Manager PPA added to the system. Here I see the following for i3-gaps
package search:
cd ~/Downloads
wget -c https://raw.githubusercontent.com/anenasa/pyppasearch/main/pyppasearch.py
sudo apt-get update
sudo apt-get install python3-bs
chmod +x pyppasearch.py
./pyppasearch.py -c Bionic i3-gaps
i3-gaps 4.17.1-0york0~18.04 jonathonf/i3 Bionic
Search is finished.
Could you please elaborate why your script shows 1 line, while Y PPA Manager shows 12?
I have an issue with your great script. See below:
$ pyppasearch.py -c bionic -a amd64 cmake
cmake 3.15.4-1ubuntu3ppa1~bionic ppa:hnakamur/cmake Bionic (amd64)
cmake 3.22.6-0ubuntu1~18.04.sav0 ppa:savoury1/build-tools Bionic (amd64)
cmake 3.12.3-3~ubuntu18.04.1~ppa1 ppa:rsjtaylor/cmake-backports Bionic (amd64)
Searching 17/300Traceback (most recent call last):
File "/home/username/bin/pyppasearch.py", line 75, in <module>
main()
File "/home/username/bin/pyppasearch.py", line 66, in main
packages = repos[i].search(lp, args.codename, args.arch, args.noexact, args.package)
File "/home/username/bin/pyppasearch.py", line 15, in search
owner = lp.people[self.user]
File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 998, in __getitem__
shim_resource._ensure_representation()
File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 379, in _ensure_representation
representation = self._root._browser.get(self._wadl_resource)
File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 441, in get
response, content = self._request(url, extra_headers=headers)
File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 431, in _request
raise error
lazr.restfulclient.errors.Unauthorized: HTTP Error 401: Unauthorized
Response headers:
---
content-length: 0
content-type: text/plain;charset=utf-8
date: Wed, 14 Sep 2022 08:54:12 GMT
server: gunicorn/19.8.1
status: 401
x-powered-by: Zope (www.zope.org), Python (www.python.org)
x-request-id: b40c9f14-1093-4f11-961d-447ca4cb3cc6
x-vcs-revision: d1a8db0ec52d1c50071022e2e670bde7beea6c4c
---
Response body:
---
b''
---
So it stops on HTTP 401 Error.
Locally I hacked this by the below patch,
--- /tmp/pyppasearch.py
+++ /home/username/bin/pyppasearch.py
@@ -12,20 +12,23 @@
self.url = url
def search(self, lp, codename, cpu_arch, noexact, search):
- owner = lp.people[self.user]
- archive = owner.getPPAByName(distribution=lp.distributions["ubuntu"], name=self.name)
- binaries = archive.getPublishedBinaries(status='Published', binary_name=search, exact_match=not noexact)
+ try:
+ owner = lp.people[self.user]
+ archive = owner.getPPAByName(distribution=lp.distributions["ubuntu"], name=self.name)
+ binaries = archive.getPublishedBinaries(status='Published', binary_name=search, exact_match=not noexact)
- packages = []
- if len(binaries) > 0:
- for binary in binaries:
- distro_arch_series = binary.distro_arch_series_link
- binary_codename = distro_arch_series.split('/')[-2]
- binary_arch = distro_arch_series.split('/')[-1]
- if (codename is None or codename.lower() == binary_codename) and (cpu_arch is None or cpu_arch == binary_arch):
- packages.append(Package(self.user, self.name, binary.binary_package_name, binary.binary_package_version, binary_codename, binary_arch))
- return packages
+ packages = []
+ if len(binaries) > 0:
+ for binary in binaries:
+ distro_arch_series = binary.distro_arch_series_link
+ binary_codename = distro_arch_series.split('/')[-2]
+ binary_arch = distro_arch_series.split('/')[-1]
+ if (codename is None or codename.lower() == binary_codename) and (cpu_arch is None or cpu_arch == binary_arch):
+ packages.append(Package(self.user, self.name, binary.binary_package_name, binary.binary_package_version, binary_codename, binary_arch))
+ return packages
+ except:
+ return []
class Package:
def __init__(self, user, repo, name, version, series, arch):
but you can do this in other way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.