chartserver.py
def do_POST(self):
		"""Handles a POST request, which is assumed to be from the GUI."""
		form = cgi.FieldStorage(fp=self.rfile,headers=self.headers,
								environ={'REQUEST_METHOD':'POST','CONTENT_TYPE':self.headers['Content-Type']})

		outfiles = dict()
		for key in ['outfile_settings','outfile_data','outfile_scripts']:
			outfiles[key[8:]] = "genxml/" + form.getfirst(key)

		# Settings
		sroot = ETree.Element('settings')
		for key in form:
			if (key.startswith('/')):
				for path in key.split(','):
					addXml(sroot,path,form.getfirst(key))
		stree = ETree.ElementTree(element=sroot)
		with open(outfiles['settings'],'w') as sfile:
			stree.write(sfile,encoding='utf-8',xml_declaration=True)

		# Data
		with open(outfiles['data'],'w') as dfile:
			fileitemlist = form['data_files']
			if (not isinstance(fileitemlist,list)):
				fileitemlist = [fileitemlist]
			filelist = []
			for fileitem in fileitemlist:
				filelist.append(fileitem.file)
			if (form.getfirst('data_file_type') == 'csv'):
				csvToXmlData(filelist,dfile)
			elif (form.getfirst('data_file_type') == 'xml'):
				combineXmlData(filelist,dfile)

		# Scripts
		with open(outfiles['scripts'],'w') as cfile:
			scriptnames = []
			for key in form:
				if (key.startswith('script_')):
					scriptnames.append(key[7:])
			builtinScripts(scriptnames,cfile)

		try:
			self.send_response(200)
			self.send_header('Content-type','image/svg+xml')
			self.end_headers()
			getChart(None, outfiles['settings'], outfiles['data'], outfiles['scripts'], self.wfile, form.getfirst('type'), False, ',,,')
		except:
			self.wfile.write("""<?xml version='1.0' encoding='utf-8'?>
			<svg verson='1.1' xmlns='http://www.w3.org/2000/svg'>
				<text x='10' y='25'>An error occured during chart generation. Please use your browser's Back
				button to return to the previous page and make sure that all input is valid.</text>
			</svg>
			""")
Handles a POST request, which is assumed to be from the GUI.
Handles a POST request, which is assumed to be from the GUI.
Handles a POST request which is assumed to be from the GUI .
def do_POST(self):
		form = cgi.FieldStorage(fp=self.rfile,headers=self.headers,
								environ={'REQUEST_METHOD':'POST','CONTENT_TYPE':self.headers['Content-Type']})
		outfiles = dict()
		for key in ['outfile_settings','outfile_data','outfile_scripts']:
			outfiles[key[8:]] = "genxml/" + form.getfirst(key)
		sroot = ETree.Element('settings')
		for key in form:
			if (key.startswith('/')):
				for path in key.split(','):
					addXml(sroot,path,form.getfirst(key))
		stree = ETree.ElementTree(element=sroot)
		with open(outfiles['settings'],'w') as sfile:
			stree.write(sfile,encoding='utf-8',xml_declaration=True)
		with open(outfiles['data'],'w') as dfile:
			fileitemlist = form['data_files']
			if (not isinstance(fileitemlist,list)):
				fileitemlist = [fileitemlist]
			filelist = []
			for fileitem in fileitemlist:
				filelist.append(fileitem.file)
			if (form.getfirst('data_file_type') == 'csv'):
				csvToXmlData(filelist,dfile)
			elif (form.getfirst('data_file_type') == 'xml'):
				combineXmlData(filelist,dfile)
		with open(outfiles['scripts'],'w') as cfile:
			scriptnames = []
			for key in form:
				if (key.startswith('script_')):
					scriptnames.append(key[7:])
			builtinScripts(scriptnames,cfile)
		try:
			self.send_response(200)
			self.send_header('Content-type','image/svg+xml')
			self.end_headers()
			getChart(None, outfiles['settings'], outfiles['data'], outfiles['scripts'], self.wfile, form.getfirst('type'), False, ',,,')
		except:
			self.wfile.write("""<?xml version='1.0' encoding='utf-8'?>
			<svg verson='1.1' xmlns='http://www.w3.org/2000/svg'>
				<text x='10' y='25'>An error occured during chart generation. Please use your browser's Back
				button to return to the previous page and make sure that all input is valid.</text>
			</svg>
			""")
def do_POST ( self ) : form = cgi . FieldStorage ( fp = self . rfile , headers = self . headers , environ = { 'REQUEST_METHOD' : 'POST' , 'CONTENT_TYPE' : self . headers [ 'Content-Type' ] } ) outfiles = dict ( ) for key in [ 'outfile_settings' , 'outfile_data' , 'outfile_scripts' ] : outfiles [ key [ 8 : ] ] = "genxml/" + form . getfirst ( key ) sroot = ETree . Element ( 'settings' ) for key in form : if ( key . startswith ( '/' ) ) : for path in key . split ( ',' ) : addXml ( sroot , path , form . getfirst ( key ) ) stree = ETree . ElementTree ( element = sroot ) with open ( outfiles [ 'settings' ] , 'w' ) as sfile : stree . write ( sfile , encoding = 'utf-8' , xml_declaration = True ) with open ( outfiles [ 'data' ] , 'w' ) as dfile : fileitemlist = form [ 'data_files' ] if ( not isinstance ( fileitemlist , list ) ) : fileitemlist = [ fileitemlist ] filelist = [ ] for fileitem in fileitemlist : filelist . append ( fileitem . file ) if ( form . getfirst ( 'data_file_type' ) == 'csv' ) : csvToXmlData ( filelist , dfile ) elif ( form . getfirst ( 'data_file_type' ) == 'xml' ) : combineXmlData ( filelist , dfile ) with open ( outfiles [ 'scripts' ] , 'w' ) as cfile : scriptnames = [ ] for key in form : if ( key . startswith ( 'script_' ) ) : scriptnames . append ( key [ 7 : ] ) builtinScripts ( scriptnames , cfile ) try : self . send_response ( 200 ) self . send_header ( 'Content-type' , 'image/svg+xml' ) self . end_headers ( ) getChart ( None , outfiles [ 'settings' ] , outfiles [ 'data' ] , outfiles [ 'scripts' ] , self . wfile , form . getfirst ( 'type' ) , False , ',,,' ) except : self . wfile . write ( """<?xml version='1.0' encoding='utf-8'?>
			<svg verson='1.1' xmlns='http://www.w3.org/2000/svg'>
				<text x='10' y='25'>An error occured during chart generation. Please use your browser's Back
				button to return to the previous page and make sure that all input is valid.</text>
			</svg>
			""" )
Handles a POST request, which is assumed to be from the GUI.
Handles a POST request which is assumed to be from the GUI .
"""Handles a POST request, which is assumed to be from the GUI.""" # Settings # Data # Scripts
self