Python应用程序.desktop

编程入门 行业动态 更新时间:2024-10-19 04:29:05
本文介绍了Python应用程序.desktop-shortcut导致故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想为我的Python应用程序创建一个桌面启动器.应用程序使用公钥身份验证在pexpect上执行各种ssh操作.但是问题是,当我使用.desktop启动器启动应用程序时,它无法正常运行. ssh连接要求输入密码,并且不使用公共密钥.但是它可以通过命令行执行正常工作.

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.

.desktop文件如下所示:

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

桌面环境为KDE,桌面用户与命令行用户相同.

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?

示例函数

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

推荐答案

正如MirosławZalewski在评论中所怀疑的那样,问题在于ssh-agent不在桌面环境中运行,因为ssh-add最初是在/etc/sources.因此,在X用户~./profile中执行ssh-add可以解决该问题.

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.

更多推荐

Python应用程序.desktop

本文发布于:2023-11-07 23:03:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   Python   desktop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!