# Run this first if running everything in non-VSCode ide import os option = "upload" # build, upload, clean, or read if os.name == 'nt': platformio = os.path.join(os.path.expanduser('~'), '.platformio', 'penv', 'Scripts', 'platformio.exe') else: platformio = os.path.join(os.path.expanduser('~'), '.platformio', 'penv', 'bin', 'platformio') if not os.path.exists(platformio): # Platformio not exist, run setup from web import requests, base64 s = requests.Session() s.trust_env = None # for anyone running on proxy r = s.get('https://api.github.com/repos/platformio/platformio-core-installer/contents/get-platformio.py?ref=develop').json() exec(base64.b64decode(r['content'])) params = { 'build': 'run', 'upload': 'run --target upload', 'clean': 'run --target clean', 'read': 'device monitor' } os.system(f'{platformio} {params[option]}') # put one of the three function from above