def audit(path, cinematic_id):
	mel.eval("source \"O:/ArtistTools/zoo/zooShotsUtils.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooShelveIt.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooFlags.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooUtils.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooArrays_int.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooArrays_str.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooShots.mel\"")
	
	mcommand_callback = om.MCommandMessage.addCommandOutputCallback(callback, None)
	
	messages = StringIO.StringIO()
	sys.stdout = messages
	
	
	post = {'scene[error_messages]':[],'_method':'PUT'}
	#sys.stdout = messages
	
	#post['messages'].append(util.debug("File to open: %s" % path))
	try:
		if scn.open(path):
			print "File opened, begin audit"
			if len(scn.audit()) < 1:
				util.debug(scn.audit())
				shots = scn.getShots()
				util.debug(shots)
				scene_start, scene_end = scn.length()
				namespaces = []
				for ref in cmds.file(q=1, r=1):
					namespaces.append(cmds.referenceQuery(ref, rfn=True).replace('RN', ''))
	
				post.update({
					'namespaces':namespaces,
					'scene[start_time]':scene_start,
					'scene[end_time]':scene_end,
					'scene[shots]':shots
				})
	
				#post['messages'].append(util.debug("Scene passed."))
				print "Scene passed."
			else:
				print "Scene failed."
				post['scene[error_messages]'].append(scn.audit())
		else:
			print "File open failed"
			post['scene[error_messages]'].append(util.error(10012))
	except:
		util.debug("Runtime Error")
		post['scene[error_messages]'].append("Runtime Error")

	sys.stdout = sys.__stdout__
	
	post.update({'scene[debug_messages]': messages.getvalue()})
	om.MCommandMessage.removeCallback(mcommand_callback)
	messages.close()

	connect_string = "http://%(server)s:%(port)s/cinematics/%(id)s/scene" % {
		'id':cinematic_id,
		'server':ROBO_SERVER,
		'port':ROBO_PORT
	}
	util.debug("Connect string: %s" % connect_string)
	util.debug(post)
	util.debug(urllib.urlencode(post))
	urllib.urlopen(connect_string,urllib.urlencode(post))
def batch_list(scene_location, cinematic_id, export_to, script_name, parts):
	mel.eval("source \"O:/ArtistTools/zoo/zooShotsUtils.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooShelveIt.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooFlags.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooUtils.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooArrays_int.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooArrays_str.mel\"")
	mel.eval("source \"O:/ArtistTools/zoo/zooShots.mel\"")
	
#	try:
	mcommand_callback = om.MCommandMessage.addCommandOutputCallback(callback, None)

	for part in parts:
		util.debug('Exporting %(script_name)s:%(part)s' % {
			'script_name':script_name,
			'part':part
		})
		try:
			fail = False
			messages = StringIO.StringIO()
			sys.stdout = messages
			
			post = {'_method':'PUT'}
	
			if util.hasActorX():
				if(scn.open(scene_location)):
					if part == 'camera':
						util.debug("Exporting camera")
						if cam.export(export_to, script_name):
							util.debug("Camera exported successfully.")
						else:
							util.debug('Export failed for: camera')
							fail = True
					else:
						util.debug("Exporting actor \"%s\"" % part)
						if act.export(export_to, script_name, part):
							util.debug("Actor \"%s\" exported successfully." % part)
						else:
							util.debug('Export failed for: %s' % part)
							fail = True
				else:
					util.debug("Couldn't open scene %s" % scene_location)	
					fail = True
			else:
				util.debug("Need ActorX plugin to perform exports.")
				fail = True

			if fail:
				endpoint = 'fail'
			else:
				endpoint = 'pass'
			connect_string = "http://%(server)s:%(port)s/cinematics/%(id)s/parts/%(part)s/%(endpoint)s" % {
				'endpoint':endpoint,
				'part':part,
				'id':cinematic_id,
				'server':ROBO_SERVER,
				'port':ROBO_PORT
			}
			sys.stdout = sys.__stdout__
			post.update({'messages': messages.getvalue()})
			util.debug(post)
	#		util.debug(urllib.urlencode(post))
			util.debug("Connect string: %s" % connect_string)
			urllib.urlopen(connect_string,urllib.urlencode(post))
		except Exception, e:
			util.debug('Exception: %s' % e)
			endpoint = 'fail'
			connect_string = "http://%(server)s:%(port)s/cinematics/%(id)s/parts/%(part)s/%(endpoint)s" % {
				'endpoint':endpoint,
				'part':part,
				'id':cinematic_id,
				'server':ROBO_SERVER,
				'port':ROBO_PORT
			}
			sys.stdout = sys.__stdout__
			post.update({'messages': messages.getvalue()})
			util.debug(post)
	#		util.debug(urllib.urlencode(post))
			util.debug("Connect string: %s" % connect_string)
			urllib.urlopen(connect_string,urllib.urlencode(post))