Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82502

Re: how to delete my file if exits in the remote server with paramiko?

References <tencent_75118A3B15CC638478581FA8@qq.com>
Date 2014-12-14 07:35 -0600
Subject Re: how to delete my file if exits in the remote server with paramiko?
From Skip Montanaro <skip.montanaro@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16945.1418564136.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Dec 14, 2014 at 6:49 AM, 水静流深 <1248283536@qq.com> wrote:
> Is there more elegant way to do the same work?

Unlikely. You have two fairly simple bits of code in your example, one
to connect to the remote server, the other to check for the file's
existence and remove it. The only extra elegance I see is to isolate
those two bits of work into separate functions, so you execute
something like:

sftp = connect_via_paramiko("vps ip", 22)
remove_remote_file(sftp, "/home/names.txt")

Presumably, if you have other work to do on the server, you'd save the
sftp object for reuse.

Skip

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to delete my file if exits in the remote server with paramiko? Skip Montanaro <skip.montanaro@gmail.com> - 2014-12-14 07:35 -0600

csiph-web