Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40255 > unrolled thread
| Started by | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| First post | 2013-03-01 06:18 -0800 |
| Last post | 2013-03-01 08:24 -0800 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.python
os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 06:18 -0800
Re: os.system() not responding on django... any reason? Roy Smith <roy@panix.com> - 2013-03-01 09:24 -0500
Re: os.system() not responding on django... any reason? "marduk@python.net" <marduk@python.net> - 2013-03-01 09:59 -0500
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:23 -0800
Re: os.system() not responding on django... any reason? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-01 19:20 +0000
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:24 -0800
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:23 -0800
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:24 -0800
| From | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| Date | 2013-03-01 06:18 -0800 |
| Subject | os.system() not responding on django... any reason? |
| Message-ID | <4fcc93b7-3be9-416f-a2d4-bdc6cba2133e@googlegroups.com> |
import sys,os
sys.stderr = open('/dev/null')
import paramiko
sys.stderr = sys.__stderr__
os.system("echo \'s3\' >> myfile.txt ") #debug first in ssh2
def ssh2_connect(host, user, pswd, port=22):
try:
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, user, pswd)
return ssh
except Exception, e:
return str(e) + "Error. Failed to connect. Wrong IP/Username/Password"
def ssh2_exec(ssh, cmd, sudo=False):
result = []
try:
channel = ssh.get_transport().open_session()
if sudo:
channel.get_pty()
except:
return result
stdin = channel.makefile('wb')
stdout = channel.makefile('rb')
channel.exec_command(cmd)
exit_status = channel.recv_exit_status()
if exit_status == 0:
for line in stdout:
result.append(line)
channel.close()
return result
def ssh2_close(ssh):
ssh.close()
return
def ssh2_copyToFile(ssh, local_file, remote_file):
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
sftp.put(local_file, remote_file)
return
[toc] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-03-01 09:24 -0500 |
| Message-ID | <roy-9C5388.09241701032013@news.panix.com> |
| In reply to | #40255 |
In article <4fcc93b7-3be9-416f-a2d4-bdc6cba2133e@googlegroups.com>, Jaiky <jaiprakashsingh213@gmail.com> wrote: [a lot of code involving ssh and paramiko] Here's a few general suggestions: 1) Try to reduce this to the smallest possible amount of code which demonstrates the problem. You gave us a page full of complicated stuff. Keep hacking away lines of code that don't change the behavior until you get it down to something small and understandable. 2) Try to eliminate environmental problems. You're running this under django? Does it work as a stand-alone process (i.e. without django)?
[toc] | [prev] | [next] | [standalone]
| From | "marduk@python.net" <marduk@python.net> |
|---|---|
| Date | 2013-03-01 09:59 -0500 |
| Message-ID | <mailman.2733.1362149982.2939.python-list@python.org> |
| In reply to | #40256 |
On Fri, Mar 1, 2013, at 09:24 AM, Roy Smith wrote: > In article <4fcc93b7-3be9-416f-a2d4-bdc6cba2133e@googlegroups.com>, > Jaiky <jaiprakashsingh213@gmail.com> wrote: > > [a lot of code involving ssh and paramiko] > > Here's a few general suggestions: > > 1) Try to reduce this to the smallest possible amount of code which > demonstrates the problem. You gave us a page full of complicated stuff. > Keep hacking away lines of code that don't change the behavior until you > get it down to something small and understandable. > > 2) Try to eliminate environmental problems. You're running this under > django? Does it work as a stand-alone process (i.e. without django)? Also, what is the context (Is it running in a Django view; a model? a signal handler? in settings?)?
[toc] | [prev] | [next] | [standalone]
| From | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| Date | 2013-03-01 08:23 -0800 |
| Message-ID | <98614104-7656-4030-87ec-9529ea1804ba@googlegroups.com> |
| In reply to | #40260 |
it is running in view..........
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-03-01 19:20 +0000 |
| Message-ID | <mailman.2749.1362165483.2939.python-list@python.org> |
| In reply to | #40268 |
On 01/03/2013 16:23, Jaiky wrote: > it is running in view.......... > When replying can you please ensure we have the complete context, otherwise we have to spend time looking, thanks. -- Cheers. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| Date | 2013-03-01 08:24 -0800 |
| Message-ID | <64a6acc9-e129-4b03-8fbc-ecd0035a2df7@googlegroups.com> |
| In reply to | #40260 |
in django inviroment..............
[toc] | [prev] | [next] | [standalone]
| From | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| Date | 2013-03-01 08:23 -0800 |
| Message-ID | <mailman.2739.1362155694.2939.python-list@python.org> |
| In reply to | #40260 |
it is running in view..........
[toc] | [prev] | [next] | [standalone]
| From | Jaiky <jaiprakashsingh213@gmail.com> |
|---|---|
| Date | 2013-03-01 08:24 -0800 |
| Message-ID | <mailman.2740.1362157228.2939.python-list@python.org> |
| In reply to | #40260 |
in django inviroment..............
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web