|
17 | 17 | ) |
18 | 18 | from canonicalwebteam.exceptions import StoreApiError |
19 | 19 | from canonicalwebteam.store_api.devicegw import DeviceGW |
20 | | -device_gateway = DeviceGW("snap", helpers.api_session) |
21 | 20 | from pybadges import badge |
22 | | -import sys |
23 | | - |
24 | | - |
25 | | -# --- Patch device_gateway.session.get to log full request/response --- |
26 | | -original_get = device_gateway.session.get |
27 | | - |
28 | | -def debug_get(url, *args, **kwargs): |
29 | | - if "nushell" in url: |
30 | | - print(f"\nDEBUG: GET request to URL: {url}") |
31 | | - print(f"DEBUG: kwargs: {kwargs}") |
32 | | - response = original_get(url, *args, **kwargs) |
33 | | - if "nushell" in url: |
34 | | - print(f"DEBUG: Response status: {response.status_code}") |
35 | | - print(f"DEBUG: Response headers: {response.headers}") |
36 | | - print(f"DEBUG: Response text (first 500 chars): {response.text[:500]}") |
37 | | - sys.stdout.flush() |
38 | | - return response |
39 | | - |
40 | | -device_gateway.session.get = debug_get |
41 | | - |
42 | | -# --- Patch get_snap_details to log input, output, and exceptions --- |
43 | | -original_get_snap_details = device_gateway.get_snap_details |
44 | | - |
45 | | -def debug_get_snap_details(snap_name, fields=None): |
46 | | - if snap_name == "nushell": |
47 | | - print(f"\nDEBUG: Calling get_snap_details with snap_name={snap_name}, fields={fields}") |
48 | | - sys.stdout.flush() |
49 | | - try: |
50 | | - result = original_get_snap_details(snap_name, fields=fields) |
51 | | - print(f"DEBUG: get_snap_details result:\n{result}") |
52 | | - sys.stdout.flush() |
53 | | - return result |
54 | | - except Exception as e: |
55 | | - print(f"DEBUG: Exception in get_snap_details: {e}") |
56 | | - sys.stdout.flush() |
57 | | - import traceback |
58 | | - traceback.print_exc() |
59 | | - raise |
60 | | - |
61 | | -device_gateway.get_snap_details = debug_get_snap_details |
62 | | - |
63 | | -import traceback |
| 21 | + |
| 22 | +device_gateway = DeviceGW("snap", helpers.api_session) |
| 23 | + |
64 | 24 | FIELDS = [ |
65 | 25 | "title", |
66 | 26 | "summary", |
@@ -253,20 +213,19 @@ def snap_details(snap_name): |
253 | 213 | status_code = 200 |
254 | 214 |
|
255 | 215 | context = _get_context_snap_details(snap_name) |
256 | | - print("----------------------------------------------------------------") |
257 | | - print(f"DEBUGGING: {snap_name}",flush=True) |
| 216 | + print(f"DEBUGGING: {snap_name}") |
258 | 217 | try: |
259 | 218 | extra_details = device_gateway.get_snap_details( |
260 | 219 | snap_name, fields=FIELDS_EXTRA_DETAILS |
261 | 220 | ) |
262 | 221 | except Exception as e: |
263 | | - print("IT FAILED",flush=True) |
264 | 222 | print(e) |
265 | | - traceback.print_exc() |
266 | | - extra_details = None |
267 | | - print("END_DEBUGGING",flush=True) |
268 | | - |
269 | | - print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE") |
| 223 | + response = requests.get( |
| 224 | + f"https://api.snapcraft.io/api/v1/snaps/details/{snap_name}?fields=aliases", |
| 225 | + headers={"X-Ubuntu-Series": "16"}) |
| 226 | + print(response.status_code) |
| 227 | + print(response.text) |
| 228 | + print("END_DEBUGGING") |
270 | 229 |
|
271 | 230 | if extra_details and extra_details["aliases"]: |
272 | 231 | context["aliases"] = [ |
|
0 commit comments