def upload_photo(photo, auth):
	while True:
		try:
			f = open(photo, "rb")
			data = f.read()

			u = Uploader(photo, data, auth)
			u.setPublic()
			req = u.getRequest()

			res = execute(req)
			photo_id = u.getPhotoIdFromResponse(res)

			return photo_id
		except urllib2.HTTPError as e:
			pass
示例#2
0
def upload_photo(photo, auth):
    while True:
        try:
            f = open(photo, "rb")
            data = f.read()

            u = Uploader(photo, data, auth)
            u.setPublic()
            req = u.getRequest()

            res = execute(req)
            photo_id = u.getPhotoIdFromResponse(res)

            return photo_id
        except urllib2.HTTPError as e:
            pass
示例#3
0
def run_tests(key, secret):
	try:
		x = Auth(key, secret)
		x.authenticate()
	except urllib2.HTTPError as e:
		print e.read()
		raise

	filename = "/Users/riyer/Desktop/Screen Shot 2013-06-28 at 7.36.02 PM.png"

	f = open(filename, "rb")
	pic = f.read()

	u = Uploader("test_pic", pic, x)
	u.addTitle("test pic")
	u.setPublic()

	req = u.getRequest()
	try:
		handle = urllib2.urlopen(req)
		res = handle.read()
	except urllib2.HTTPError as e:
		print e.read()
		raise

	photo_id = u.getPhotoIdFromResponse(res)

	p = Photosets(x)
	r = p.createGetListRequest()
	res = execute(r, "createGetListRequest")

	names = p.getPhotosetList(res)

	r = p.createNewSetRequest("test set", "test desc", '9404583236')
	res = execute(r, "createNewSetRequest")

	set_id = p.getPhotosetIdFromResult(res)

	r = p.createAddPhotoRequest(photo_id, set_id)
	execute(r, "createAddPhotoRequest")

	r = p.createPhotosetDeleteRequest(set_id)
	execute(r, "createPhotosetDeleteRequest")

	photos = Photos(x)
	r = photos.createDeletePhotoRequest(photo_id)
	execute(r, "createDeletePhotoRequest")
示例#4
0
def run_tests(key, secret):
    try:
        x = Auth(key, secret)
        x.authenticate()
    except urllib2.HTTPError as e:
        print e.read()
        raise

    filename = "/Users/riyer/Desktop/Screen Shot 2013-06-28 at 7.36.02 PM.png"

    f = open(filename, "rb")
    pic = f.read()

    u = Uploader("test_pic", pic, x)
    u.addTitle("test pic")
    u.setPublic()

    req = u.getRequest()
    try:
        handle = urllib2.urlopen(req)
        res = handle.read()
    except urllib2.HTTPError as e:
        print e.read()
        raise

    photo_id = u.getPhotoIdFromResponse(res)

    p = Photosets(x)
    r = p.createGetListRequest()
    res = execute(r, "createGetListRequest")

    names = p.getPhotosetList(res)

    r = p.createNewSetRequest("test set", "test desc", '9404583236')
    res = execute(r, "createNewSetRequest")

    set_id = p.getPhotosetIdFromResult(res)

    r = p.createAddPhotoRequest(photo_id, set_id)
    execute(r, "createAddPhotoRequest")

    r = p.createPhotosetDeleteRequest(set_id)
    execute(r, "createPhotosetDeleteRequest")

    photos = Photos(x)
    r = photos.createDeletePhotoRequest(photo_id)
    execute(r, "createDeletePhotoRequest")