Re: [Tutor] socket / over network
in case it helps here is a very basic example: import MySQLdb, glob, os, re, shutil from ftplib import FTP a=file_to_fetch ftp=FTP('ftp_server') ftp.login('user_name','password') try: aa=ftp.nlst(a) b='/home/a' bb=os.path.basename(aa[0]) e=os.path.basename(b) c=open(b, 'wb') ftp.retrbinary('RETR '+aa[0], c.write) c.close() well u just copied some pieces of my own code to maybe help you get started with ftp as you maybe don't know that you have to open a file for writing & then write into it the stream from ftp retrieve cmd. On Mon, Apr 7, 2008 at 7:16 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "Nathan McBride" <[EMAIL PROTECTED]> wrote > > > Going off of wha tyou said, if I choose to use ftp, is there a way i > > could do everything from within python including the server to get > > the > > files? Is there like a ftp module for python to help in the passing > > of > > the files between the computers? > > Yes, there is an ftp module in the standard library. > > Alan G > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
"Nathan McBride" <[EMAIL PROTECTED]> wrote > Going off of wha tyou said, if I choose to use ftp, is there a way i > could do everything from within python including the server to get > the > files? Is there like a ftp module for python to help in the passing > of > the files between the computers? Yes, there is an ftp module in the standard library. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
Hi Nathan, Nathan McBride wrote: > Alan Gauld wrote: >> "Nathan McBride" <[EMAIL PROTECTED]> wrote >>> I'm pretty tired of the lame backup solution we have at work. >>> Could anyone point me to a (more or less newbieish) example of how >>> to >>> have python open a socket on one box and get data from it, then have >>> another >>> box write to it over the network? >> For a very simple example of using a socket you could try the >> Network Programming topic in my tutorial. > >> There is also a HowTo or Topic guide on the Python web site >> that gives a more detailed example. > >> That having been said, backups are usually best done using >> OS tools or if you must roll your own then using ftp or similar >> as a file transfer mechanism rather than trying to send a >> bytestream over a socket. ftp can handle broken connections >> etc more easily. Detecting and fixing errors over a socket >> stream is non trivial and for backups is pretty much essential!! > > Going off of wha tyou said, if I choose to use ftp, is there a way i > could do everything from within python including the server to get the > files? Is there like a ftp module for python to help in the passing of > the files between the computers? There are number of problems with FTP around security and firewalls, etc. This might be overkill, but perhaps you could use Twisted with SSH/SCP to get files around? See; [Twisted-Python] Twisted SCP http://twistedmatrix.com/pipermail/twisted-python/2005-December/012180.html Perhaps using Rsync and SSH might be more appropriate; http://www.howtoforge.com/rsync_incremental_snapshot_backups regards, Kim -- Operating Systems, Services and Operations Information Technology Services, The University of Adelaide [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alan Gauld wrote: > "Nathan McBride" <[EMAIL PROTECTED]> wrote > > Hi Nathan, > > Please don't reply to an existing message to start a new discussion. > It messes up those of us using threaded mail/news readers and > increases the likelihood that your message will be missed. > >> I'm pretty tired of the lame backup solution we have at work. >> Could anyone point me to a (more or less newbieish) example of how >> to >> have python open a socket on one box and get data from it, then have >> another >> box write to it over the network? > > For a very simple example of using a socket you could try the > Network Programming topic in my tutorial. > > There is also a HowTo or Topic guide on the Python web site > that gives a more detailed example. > > That having been said, backups are usually best done using > OS tools or if you must roll your own then using ftp or similar > as a file transfer mechanism rather than trying to send a > bytestream over a socket. ftp can handle broken connections > etc more easily. Detecting and fixing errors over a socket > stream is non trivial and for backups is pretty much essential!! > Going off of wha tyou said, if I choose to use ftp, is there a way i could do everything from within python including the server to get the files? Is there like a ftp module for python to help in the passing of the files between the computers? Thanks, Nate -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFH+YH1/n+duykW6K8RAhv+AJoCDvQip6Q1wJSh3dEoRZoC4Gx3oACdF0DK oQXQTccEnkEz0mf/Qo4Ywqo= =QRMr -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
re-inventing the wheel ? http://www.howtoforge.com/linux_backuppc > > > On Thu, Apr 3, 2008 at 3:44 PM, Alan Gauld <[EMAIL PROTECTED]> > wrote: > > > "Nathan McBride" <[EMAIL PROTECTED]> wrote > > > > Hi Nathan, > > > > Please don't reply to an existing message to start a new discussion. > > It messes up those of us using threaded mail/news readers and > > increases the likelihood that your message will be missed. > > > > > I'm pretty tired of the lame backup solution we have at work. > > > Could anyone point me to a (more or less newbieish) example of how > > > to > > > have python open a socket on one box and get data from it, then have > > > another > > > box write to it over the network? > > > > For a very simple example of using a socket you could try the > > Network Programming topic in my tutorial. > > > > There is also a HowTo or Topic guide on the Python web site > > that gives a more detailed example. > > > > That having been said, backups are usually best done using > > OS tools or if you must roll your own then using ftp or similar > > as a file transfer mechanism rather than trying to send a > > bytestream over a socket. ftp can handle broken connections > > etc more easily. Detecting and fixing errors over a socket > > stream is non trivial and for backups is pretty much essential!! > > > > -- > > Alan Gauld > > Author of the Learn to Program web site > > http://www.freenetpages.co.uk/hp/alan.gauld > > > > > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
"Nathan McBride" <[EMAIL PROTECTED]> wrote Hi Nathan, Please don't reply to an existing message to start a new discussion. It messes up those of us using threaded mail/news readers and increases the likelihood that your message will be missed. > I'm pretty tired of the lame backup solution we have at work. > Could anyone point me to a (more or less newbieish) example of how > to > have python open a socket on one box and get data from it, then have > another > box write to it over the network? For a very simple example of using a socket you could try the Network Programming topic in my tutorial. There is also a HowTo or Topic guide on the Python web site that gives a more detailed example. That having been said, backups are usually best done using OS tools or if you must roll your own then using ftp or similar as a file transfer mechanism rather than trying to send a bytestream over a socket. ftp can handle broken connections etc more easily. Detecting and fixing errors over a socket stream is non trivial and for backups is pretty much essential!! -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] socket / over network
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey guys, I'm pretty tired of the lame backup solution we have at work. Could anyone point me to a (more or less newbieish) example of how to have python open a socket on one box and get data from it, then have another box write to it over the network? I'm having trouble finding something like this. Thanks, Nate -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFH9PUf/n+duykW6K8RAvXMAKCE5708Bly/9fzHFZu45cd/d11WGQCdGNcG PWcbs2jjZXv7b586aNAnSv4= =9uBW -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor