This script uploads the pics in the specified directory into the specified album in picasa. The script requires gdata libraries installed. Check code.google.com.
I had written and tested the code in linux platform. Hasn't been tested in windows.
Any suggestions to add more functionality, or add a UI or any improvements would be great.

#!/usr/bin/python

###
# This script serves to upload the pictures from the specified directory to the specified album in picasa.
# Usage : python picasaUploader -l <source directory> 
###
import gdata.photos.service
import gdata.media
import gdata.geo
import os
import dircache
import sys
import getopt

###
# Method that performs all initializations and insertions into the album
###
def init(path):
	print 'Uploading pics from path ', (path)
	DIR_UPLOAD=path
	gd_client = gdata.photos.service.PhotosService()
	gd_client.email = 'jason.cosmo' #type your username here
	gd_client.password = os.environ['PASSWRD'] # store your password in an environment variable called PASSWD
	gd_client.source = 'python uploader'
	gd_client.ProgrammaticLogin()
	username=gd_client.email
	index = 0
	albums = gd_client.GetUserFeed(user=username)
	albumidlist = []
	# add each album in the list
	for album in albums.entry:
		index = index + 1
		albumidlist.append(album.gphoto_id)
		print '%d %s' %(index,album.title.text)  

	#This choice would be the index of the album chosen from the list
	choice = int(raw_input('Choose the album you want to insert the pics in:'))
	album_url = '/data/feed/api/user/%s/albumid/%s' %(username, albumidlist[choice-1].text)

	#store the references to the pics in the
	#directory in the list
	try:
		pics_list = dircache.listdir(DIR_UPLOAD)
	except:
		print 'Enter a valid directory'		
		usage()
	count = 0
	#upload the pics one by one
	for pic in pics_list:
		filename = DIR_UPLOAD+'/'+pic
		try:
			photo = gd_client.InsertPhotoSimple(album_url, pic, str(count)+'JPG', filename,content_type='image/jpeg')
			count = count + 1
			print count
		except:
			print 'Count not upload', Photo

###
# Method that shows the script usage
###
def usage():
	print 'Usage : python picasaUploader.py -l <directory path>'
	exit(0)


if __name__=='__main__':
	path = ''
	try:
		opts, args = getopt.getopt(sys.argv[1:], "l:v",["directory"])
		for option in opts:
			if option[0] == '-l':
				path = option[1]				
	except:
		usage()

	init(path)

Is it secure to store the password as an environment variable?

Is it secure to store the password as an environment variable?

It sure isn't. But as the above script was written quickly and I thought it would be better to have it as an environment variable instead of putting it in the code, I couldn't think of a better alternative.
You are safe though, if you terminate the shell as soon as the program ends :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.