@@ -73,7 +73,9 @@ class ServerError(Error):
7373
7474
7575class InteractiveCommandError (Error ):
76- pass
76+ def __init__ (self : Error , msg : str , exitcode : int ):
77+ super (InteractiveCommandError , self ).__init__ (msg )
78+ self .exitcode = exitcode
7779
7880
7981class ErrorGroup (ExceptionGroup ):
@@ -1099,9 +1101,7 @@ async def console(self, place, target):
10991101 break
11001102 if not self .args .loop :
11011103 if res :
1102- exc = InteractiveCommandError ("microcom error" )
1103- exc .exitcode = res
1104- raise exc
1104+ raise InteractiveCommandError ("microcom error" , res )
11051105 break
11061106 await asyncio .sleep (1.0 )
11071107
@@ -1301,27 +1301,21 @@ def ssh(self):
13011301
13021302 res = drv .interact (self .args .leftover )
13031303 if res :
1304- exc = InteractiveCommandError ("ssh error" )
1305- exc .exitcode = res
1306- raise exc
1304+ raise InteractiveCommandError ("ssh error" , res )
13071305
13081306 def scp (self ):
13091307 drv = self ._get_ssh ()
13101308
13111309 res = drv .scp (src = self .args .src , dst = self .args .dst )
13121310 if res :
1313- exc = InteractiveCommandError ("scp error" )
1314- exc .exitcode = res
1315- raise exc
1311+ raise InteractiveCommandError ("scp error" , res )
13161312
13171313 def rsync (self ):
13181314 drv = self ._get_ssh ()
13191315
13201316 res = drv .rsync (src = self .args .src , dst = self .args .dst , extra = self .args .leftover )
13211317 if res :
1322- exc = InteractiveCommandError ("rsync error" )
1323- exc .exitcode = res
1324- raise exc
1318+ raise InteractiveCommandError ("rsync error" , res )
13251319
13261320 def sshfs (self ):
13271321 drv = self ._get_ssh ()
@@ -1359,9 +1353,7 @@ def telnet(self):
13591353 args = ["telnet" , str (ip )]
13601354 res = subprocess .call (args )
13611355 if res :
1362- exc = InteractiveCommandError ("telnet error" )
1363- exc .exitcode = res
1364- raise exc
1356+ raise InteractiveCommandError ("telnet error" , res )
13651357
13661358 def video (self ):
13671359 place = self .get_acquired_place ()
@@ -1397,9 +1389,7 @@ def video(self):
13971389 else :
13981390 res = drv .stream (quality , controls = controls )
13991391 if res :
1400- exc = InteractiveCommandError ("gst-launch-1.0 error" )
1401- exc .exitcode = res
1402- raise exc
1392+ raise InteractiveCommandError ("gst-launch-1.0 error" , res )
14031393
14041394 def audio (self ):
14051395 place = self .get_acquired_place ()
@@ -1408,9 +1398,7 @@ def audio(self):
14081398 drv = self ._get_driver_or_new (target , "USBAudioInputDriver" , name = name )
14091399 res = drv .play ()
14101400 if res :
1411- exc = InteractiveCommandError ("gst-launch-1.0 error" )
1412- exc .exitcode = res
1413- raise exc
1401+ raise InteractiveCommandError ("gst-launch-1.0 error" , res )
14141402
14151403 def _get_tmc (self ):
14161404 place = self .get_acquired_place ()
0 commit comments