def execute(self,command):
to_exec = self.transport.open_session()
to_exec.exec_command(command)
print 'Command executed'
connection.execute("install.sh")
Run Code Online (Sandbox Code Playgroud)
当我检查远程系统时,我发现脚本没有运行.任何线索?
每当我单击列表小部件中的任何函数时,它都会运行特定的函数.现在我想将项目本身作为该函数的参数发送.这是代码:
QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.test)
def test(self):
print 'hello'
Run Code Online (Sandbox Code Playgroud)
相反,我想:
def test(self,item):
print item
Run Code Online (Sandbox Code Playgroud) 例如 - $x=xyz.2.3.4.fc15.i686
输出require = 15(即在fc和.i686之间)
我有一个主对话框,在那个对话框上有一个按钮。单击按钮时,我想打开另一个对话框。
主对话框代码(在主对话框中单击按钮时调用的函数):
def add_host(self):
x=add_host.Ui_Dialog1()
x.main()
Run Code Online (Sandbox Code Playgroud)
默认功能:
if __name__ == "__main__":
import sys
global app
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
辅助对话框(add_host.py)代码快照:
def main(self):
app1 = QtGui.QApplication(sys.argv)
Dialog1 = QtGui.QDialog()
ui1 = Ui_Dialog1()
ui1.setupUi1(Dialog1)
Dialog1.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
因此,当我运行代码时,它会打开辅助对话框,但是当我关闭它时,它会冻结,并收到以下错误消息:
File "testbot.py", line 175, in add_host
x.main()
File "/home/ppp/ppp/add_host.py", line 74, in main
sys.exit(app.exec_())
NameError: global name 'app' is not defined
Run Code Online (Sandbox Code Playgroud)
这确实有道理,但我不知道如何解决。我尝试了几种组合都没有成功,包括添加和删除app.exec_().
这是我使用BeautifulSoup的python代码.主要问题是属性.我正在寻找的是,th的每个元素应该是分开的,但由于某种原因它只在一个单独的标签内生成.
from BeautifulSoup import BeautifulSoup, Tag
soup=BeautifulSoup()
mem_attr=['Description','PhysicalID','Slot','Size','Width']
tag1 = Tag(soup, "html")
tag2 = Tag(soup, "table")
tag3 = Tag(soup, "tr")
tag4 = Tag(soup, "th")
tag5 = Tag(soup, "td")
soup.insert(0, tag1)
tag1.insert(0, tag2)
tag2.insert(0, tag3)
for i in range(0,len(mem_attr)):
tag3.insert(0,tag4)
tag4.insert(i,mem_attr[i])
print soup.prettify()
Run Code Online (Sandbox Code Playgroud)
这是它的输出:
<html>
<table>
<tr>
<th>
Description
PhysicalID
Slot
Size
Width
</th>
</tr>
</table>
</html>
Run Code Online (Sandbox Code Playgroud)
我正在寻找的就是这个.
<html>
<table>
<tr>
<th>
Description
</th>
<th>
PhysicalID
</th>
<th>
Slot
</th>
<th>
Size
</th>
<th>
Width
</th>
</tr>
</table>
</html>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我代码中缺少什么?