python桌面应用崩溃,Python应用程序.desktop-shortcut导致故障

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

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值