My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

download_mks_assets.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # download_mks_assets.py
  3. # Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
  4. #
  5. import pioutil
  6. if pioutil.is_pio_build():
  7. Import("env")
  8. import os,requests,zipfile,tempfile,shutil
  9. url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
  10. deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR")
  11. zip_path = os.path.join(deps_path, "mks-assets.zip")
  12. assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")
  13. def download_mks_assets():
  14. print("Downloading MKS Assets")
  15. r = requests.get(url, stream=True)
  16. # the user may have a very clean workspace,
  17. # so create the PROJECT_LIBDEPS_DIR directory if not exits
  18. if os.path.exists(deps_path) == False:
  19. os.mkdir(deps_path)
  20. with open(zip_path, 'wb') as fd:
  21. for chunk in r.iter_content(chunk_size=128):
  22. fd.write(chunk)
  23. def copy_mks_assets():
  24. print("Copying MKS Assets")
  25. output_path = tempfile.mkdtemp()
  26. zip_obj = zipfile.ZipFile(zip_path, 'r')
  27. zip_obj.extractall(output_path)
  28. zip_obj.close()
  29. if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False:
  30. os.unlink(assets_path)
  31. if os.path.exists(assets_path) == False:
  32. os.mkdir(assets_path)
  33. base_path = ''
  34. for filename in os.listdir(output_path):
  35. base_path = filename
  36. for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')):
  37. shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path)
  38. for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')):
  39. shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', filename), assets_path)
  40. shutil.rmtree(output_path, ignore_errors=True)
  41. if os.path.exists(zip_path) == False:
  42. download_mks_assets()
  43. if os.path.exists(assets_path) == False:
  44. copy_mks_assets()