@@ -88,51 +88,57 @@ def get_ports(self):
88
88
89
89
def download (self , action , file_to_load , com_port ):
90
90
# Download application to Propeller
91
+ # Set loading flag to prevent interruption
91
92
self .loading = True
92
93
93
- # Patch - see if __init__ is back in full operation
94
- if not self .appdir or self .appdir == "" or self .appdir == "/" :
95
- self .logger .info ('ERROR: LOADER FOLDER NOT FOUND!' )
96
- return False , ' ' , ' '
97
- # Patch below removed temporarily during platform testing
98
- # # Patch until we figure out why the __init__ is not getting called
99
- # if not self.appdir or self.appdir == "" or self.appdir == "/":
100
- # # realpath expands to full path if __file__ or sys.argv[0] contains just a filename
101
- # self.appdir = os.path.dirname(os.path.realpath(__file__))
102
- # if self.appdir == "" or self.appdir == "/":
103
- # # launch path is blank; try extracting from argv
104
- # self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
105
-
106
- # Set command download to RAM or EEPROM and to run afterward download
107
- command = []
108
- if self .loaderAction [action ]["compile-options" ] != "" :
109
- # if RAM/EEPROM compile-option not empty, add it to the list
110
- command .extend ([self .loaderAction [action ]["compile-options" ]])
111
- command .extend (["-r" ])
112
-
113
- # Add requested port
114
- if com_port is not None :
115
- # Find port(s) named com_port
116
- targetWiFi = [l for l in self .wports if isWiFiName (l , com_port )]
117
- if len (targetWiFi ) > 0 :
118
- # Found Wi-Fi match
119
- self .logger .debug ('Requested port %s is at %s' , com_port , getWiFiIP (targetWiFi [0 ]))
120
- command .extend (["-i" ])
121
- command .extend ([getWiFiIP (targetWiFi [0 ]).encode ('ascii' , 'ignore' )])
122
- else :
123
- # Not Wi-Fi match, should be COM port
124
- self .logger .debug ('Requested port is %s' , com_port )
125
- command .extend (["-p" ])
126
- command .extend ([com_port .encode ('ascii' , 'ignore' )])
127
-
128
- # Add target file
129
- command .extend ([file_to_load .name .encode ('ascii' , 'ignore' ).replace ('\\ ' , '/' )])
130
-
131
- # Download
132
- (success , out , err ) = loader (self , command )
133
-
134
- # Return results
135
- return success , out or '' , err or ''
94
+ try :
95
+ # Patch - see if __init__ is back in full operation
96
+ if not self .appdir or self .appdir == "" or self .appdir == "/" :
97
+ self .logger .info ('ERROR: LOADER FOLDER NOT FOUND!' )
98
+ return False , ' ' , ' '
99
+ # Patch below removed temporarily during platform testing
100
+ # # Patch until we figure out why the __init__ is not getting called
101
+ # if not self.appdir or self.appdir == "" or self.appdir == "/":
102
+ # # realpath expands to full path if __file__ or sys.argv[0] contains just a filename
103
+ # self.appdir = os.path.dirname(os.path.realpath(__file__))
104
+ # if self.appdir == "" or self.appdir == "/":
105
+ # # launch path is blank; try extracting from argv
106
+ # self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
107
+
108
+ # Set command download to RAM or EEPROM and to run afterward download
109
+ command = []
110
+ if self .loaderAction [action ]["compile-options" ] != "" :
111
+ # if RAM/EEPROM compile-option not empty, add it to the list
112
+ command .extend ([self .loaderAction [action ]["compile-options" ]])
113
+ command .extend (["-r" ])
114
+
115
+ # Add requested port
116
+ if com_port is not None :
117
+ # Find port(s) named com_port
118
+ targetWiFi = [l for l in self .wports if isWiFiName (l , com_port )]
119
+ if len (targetWiFi ) > 0 :
120
+ # Found Wi-Fi match
121
+ self .logger .debug ('Requested port %s is at %s' , com_port , getWiFiIP (targetWiFi [0 ]))
122
+ command .extend (["-i" ])
123
+ command .extend ([getWiFiIP (targetWiFi [0 ]).encode ('ascii' , 'ignore' )])
124
+ else :
125
+ # Not Wi-Fi match, should be COM port
126
+ self .logger .debug ('Requested port is %s' , com_port )
127
+ command .extend (["-p" ])
128
+ command .extend ([com_port .encode ('ascii' , 'ignore' )])
129
+
130
+ # Add target file
131
+ command .extend ([file_to_load .name .encode ('ascii' , 'ignore' ).replace ('\\ ' , '/' )])
132
+
133
+ # Download
134
+ (success , out , err ) = loader (self , command )
135
+
136
+ # Return results
137
+ return success , out or '' , err or ''
138
+
139
+ finally :
140
+ # Done, clear loading flag to process other events
141
+ self .loading = False
136
142
137
143
138
144
def loader (self , cmdOptions ):
0 commit comments