@@ -110,15 +110,11 @@ def spiCountBoards(sub20Mapper, maxRetry=MAX_SPI_RETRY, waitRetry=WAIT_SPI_RETRY
110110 if attempt != 0 :
111111 time .sleep (waitRetry )
112112
113- p = subprocess .Popen ('/usr/local/bin/countBoards %s' % sub20SN , shell = True ,
114- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
113+ p = subprocess .Popen (['/usr/local/bin/countBoards' , str (sub20SN ),
114+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
115+ text = True )
115116 output , output2 = p .communicate ()
116- try :
117- output = output .decode ('ascii' )
118- output2 = output2 .decode ('ascii' )
119- except AttributeError :
120- pass
121-
117+
122118 if p .returncode == 0 :
123119 aspSUB20Logger .warning ("%s: SUB-20 S/N %s command %i of %i returned %i; '%s;%s'" , inspect .stack ()[0 ][3 ], sub20SN , attempt , maxRetry , p .returncode , output , output2 )
124120 status = False
@@ -187,7 +183,7 @@ def stop(self):
187183
188184 @staticmethod
189185 def _run_command (sub20SN , device_count , devices , spi_commands , maxRetry = MAX_SPI_RETRY , waitRetry = WAIT_SPI_RETRY ):
190- command = ["/usr/local/bin/sendARXDevice" , sub20SN , str (device_count )]
186+ command = ["/usr/local/bin/sendARXDevice" , str ( sub20SN ) , str (device_count )]
191187 for dev ,cmd in zip (devices ,spi_commands ):
192188 command .append (str (dev ))
193189 command .append ("0x%04X" % cmd )
@@ -286,15 +282,11 @@ def psuSend(sub20SN, psuAddress, state, maxRetry=MAX_I2C_RETRY, waitRetry=WAIT_I
286282 time .sleep (waitRetry )
287283
288284 try :
289- p = subprocess .Popen ('/usr/local/bin/onoffPSU %s 0x%02X %s' % (sub20SN , psuAddress , str (state )), shell = True ,
290- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
285+ p = subprocess .Popen (['/usr/local/bin/onoffPSU' , str (sub20SN ), '0x%02X' % psuAddress , str (state )],
286+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
287+ text = True )
291288 output , output2 = p .communicate ()
292- try :
293- output = output .decode ('ascii' )
294- output2 = output2 .decode ('ascii' )
295- except AttributeError :
296- pass
297-
289+
298290 if p .returncode == 0 :
299291 status = True
300292 break
@@ -319,22 +311,18 @@ def psuRead(sub20SN, psuAddress, maxRetry=MAX_I2C_RETRY, waitRetry=WAIT_I2C_RETR
319311 time .sleep (waitRetry )
320312
321313 try :
322- p = subprocess .Popen ('/usr/local/bin/readPSU %s 0x%02X' % (self .sub20SN , self .deviceAddress ), shell = True ,
323- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
314+ p = subprocess .Popen (['/usr/local/bin/readPSU' , str (sub20SN ), '0x%02X' % deviceAddress ],
315+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
316+ text = True )
324317 output , output2 = p .communicate ()
325- try :
326- output = output .decode ('ascii' )
327- output2 = output2 .decode ('ascii' )
328- except AttributeError :
329- pass
330-
318+
331319 if p .returncode == 0 :
332320 psu , desc , onoffHuh , statusHuh , voltageV , currentA , = output .replace ('\n ' , '' ).split (None , 5 )
333321 data = {'address' : psu ,
334322 'description' : desc ,
335323 'voltage' : float (voltageV )
336324 'current' : float (currentA )
337- 'onoff' : self . onoff = '%-3s' % onoffHuh
325+ 'onoff' : '%-3s' % onoffHuh
338326 'status' : statusHuh
339327 }
340328 break ;
@@ -359,14 +347,10 @@ def psuCountTemperature(sub20SN, maxRetry=MAX_I2C_RETRY, waitRetry=WAIT_I2C_RETR
359347 time .sleep (waitRetry )
360348
361349 try :
362- p = subprocess .Popen ('/usr/local/bin/countThermometers %s' % sub20SN , shell = True ,
363- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
350+ p = subprocess .Popen (['/usr/local/bin/countThermometers' , str (sub20SN )],
351+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
352+ text = True )
364353 output , output2 = p .communicate ()
365- try :
366- output = output .decode ('ascii' )
367- output2 = output2 .decode ('ascii' )
368- except AttributeError :
369- pass
370354
371355 if p .returncode == 0 :
372356 aspSUB20Logger .warning ("%s: SUB-20 S/N %s command %i of %i returned %i; '%s;%s'" , inspect .stack ()[0 ][3 ], sub20SN , attempt , maxRetry , p .returncode , output , output2 )
@@ -391,15 +375,11 @@ def psuTemperature(sub20SN, maxRetry=MAX_I2C_RETRY, waitRetry=WAIT_I2C_RETRY):
391375 time .sleep (waitRetry )
392376
393377 try :
394- p = subprocess .Popen ('/usr/local/bin/readThermometers %s' % sub20SN , shell = True ,
395- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
378+ p = subprocess .Popen (['/usr/local/bin/readThermometers' , str (sub20SN )],
379+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
380+ text = True )
396381 output , output2 = p .communicate ()
397- try :
398- output = output .decode ('ascii' )
399- output2 = output2 .decode ('ascii' )
400- except AttributeError :
401- pass
402-
382+
403383 if p .returncode != 0 :
404384 aspSUB20Logger .warning ("%s: SUB-20 S/N %s command %i of %i returned %i; '%s;%s'" , inspect .stack ()[0 ][3 ], sub20SN , attempt , maxRetry , p .returncode , output , output2 )
405385 else :
@@ -433,15 +413,11 @@ def rs485CountBoards(sub20Mapper, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485
433413 if attempt != 0 :
434414 time .sleep (waitRetry )
435415
436- p = subprocess .Popen ('/usr/local/bin/countPICs %s' % sub20SN , shell = True ,
437- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
416+ p = subprocess .Popen (['/usr/local/bin/countPICs' , str (sub20SN )],
417+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
418+ text = True )
438419 output , output2 = p .communicate ()
439- try :
440- output = output .decode ('ascii' )
441- output2 = output2 .decode ('ascii' )
442- except AttributeError :
443- pass
444-
420+
445421 if p .returncode == 0 :
446422 aspSUB20Logger .warning ("%s: SUB-20 S/N %s command %i of %i returned %i; '%s;%s'" , inspect .stack ()[0 ][3 ], sub20SN , attempt , maxRetry , p .returncode , output , output2 )
447423 status = False
@@ -471,15 +447,11 @@ def rs485Reset(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RETR
471447 board_success = False
472448 for attempt in range (maxRetry + 1 ):
473449 try :
474- p = subprocess .Popen ('/usr/local/bin/sendPICDevice %s %s RSET' % (sub20SN , board ), shell = True ,
475- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
450+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , str (sub20SN ), str (board ), ' RSET' ],
451+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
452+ text = True )
476453 output , output2 = p .communicate ()
477- try :
478- output = output .decode ('ascii' )
479- output2 = output2 .decode ('ascii' )
480- except AttributeError :
481- pass
482-
454+
483455 if p .returncode == 0 :
484456 board_success = True
485457 break
@@ -512,15 +484,11 @@ def rs485Sleep(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RETR
512484 board_success = False
513485 for attempt in range (maxRetry + 1 ):
514486 try :
515- p = subprocess .Popen ('/usr/local/bin/sendPICDevice %s %s SLEP' % (sub20SN , board ), shell = True ,
516- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
487+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , str (sub20SN ), str (board ), ' SLEP' ],
488+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
489+ text = True )
517490 output , output2 = p .communicate ()
518- try :
519- output = output .decode ('ascii' )
520- output2 = output2 .decode ('ascii' )
521- except AttributeError :
522- pass
523-
491+
524492 if p .returncode == 0 :
525493 board_success = True
526494 break
@@ -548,15 +516,11 @@ def rs485Wake(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RETRY
548516 board_success = False
549517 for attempt in range (maxRetry + 1 ):
550518 try :
551- p = subprocess .Popen ('/usr/local/bin/sendPICDevice %s %s WAKE' % (sub20SN , board ), shell = True ,
552- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
519+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , str (sub20SN ), str (board ), 'WAKE' ],
520+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
521+ text = True )
553522 output , output2 = p .communicate ()
554- try :
555- output = output .decode ('ascii' )
556- output2 = output2 .decode ('ascii' )
557- except AttributeError :
558- pass
559-
523+
560524 if p .returncode == 0 :
561525 board_success = True
562526 break
@@ -594,15 +558,11 @@ def rs485Check(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RETR
594558 board_success = False
595559 for attempt in range (maxRetry + 1 ):
596560 try :
597- p = subprocess .Popen ('/usr/local/bin/sendPICDevice -v -d %s %s ECHO%s' % (sub20SN , board , data ), shell = True ,
598- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
561+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , '-v' , '-d' , str (sub20SN ), str (board ), 'ECHO%s' % data ],
562+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
563+ text = True )
599564 output , output2 = p .communicate ()
600- try :
601- output = output .decode ('ascii' )
602- output2 = output2 .decode ('ascii' )
603- except AttributeError :
604- pass
605-
565+
606566 if p .returncode == 0 and output .find (data ) != - 1 :
607567 board_success = True
608568 break
@@ -638,15 +598,11 @@ def rs485SetTime(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RE
638598 board_success = False
639599 for attempt in range (maxRetry + 1 ):
640600 try :
641- p = subprocess .Popen ('/usr/local/bin/sendPICDevice %s %s STIM%s' % (sub20SN , board , data ), shell = True ,
642- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
601+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , str (sub20SN ), str (board ), ' STIM%s' % data ],
602+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
603+ text = True )
643604 output , output2 = p .communicate ()
644- try :
645- output = output .decode ('ascii' )
646- output2 = output2 .decode ('ascii' )
647- except AttributeError :
648- pass
649-
605+
650606 if p .returncode == 0 :
651607 board_success = True
652608 break
@@ -684,15 +640,11 @@ def rs485GetTime(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RE
684640 board_success = False
685641 for attempt in range (maxRetry + 1 ):
686642 try :
687- p = subprocess .Popen ('/usr/local/bin/sendPICDevice -v -d %s %s GTIM' % (sub20SN , board ), shell = True ,
688- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
643+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , '-v' , '-d' , str (sub20SN ), str (board ), 'GTIM' ],
644+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
645+ text = True )
689646 output , output2 = p .communicate ()
690- try :
691- output = output .decode ('ascii' )
692- output2 = output2 .decode ('ascii' )
693- except AttributeError :
694- pass
695-
647+
696648 mtch = gtimRE .search (output )
697649 if mtch is not None :
698650 gtim_data = mtch .group ('gtim' )
@@ -731,15 +683,11 @@ def rs485Power(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RETR
731683 board_success = False
732684 for attempt in range (maxRetry + 1 ):
733685 try :
734- p = subprocess .Popen ('/usr/local/bin/sendPICDevice -v -d %s %s CURA' % (sub20SN , board ), shell = True ,
735- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
686+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , '-v' , '-d' , str (sub20SN ), str (board ), 'CURA' ],
687+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
688+ text = True )
736689 output , output2 = p .communicate ()
737- try :
738- output = output .decode ('ascii' )
739- output2 = output2 .decode ('ascii' )
740- except AttributeError :
741- pass
742-
690+
743691 if p .returncode == 0 :
744692 for line in filter (lambda x : x .find (' mA' ) != - 1 , output .split ('\n ' )):
745693 mtch = curaRE .search (line )
@@ -778,15 +726,11 @@ def rs485RFPower(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS485_RE
778726 board_success = False
779727 for attempt in range (maxRetry + 1 ):
780728 try :
781- p = subprocess .Popen ('/usr/local/bin/sendPICDevice -v -d %s %s CURA' % (sub20SN , board ), shell = True ,
782- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
729+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , '-v' , '-d' , str (sub20SN ), str (board ), 'POWA' ],
730+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
731+ text = True )
783732 output , output2 = p .communicate ()
784- try :
785- output = output .decode ('ascii' )
786- output2 = output2 .decode ('ascii' )
787- except AttributeError :
788- pass
789-
733+
790734 if p .returncode == 0 :
791735 for line in filter (lambda x : x .find (' uW' ) != - 1 , output .split ('\n ' )):
792736 mtch = powaRE .search (line )
@@ -825,15 +769,11 @@ def rs485Temperature(sub20Mapper2, maxRetry=MAX_RS485_RETRY, waitRetry=WAIT_RS48
825769 board_success = False
826770 for attempt in range (maxRetry + 1 ):
827771 try :
828- p = subprocess .Popen ('/usr/local/bin/sendPICDevice -v -d %s %s OWTE' % (sub20SN , board ), shell = True ,
829- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
772+ p = subprocess .Popen (['/usr/local/bin/sendPICDevice' , '-v' , '-d' , str (sub20SN ), str (board ), 'OWTE' ],
773+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
774+ text = True )
830775 output , output2 = p .communicate ()
831- try :
832- output = output .decode ('ascii' )
833- output2 = output2 .decode ('ascii' )
834- except AttributeError :
835- pass
836-
776+
837777 if p .returncode == 0 :
838778 for line in filter (lambda x : x .find (' C' ) != - 1 , output .split ('\n ' )):
839779 mtch = owteRE .search (line )
0 commit comments