Giter Club home page Giter Club logo

pyppasearch's People

Contributors

anenasa avatar n0rbert avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

n0rbert tjakway

pyppasearch's Issues

For some reason pyppasearch.py finds fewer packages than Y PPA Manager

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.

y-ppa-manager_i3-gaps_bionic

Could you please elaborate why your script shows 1 line, while Y PPA Manager shows 12?

Handle 401 and possible other HTTP error codes/exceptions

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.