Python-Application .desktop-shortcut causing malfunction

谁说我不能喝 提交于 2019-12-25 14:50:00

问题


I wanted to create a desktop launcher for my Python application. The application executes various ssh operations over pexpect with publickey-authentication. The problem is however, when I start my app with the .desktop launcher it doesn't work properly. The ssh connections ask for a password and don't use the publickeys. But it works fine via commandline execution.

The .desktop File looks like this:

[Desktop Entry]
Version=1.0
Name=SSH-Manager
Comment=XYZ
Exec=python /home/userx/SSH-Manager/startup.py
Icon=/home/userx/SSH-Manager/resources/icon.png
Path=/home/userx/repos/SSH-Manager
Terminal=true
Type=Application
Categories=Utility;Application;
StartupNotify=false

The desktop environment is KDE and the desktop user is the same as the commandline user.

Can someone explain why I get such strange behavior with the launcher?

Edit: Example function

def run(self):
    self.a_signal.emit("Retrieving Data")
    try:
        session = pxssh()
        session.force_password = False
        hostname = self.client
        username = "root"
        session.login(hostname, username)
        session.sendline("ls -a")
        session.prompt()
        session.logout()
    except ExceptionPxssh as e:
        print ("pxssh failed: ")
        self.error_signal.emit("failed", str(e))
        print e
        return
    self.process_output()
    self.finish_signal.emit("done")

回答1:


As Mirosław Zalewski suspected in the comments, the problem was the ssh-agent was not running for the desktop-environment because ssh-add was initially used in the /etc/sources. Executing ssh-add in the X-users ~./profile therefore solves the problem.



来源:https://stackoverflow.com/questions/43679016/python-application-desktop-shortcut-causing-malfunction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!