Skip to content

Commit cdd6005

Browse files
M7mdiskalvaromateo
authored andcommitted
ALL THE LOGS IN THE WORLD
1 parent 1d3d67f commit cdd6005

1 file changed

Lines changed: 51 additions & 10 deletions

File tree

webapp/store/snap_details_views.py

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,50 @@
1717
)
1818
from canonicalwebteam.exceptions import StoreApiError
1919
from canonicalwebteam.store_api.devicegw import DeviceGW
20-
from pybadges import badge
21-
2220
device_gateway = DeviceGW("snap", helpers.api_session)
23-
21+
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
2464
FIELDS = [
2565
"title",
2666
"summary",
@@ -213,19 +253,20 @@ def snap_details(snap_name):
213253
status_code = 200
214254

215255
context = _get_context_snap_details(snap_name)
216-
print(f"DEBUGGING: {snap_name}")
256+
print("----------------------------------------------------------------")
257+
print(f"DEBUGGING: {snap_name}",flush=True)
217258
try:
218259
extra_details = device_gateway.get_snap_details(
219260
snap_name, fields=FIELDS_EXTRA_DETAILS
220261
)
221262
except Exception as e:
263+
print("IT FAILED",flush=True)
222264
print(e)
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")
265+
traceback.print_exc()
266+
extra_details = None
267+
print("END_DEBUGGING",flush=True)
268+
269+
print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
229270

230271
if extra_details and extra_details["aliases"]:
231272
context["aliases"] = [

0 commit comments

Comments
 (0)