使用IceFaces加载Ajax样式(Ajax style loading with IceFaces)
我有一个页面,我在其中显示从Web服务加载的对象列表。 可能还要等一下。 现在我想用Ajax方式做,首先显示页面,然后加载列表。 当列表加载时,应显示动画。 有人能举例说明如何用JSF / ICEFaces做到这一点吗? 谢谢。
I have a page on which I show a list of objects which are loaded from a webservice. This may take a while. Now I'd like to do it the Ajax way and first show the page and then load the list. While the list is loading a animated should be shown. Can anybody give me an example how to do that with JSF/ICEFaces? Thanks.
原文:https://stackoverflow.com/questions/2227536
最满意答案
非交互式用例
这是一个非交互式的例子...它发送
cd tmp
,ls
然后exit
。import sys sys.stderr = open('/dev/null') # Silence silly warnings from paramiko import paramiko as pm sys.stderr = sys.__stderr__ import os class AllowAllKeys(pm.MissingHostKeyPolicy): def missing_host_key(self, client, hostname, key): return HOST = '127.0.0.1' USER = '' PASSWORD = '' client = pm.SSHClient() client.load_system_host_keys() client.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) client.set_missing_host_key_policy(AllowAllKeys()) client.connect(HOST, username=USER, password=PASSWORD) channel = client.invoke_shell() stdin = channel.makefile('wb') stdout = channel.makefile('rb') stdin.write(''' cd tmp ls exit ''') print stdout.read() stdout.close() stdin.close() client.close()
交互式用例
如果你有一个交互式用例,这个答案不会有帮助...我个人会使用pexpect
或exscript
进行交互式会话。Non-Interactive use cases
This is a non-interactive example... it sends
cd tmp
,ls
and thenexit
.import sys sys.stderr = open('/dev/null') # Silence silly warnings from paramiko import paramiko as pm sys.stderr = sys.__stderr__ import os class AllowAllKeys(pm.MissingHostKeyPolicy): def missing_host_key(self, client, hostname, key): return HOST = '127.0.0.1' USER = '' PASSWORD = '' client = pm.SSHClient() client.load_system_host_keys() client.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) client.set_missing_host_key_policy(AllowAllKeys()) client.connect(HOST, username=USER, password=PASSWORD) channel = client.invoke_shell() stdin = channel.makefile('wb') stdout = channel.makefile('rb') stdin.write(''' cd tmp ls exit ''') print stdout.read() stdout.close() stdin.close() client.close()
Interactive use cases
If you have an interactive use case , this answer won't help... I personally would usepexpect
orexscript
for interactive sessions.
相关问答
更多-
你如何在Paramiko的单个会话中执行多个命令?(How do you execute multiple commands in a single session in Paramiko? (Python))[2022-03-19]
非交互式用例 这是一个非交互式的例子...它发送cd tmp , ls然后exit 。 import sys sys.stderr = open('/dev/null') # Silence silly warnings from paramiko import paramiko as pm sys.stderr = sys.__stderr__ import os class AllowAllKeys(pm.MissingHostKeyPolicy): def missing_hos ... -
使用Paramiko在Python中使用ssh实现交互式shell?(Implement an interactive shell over ssh in Python using Paramiko?)[2022-01-10]
import paramiko import re class ShellHandler: def __init__(self, host, user, psw): self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(host, username=user, password= ... -
在exec_command执行之后,只有paramiko关闭了通道,并且ssh返回一个auth提示符。 似乎它不可能与paramiko ,尝试fabric或其他工具。 ** fabric也没有解决 。 With just paramiko after the exec_command executes the channel is closed and the ssh returns an auth prompt. Seems its not possible with just paramiko, try ...
-
我无法使用您的命令重现问题,但我可以使用cat some_big_file.txt等命令重现它。 所以看起来你的假设是正确的。 在您阅读channel所有内容之前,可以准备退出状态。 目前尚不清楚你是否真的需要使用select 。 如果不是,我会重写循环: while True: buf = channel.recv(1024) if not buf: break print buf 这样的循环将继续读取通道,同时其中包含一些数据。 如果你真的想使用select你可 ...
-
Paramiko会话超时,但我需要执行很多命令(Paramiko session times out, but i need to execute a lot of commands)[2021-05-08]
我认为你需要的是invoke_shell() 。 例如: ssh = paramiko.SSHClient() ... ... chan = ssh.invoke_shell() # starts an interactive session chan.send('command 1\r') output = chan.recv() chan.send('command 2\r') output = chan.recv() ... ... 该Channel有许多其他方法。 您可以参考该文件以了解更多详 ... -
用cmd = ['cmd.exe /c "cd C:\ && dir"' ]替换cmd = ["cd ..", "dir" ] cmd = ['cmd.exe /c "cd C:\ && dir"' ] Replace cmd = ["cd ..", "dir" ] with cmd = ['cmd.exe /c "cd C:\ && dir"' ]
-
用paramiko执行命令后EOFError的含义是什么?(What is the meaning of the EOFError after I execute a command with paramiko?)[2022-04-08]
SSH服务器可能不支持或不允许exec_command() 。 您可以通过手动运行以下ssh命令来验证这一点(例如,从shell): ssh user@host c i eth i 使用手动ssh user@host ci eth i “我得到以下内容”由远程主机关闭的50.0.0.235连接。 你需要在paramiko中启动一个interative shell: ssh = paramiko.SSHClient() ssh.connect(...) chan = ssh.invoke_shell() ... -
好吧,你们,我没有确定为什么我会收到这些错误。 但我确实找到了解决方法。 在创建SSHClient之后,使用connect,你可以调用Invoke_Shell,它会打开一个通道,在你通过它发送内容后它不会关闭,这很棒。 下面是我更新的connectSwitch代码,它利用了这项工作。 def connectSwitch(UUser, UPass, Host):#SSH connection to Switch ssh = paramiko.SSHClient() ssh.set_missin ...
-
执行一个cmd后,paramiko的ssh通道关闭 - Python(paramiko's ssh channel closed after executing one cmd - Python)[2023-10-31]
关于这一点, channel文档非常明确。 您需要为每个exec_command打开一个新通道。 exec_command(* args,** kwds) 在服务器上执行命令。 如果服务器允许,则通道将直接连接到正在执行的命令的stdin,stdout和stderr。 命令完成执行后,通道将关闭,无法重复使用。 如果要执行其他命令,则必须打开新通道。 SSHClient对象有一个exec_command方法,可以为您执行此操作。 The channel docs are very clear about t ... -
根据您的最新评论: 我安装了一个Cygwin终端并使用命令SSH服务器......它提出了Extra params错误。 我执行的命令: ssh usrm@10.126.141.132 "show chassis" ,输出: No entry for terminal type "dumb"; using dumb terminal settings. Extra params found in CLI, this is not supported, exiting the CLI session: No ...