27 lines
891 B
Python
27 lines
891 B
Python
# Run this first if running everything in non-VSCode ide
|
|
import os
|
|
|
|
option = "build" # 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):
|
|
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
|