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.9KB

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