|
@@ -9,7 +9,9 @@ target_filename = "FIRMWARE.CUR"
|
9
|
9
|
target_drive = "REARM"
|
10
|
10
|
|
11
|
11
|
import os
|
|
12
|
+import getpass
|
12
|
13
|
import platform
|
|
14
|
+
|
13
|
15
|
current_OS = platform.system()
|
14
|
16
|
Import("env")
|
15
|
17
|
|
|
@@ -77,28 +79,26 @@ try:
|
77
|
79
|
upload_disk = 'Disk not found'
|
78
|
80
|
target_file_found = False
|
79
|
81
|
target_drive_found = False
|
80
|
|
- medias = os.listdir('/media') #
|
81
|
|
- for media in medias:
|
82
|
|
- drives = os.listdir('/media/' + media) #
|
83
|
|
- if target_drive in drives and target_file_found == False: # set upload if not found target file yet
|
84
|
|
- target_drive_found = True
|
85
|
|
- upload_disk = '/media/' + media + '/' + target_drive + '/'
|
|
82
|
+ drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
|
|
83
|
+ if target_drive in drives: # If target drive is found, use it.
|
|
84
|
+ target_drive_found = True
|
|
85
|
+ upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
|
|
86
|
+ else:
|
86
|
87
|
for drive in drives:
|
87
|
88
|
try:
|
88
|
|
- files = os.listdir('/media/' + media + '/' + drive)
|
|
89
|
+ files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
|
89
|
90
|
except:
|
90
|
91
|
continue
|
91
|
92
|
else:
|
92
|
93
|
if target_filename in files:
|
93
|
|
- if target_file_found == False:
|
94
|
|
- upload_disk = '/media/' + media + '/' + drive + '/'
|
95
|
|
- target_file_found = True
|
96
|
|
-
|
|
94
|
+ upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
|
|
95
|
+ target_file_found = True
|
|
96
|
+ break
|
97
|
97
|
#
|
98
|
98
|
# set upload_port to drive if found
|
99
|
99
|
#
|
100
|
100
|
|
101
|
|
- if target_file_found == True or target_drive_found == True:
|
|
101
|
+ if target_file_found or target_drive_found:
|
102
|
102
|
env.Replace(
|
103
|
103
|
UPLOAD_FLAGS="-P$UPLOAD_PORT",
|
104
|
104
|
UPLOAD_PORT=upload_disk
|