|
|
@ -10,18 +10,16 @@ target_drive = "REARM"
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import platform
|
|
|
|
current_OS = platform.system()
|
|
|
|
current_OS = platform.system()
|
|
|
|
|
|
|
|
Import("env")
|
|
|
|
|
|
|
|
|
|
|
|
#env_vars = subprocess.check_output('platformio run -t envdump')
|
|
|
|
def detect_error(e):
|
|
|
|
#env_vars = env_vars.split('\n')
|
|
|
|
print '\nUnable to find destination disk (' + e + ')\n' \
|
|
|
|
#for env in env_vars:
|
|
|
|
'Please select it in platformio.ini using the upload_port keyword ' \
|
|
|
|
# print env
|
|
|
|
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html)\n' \
|
|
|
|
#exit(0)
|
|
|
|
'or copy the firmware (.pioenvs/' + env.get('PIOENV') + '/firmware.bin) manually to the appropriate disk\n'
|
|
|
|
|
|
|
|
|
|
|
|
build_type = os.environ.get("BUILD_TYPE", 'Not Set')
|
|
|
|
|
|
|
|
if build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set' :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
if current_OS == 'Windows':
|
|
|
|
if current_OS == 'Windows':
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
|
|
|
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
|
|
|
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
|
|
|
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
|
|
@ -30,12 +28,14 @@ if build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# get all drives on this computer
|
|
|
|
# get all drives on this computer
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
# typical result (string): 'Drives: C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
|
|
|
|
driveStr = subprocess.check_output("fsutil fsinfo drives") # typical result (string): 'Drives: C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
|
|
|
|
driveStr = subprocess.check_output("fsutil fsinfo drives")
|
|
|
|
driveStr = driveStr.strip().lstrip('Drives: ') # typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
|
|
|
|
# typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
|
|
|
|
drives = driveStr.split() # typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\']
|
|
|
|
driveStr = driveStr.strip().lstrip('Drives: ')
|
|
|
|
|
|
|
|
# typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\',
|
|
|
|
|
|
|
|
# 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\']
|
|
|
|
|
|
|
|
drives = driveStr.split()
|
|
|
|
|
|
|
|
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
target_file_found = False
|
|
|
|
target_file_found = False
|
|
|
@ -60,21 +60,17 @@ if build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
Import("env")
|
|
|
|
|
|
|
|
env.Replace(
|
|
|
|
env.Replace(
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print 'upload disk: ', upload_disk
|
|
|
|
print 'upload disk: ', upload_disk
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print '\nUnable to find destination disk. File must be copied manually. \n'
|
|
|
|
detect_error('Autodetect Error')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if current_OS == 'Linux':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif current_OS == 'Linux':
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
|
|
|
|
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
target_file_found = False
|
|
|
|
target_file_found = False
|
|
|
|
target_drive_found = False
|
|
|
|
target_drive_found = False
|
|
|
@ -100,23 +96,18 @@ if build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
Import("env")
|
|
|
|
|
|
|
|
env.Replace(
|
|
|
|
env.Replace(
|
|
|
|
UPLOAD_FLAGS="-P$UPLOAD_PORT",
|
|
|
|
UPLOAD_FLAGS="-P$UPLOAD_PORT",
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print 'upload disk: ', upload_disk
|
|
|
|
print 'upload disk: ', upload_disk
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print '\nUnable to find destination disk. File must be copied manually. \n'
|
|
|
|
detect_error('Autodetect Error')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if current_OS == 'Darwin': # MAC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif current_OS == 'Darwin': # MAC
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
|
|
|
|
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
upload_disk = 'Disk not found'
|
|
|
|
drives = os.listdir('/Volumes') # human readable names
|
|
|
|
drives = os.listdir('/Volumes') # human readable names
|
|
|
|
target_file_found = False
|
|
|
|
target_file_found = False
|
|
|
@ -139,10 +130,12 @@ if build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
if target_file_found == True or target_drive_found == True:
|
|
|
|
Import("env")
|
|
|
|
|
|
|
|
env.Replace(
|
|
|
|
env.Replace(
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
UPLOAD_PORT=upload_disk
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print '\nupload disk: ', upload_disk, '\n'
|
|
|
|
print '\nupload disk: ', upload_disk, '\n'
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print '\nUnable to find destination disk. File must be copied manually. \n'
|
|
|
|
detect_error('Autodetect Error')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
detect_error(str(e))
|
|
|
|