oboyone / mb_thermal_printer

Here are the scripts and steps i took to create a momir basic thermal printer, using a cheap thermal printer and a raspberry pi
28 stars 0 forks source link

download_images_from_scryfall.py doesn't create the directories #2

Closed CollinLeishman closed 7 months ago

CollinLeishman commented 8 months ago

Here is what I had to do:

/Users/cleish/code/mb_thermal_printer/venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Traceback (most recent call last):
  File "/Users/cleish/code/mb_thermal_printer/download_images_from_scryfall.py", line 16, in <module>
    urllib.request.urlretrieve(url, save_path) 
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 249, in urlretrieve
    tfp = open(filename, 'wb')
FileNotFoundError: [Errno 2] No such file or directory: '0/Asmoranomardicadaistinaculdacar.jpg'
(venv) cleish@Collins-MacBook-Pro mb_thermal_printer % mkdir 0
CollinLeishman commented 8 months ago

Need something like this

import os

if not os.path.exists(str(cmc)):
    os.makedirs(str(cmc))