ESP8266 Treppenlichtsteuerung mit OTA zum Firmware Upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extra_script.py 595B

1234567891011121314151617181920
  1. import os
  2. # https://stackoverflow.com/questions/49449430/python-bytes-to-c-array-like-xxd-program/49450004
  3. def bytes_to_c_arr(data, lowercase=True):
  4. return [format(b, '#04x' if lowercase else '#04X') for b in data]
  5. src = 'include/http'
  6. out = 'include'
  7. for f in os.listdir(src):
  8. with open(f'{src}/{f}', 'rb') as f_in:
  9. with open(f'{out}/{f}.h', 'wb') as f_out:
  10. buf = 'const char {}[] = {{{}}};'.format(
  11. f.replace('.', '_'),
  12. ', '.join(bytes_to_c_arr(f_in.read()))
  13. )
  14. f_out.write(buf.encode(encoding='ascii'))