Theflame47 commited on
Commit
c579086
·
verified ·
1 Parent(s): 2e0845e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -62,6 +62,7 @@ def _find_first_valid_pair(logs: List[str]) -> Dict[str, Any]:
62
  variants = vr.get("variants")
63
  if isinstance(variants, list) and variants:
64
  _log(logs, f"FOUND {len(variants)} variants")
 
65
 
66
  return {
67
  "blueprint": bp,
@@ -73,6 +74,10 @@ def _find_first_valid_pair(logs: List[str]) -> Dict[str, Any]:
73
  "GET",
74
  f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/shipping.json",
75
  ),
 
 
 
 
76
  }
77
 
78
  raise RuntimeError("No blueprint/provider pair with variants found.")
@@ -122,6 +127,7 @@ def _build_product(blob: Dict[str, Any], currency: str, logs: List[str]) -> Dict
122
  },
123
  "description": description,
124
  "variants": snapshot,
 
125
  "raw": blob,
126
  }
127
 
@@ -141,13 +147,6 @@ def run(currency: str) -> Generator[Tuple[str, str], None, None]:
141
  _log(logs, f"SHOP_LIST {json.dumps(shops)}")
142
  yield flush()
143
 
144
- fd, path = tempfile.mkstemp(prefix="shops_", suffix=".json")
145
- os.close(fd)
146
- with open(path, "w", encoding="utf-8") as f:
147
- json.dump(shops, f, indent=2)
148
- _log(logs, f"SHOPS_JSON_WRITTEN {path}")
149
- yield flush()
150
-
151
  blob = _find_first_valid_pair(logs)
152
  yield flush()
153
 
 
62
  variants = vr.get("variants")
63
  if isinstance(variants, list) and variants:
64
  _log(logs, f"FOUND {len(variants)} variants")
65
+ _log(logs, f"Blueprint {bp_id} / Provider {p_id}: fetching print areas")
66
 
67
  return {
68
  "blueprint": bp,
 
74
  "GET",
75
  f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/shipping.json",
76
  ),
77
+ "printAreas": _req(
78
+ "GET",
79
+ f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/print_areas.json",
80
+ ),
81
  }
82
 
83
  raise RuntimeError("No blueprint/provider pair with variants found.")
 
127
  },
128
  "description": description,
129
  "variants": snapshot,
130
+ "printAreas": blob.get("printAreas"),
131
  "raw": blob,
132
  }
133
 
 
147
  _log(logs, f"SHOP_LIST {json.dumps(shops)}")
148
  yield flush()
149
 
 
 
 
 
 
 
 
150
  blob = _find_first_valid_pair(logs)
151
  yield flush()
152