download data using rsync

This is the place for queries that don't fit in any of the other categories.

download data using rsync

Postby kiranv5 » Wed Jul 30, 2014 10:17 am

I am using this script now wiht date as argument but i want to rsync to download data wihtout any date range. is it possible to do can you help me with this.
My previous script was downloading data for previous day i.e yesterday. But i dont want any date on it.

Code: Select all
try:
    site_id = sys.argv[1]
    try:
        dl_date = sys.argv[2]
    except:
        oneday = datetime.timedelta(days=1)
        dl_date = datetime.date.today() - oneday
except:
    print "Usage: %s site_id [date]"
    sys.exit(1)

# Process the cameras for that site
for cam_id in cam_id_list:
    cam_name = db_obj.cam_name_by_id(cam_id)
    print "Downloading %s for %s" % (cam_name, dl_date)
    try:
        #myftp = anprint.ftpClient(cam_name)
    rsync = anprint.ftpClient(cam_name)
        #dl_count = myftp.downloaddir(dl_date)
        dl_count = rsync.downloaddir(dl_date)
    db_obj.log_stats(cam_id, dl_count, dl_date)

        fp = open(stats_filename, "a")
        stats_string = "Downloaded %d entries from %s\n" % (dl_count, cam_name)
        fp.write(stats_string)
        fp.close()
    except:
Last edited by Mekire on Wed Jul 30, 2014 12:30 pm, edited 1 time in total.
Reason: First post lock.
kiranv5
 
Posts: 2
Joined: Wed Jul 30, 2014 10:10 am

Re: download data using rsync

Postby Kebap » Thu Jul 31, 2014 9:46 am

kiranv5 wrote:I am using this script now wiht date as argument but i want to rsync to download data wihtout any date range.


Hi kiran, welcome to Python!

Please read the thread for new users. I can't run your script, as it is not complete. So I can only guess.

I would suggest you just remove from the script anything that deals with the date argument. Then test if it works.

However, some of your functions receive the date as an argument. I don't know how they will react without it:

Code: Select all
dl_count = rsync.downloaddir(dl_date)
db_obj.log_stats(cam_id, dl_count, dl_date)
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 390
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: download data using rsync

Postby kiranv5 » Thu Jul 31, 2014 3:59 pm

My code is looking for yesterday date to download from this code below is there any way to say the code to look at root directory.how to pass root directory on this statement.


Code: Select all
dl_count = rsync.downloaddir('/')


Code: Select all
oneday = datetime.timedelta(days = 1)
        dl_date = datetime.date.today() - oneday
kiranv5
 
Posts: 2
Joined: Wed Jul 30, 2014 10:10 am


Return to General Coding Help

Who is online

Users browsing this forum: cnitin, W3C [Linkcheck] and 4 guests