Tkinter抛出奇怪的不完整异常

时间:2019-05-23 06:58:16

标签: python exception tkinter

我正在创建一个应用程序,该应用程序应该操纵我制造的机器人,并且应该能够要求机器人拍照并使用SCP将其取回。

class Networking {
    ....
}

class Networking.Email {
    ....
}

// MainActivity.kt

val email = Networking.Email()

在我的getImage()方法中,但是我收到一条带有奇怪消息的异常

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")

如您所见,它充满了不完整的行。我已经使用了臭名昭著的print()调试方法,并且可以确定问题出在带有“ #problem”注释的行中(您可以看到打印了“ a”,但没有看到“ command:...”)。现在我的代码在子流程调用中失败了,我可以理解,但是我不明白为什么简单的串联会给我这么奇怪的异常。

有人知道如何解决此问题吗?

0 个答案:

没有答案