Fix Linux upload path detection (#16514)
This commit is contained in:
parent
b4ee420a37
commit
55b2af9464
@ -9,7 +9,9 @@ target_filename = "FIRMWARE.CUR"
|
|||||||
target_drive = "REARM"
|
target_drive = "REARM"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import getpass
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
current_OS = platform.system()
|
current_OS = platform.system()
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
@ -77,28 +79,26 @@ try:
|
|||||||
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
|
||||||
medias = os.listdir('/media') #
|
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
|
||||||
for media in medias:
|
if target_drive in drives: # If target drive is found, use it.
|
||||||
drives = os.listdir('/media/' + media) #
|
target_drive_found = True
|
||||||
if target_drive in drives and target_file_found == False: # set upload if not found target file yet
|
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
|
||||||
target_drive_found = True
|
else:
|
||||||
upload_disk = '/media/' + media + '/' + target_drive + '/'
|
|
||||||
for drive in drives:
|
for drive in drives:
|
||||||
try:
|
try:
|
||||||
files = os.listdir('/media/' + media + '/' + drive)
|
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if target_filename in files:
|
if target_filename in files:
|
||||||
if target_file_found == False:
|
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
|
||||||
upload_disk = '/media/' + media + '/' + drive + '/'
|
target_file_found = True
|
||||||
target_file_found = True
|
break
|
||||||
|
|
||||||
#
|
#
|
||||||
# set upload_port to drive if found
|
# set upload_port to drive if found
|
||||||
#
|
#
|
||||||
|
|
||||||
if target_file_found == True or target_drive_found == True:
|
if target_file_found or target_drive_found:
|
||||||
env.Replace(
|
env.Replace(
|
||||||
UPLOAD_FLAGS="-P$UPLOAD_PORT",
|
UPLOAD_FLAGS="-P$UPLOAD_PORT",
|
||||||
UPLOAD_PORT=upload_disk
|
UPLOAD_PORT=upload_disk
|
||||||
|
Loading…
Reference in New Issue
Block a user