#!/usr/bin/python

import gnomevfs
import traceback
from os.path import expanduser

def xfer(sourceuri, targeturi):
    result = gnomevfs.xfer_uri(
        source_uri=gnomevfs.URI(sourceuri),
        target_uri=gnomevfs.URI(targeturi),
        xfer_options=gnomevfs.XFER_NEW_UNIQUE_DIRECTORY,
        error_mode=gnomevfs.XFER_ERROR_MODE_ABORT,
        overwrite_mode=gnomevfs.XFER_OVERWRITE_MODE_ABORT)

uri1 = 'http://d134w4tst3t.s3.amazonaws.com:80/a?Signature=aNxGCZQ6s5Wr3WeCIDXvQrivjhA%3D&Expires=1217534131&AWSAccessKeyId=0EYZF4DV8A7WM0H73602'
target1 = expanduser('~/tmptestfile1')
try:
    xfer(uri1, target1)
    print "1: success"
except:
    traceback.print_exc()
    print "1: failure"

uri2 = 'http://www.amazon.com/favicon.ico'
target2 = expanduser('~/tmptestfile2')
try:
    xfer(uri2, target2)
    print "2: success"
except:
    traceback.print_exc()
    print "2: failure"
