Я создаю приложение, которое должно управлять роботом, которого я создал, и должно быть в состоянии попросить робота сделать снимок и вернуть его с помощью SCP.
def snap(self): #method of the netCamera class that asks the robot to take a picture
if(subprocess.run(["ssh", self.host, "python3", "~/PilotAppTemp/scripts/snap.py"]).returncode):
print("ERROR: Unable to take picture")
return 1
else:
return 0
def getImage(self): #method of the netCamera class that gets the picture
self.imageCount += 1
print("a")
command = "scp " + self.host + ":" + self.robotPath + "/img.png " + self.localPath + "/img" + self.imageCount + ".png" #problem
print("command : " + command)
if(subprocess.run(command).returncode):
print("ERROR")
return 0
else:
return self.imageCount
def camera(self, event): #method of the App class (controler) used as callback for when the user clicks on the button to take a picture, that uses the aformentionned methods to get an image from the robot and then display it
if(self.robotCam.snap()):
self.history.log("Error: unable to take picture")
else:
imageNum = self.robotCam.getImage()
if(imageNum == 0):
self.history.log("Error: unable to take picture")
else:
self.image("img" + imageNum + ".png")
В моем getImage ()Однако, я получаю исключение со странным сообщением
a
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Anthony.JACCARD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py",rgs)
ge()
problem
te str (not "int") to str
Как видите, оно полно незавершенных строк.Я использовал печально известный метод отладки print () и мог определить, что проблема связана со строкой с комментарием «#problem» (вы можете видеть, что «a» печатается, а «command: ...» - нет).Теперь, когда мой код завершается ошибкой при вызове подпроцесса, я могу понять, но не могу понять, почему простая конкатенация дает мне такое странное исключение.
У кого-нибудь есть идеи относительно того, как это исправить?