import os


bg_image = '/usr/local/lgvp/' + 'photos/bg/Background06.jpg'
background_dir = '/usr/local/lgvp/' + 'photos/background/'


def remove_dir(dir_name):
	print 'remove dirs', dir_name
	try:
		if os.path.exists(dir_name):
			for f in os.listdir(dir_name):
				name = dir_name + f
				stat = os.stat(name)
				if stat[0] & 0100000:
					print 'remove this file:', name
					try:
						os.remove(name)
					except:
						pass
	except OSError:
		pass


os.system('ls -la ' + bg_image)


if not os.access(bg_image, os.R_OK):
	print 'Here1'
else:
	print 'Here2'


remove_dir(background_dir)



