|
@@ -8,6 +8,21 @@ target_filename = "FIRMWARE.CUR"
|
8
|
8
|
target_drive = "REARM"
|
9
|
9
|
upload_disk = ""
|
10
|
10
|
|
|
11
|
+import os
|
|
12
|
+import subprocess
|
|
13
|
+
|
|
14
|
+#env_vars = subprocess.check_output('platformio run -t envdump')
|
|
15
|
+#env_vars = env_vars.split('\n')
|
|
16
|
+#for env in env_vars:
|
|
17
|
+# print env
|
|
18
|
+#exit(0)
|
|
19
|
+
|
|
20
|
+build_type = os.environ.get("BUILD_TYPE", 'Not Set')
|
|
21
|
+if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
|
|
22
|
+ exit(0)
|
|
23
|
+
|
|
24
|
+print '\nSearching for upload disk'
|
|
25
|
+
|
11
|
26
|
import platform
|
12
|
27
|
current_OS = platform.system()
|
13
|
28
|
|
|
@@ -37,6 +52,14 @@ if current_OS == 'Windows':
|
37
|
52
|
upload_disk = 'Disk not found'
|
38
|
53
|
target_file_found = False
|
39
|
54
|
target_drive_found = False
|
|
55
|
+
|
|
56
|
+ volume_info = subprocess.check_output('powershell -Command volume ')
|
|
57
|
+ volume_info = volume_info.split('\n')
|
|
58
|
+ for entry in volume_info:
|
|
59
|
+ if target_drive in entry and target_drive_found == False: # set upload if not found target file yet
|
|
60
|
+ target_drive_found = True
|
|
61
|
+ upload_disk = entry[ : entry.find(' ')] + ':'
|
|
62
|
+
|
40
|
63
|
for drive in drives:
|
41
|
64
|
final_drive_name = drive.strip().rstrip('\\') # typical result (string): 'C:'
|
42
|
65
|
# modified version of walklevel()
|
|
@@ -49,10 +72,6 @@ if current_OS == 'Windows':
|
49
|
72
|
num_sep_this = root.count(os.path.sep)
|
50
|
73
|
if num_sep + level <= num_sep_this:
|
51
|
74
|
del dirs[:]
|
52
|
|
- volume_info = subprocess.check_output('fsutil fsinfo volumeinfo ' + final_drive_name)
|
53
|
|
- if target_drive in volume_info and target_file_found == False: # set upload if not found target file yet
|
54
|
|
- target_drive_found = True
|
55
|
|
- upload_disk = root
|
56
|
75
|
if target_filename in files:
|
57
|
76
|
if target_file_found == False:
|
58
|
77
|
upload_disk = root
|