File: 03_no-launchpad.patch

package info (click to toggle)
software-properties 0.111-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,944 kB
  • sloc: python: 8,238; makefile: 19; sh: 18; xml: 10
file content (78 lines) | stat: -rw-r--r-- 2,609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
From 8163fc1c2c0c3b74b86a801d1b3c3bf7d8757fc6 Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <mak@debian.org>
Date: Sun, 8 Jan 2023 23:28:12 +0100
Subject: [PATCH] Disable Launchpad support

This is only used for PPA support, which should be inert on Debian
anyway.
---
 softwareproperties/ppa.py | 8 +++++++-
 tests/test_shortcuts.py   | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

--- a/softwareproperties/ppa.py
+++ b/softwareproperties/ppa.py
@@ -22,7 +22,6 @@
 
 from gettext import gettext as _
 
-from launchpadlib.launchpad import Launchpad
 from lazr.restfulclient.errors import (NotFound, BadRequest, Unauthorized)
 
 from softwareproperties.shortcuthandler import (ShortcutHandler, ShortcutException,
@@ -34,6 +33,11 @@
 
 from urllib.parse import urlparse
 
+try:
+    from launchpadlib.launchpad import Launchpad
+except ImportError as e:
+    Launchpad = None
+
 
 PPA_URI_FORMAT = 'https://ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/'
 PRIVATE_PPA_URI_FORMAT = 'https://private-ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/'
@@ -103,6 +107,8 @@
 
     @property
     def lp(self):
+        if not Launchpad:
+            return None
         if not self._lp:
             if self._lp_anon:
                 login_func = Launchpad.login_anonymously
--- a/tests/test_shortcuts.py
+++ b/tests/test_shortcuts.py
@@ -11,11 +11,14 @@
 from aptsources.sourceslist import (SourceEntry, Deb822SourceEntry)
 from contextlib import contextmanager
 from http.client import HTTPException
-from launchpadlib.launchpad import Launchpad
 from lazr.restfulclient.errors import Unauthorized
 from urllib.request import urlopen
 from urllib.error import URLError
 from unittest.mock import (patch, Mock)
+try:
+    from launchpadlib.launchpad import Launchpad
+except ImportError as e:
+    Launchpad = None
 
 sys.path.insert(0, "..")
 
@@ -83,6 +86,7 @@
     return True
 
 def mock_login_with(*args, **kwargs):
+    assert Launchpad
     has_subscription = kwargs.pop("has_subscription", True)
 
     _lp = Launchpad.login_anonymously(*args, **kwargs)
@@ -218,6 +222,8 @@
     def test_shortcut_private_ppa(self):
         # this is the same tests as the public ppa, but login=True will use the mocked lp instance
         # this *does not* actually test/verify this works with a real private ppa; that must be done manually
+        if not Launchpad:
+            return
         with patch('launchpadlib.launchpad.Launchpad.login_with', new=mock_login_with):
             for ppa in VALID_PPAS:
                 for shortcut in self.create_handlers(ppa, PPAShortcutHandler, login=True):