Exemplo n.º 1
0
def main():
	try:
	
		server=HTTPServer(('',string.atoi(config.get('general', 'port'))), ReqHandler)
		
		if not scanhandler.supports_brightness_and_contrast() :
			xmlhandler.hideBox('levels')
		xmlhandler.setFiles(filehandler.getFilenames())
		print 'Webserver started. Serving until keyboard interrupt received (ctrl+c)'
		server.serve_forever()
		
	except KeyboardInterrupt:
		print 'Shutting down server'
		server.socket.close()
Exemplo n.º 2
0
	def handleActions(self,values):
		#SNAP
		if values['action'] == 'snap':
			scanhandler.reset_settings()
			scanhandler.set_mode(values['imgtype'])
			
			scanhandler.set_brightness_and_contrast(
				string.atoi(values['brightness']),
				string.atoi(values['contrast']) )
			
			
			scanhandler.set_preview_rotation(string.atoi(values['rotation']))
			scanhandler.update_preview(filehandler.createPreviewFile())
			filehandler.doneUpdatingPreviewFile()
			self.redirect('demo.html')
		#SCAN
		elif values['action'] == 'scan':
			scanhandler.reset_settings()
			
			scanhandler.set_mode(values['imgtype'])
			
			scanhandler.set_brightness_and_contrast(
				string.atoi(values['brightness']),
				string.atoi(values['contrast']) )
			
			if values['resolution'] == 'OTHER':
				scanhandler.set_resolution(string.atof(values['custom_resolution']))
			else:
				scanhandler.set_resolution(string.atof(values['resolution']))
			
			scanhandler.set_scan_bounds_from_preview(values['left'],values['top'],values['width'],values['height'],values['rotation'])
			
			if values.has_key('before_save'):
				if values['before_save']=='view':
					scanhandler.scan_and_save(filehandler.createFile(values['filename']), values['filetype'])
					xmlhandler.setFiles(filehandler.getFilenames())
					self.redirect('viewfile/'+values['filename'])	
					return			

			scanhandler.scan_and_save(filehandler.createFile(values['filename']), values['filetype'])	
			xmlhandler.setFiles(filehandler.getFilenames())
			self.redirect('demo.html')
		#DELETE_ALL
		elif values['action']=='delete_all':
			filehandler.deleteAllFiles()
			xmlhandler.setFiles(filehandler.getFilenames())
			self.redirect('demo.html')
		#DELETE
		elif values['action']=='delete':
			filehandler.deleteFile(values['selected_file'])
			xmlhandler.setFiles(filehandler.getFilenames())
			self.redirect('demo.html')
		#VIEW
		elif values['action']=='view':
			self.redirect('viewfile/'+values['selected_file'])
		#DOWNLOAD
		elif values['action']=='download':
			self.redirect('storedfiles/'+values['selected_file'])
		#Error, print some debugging info
		else:
			print "No/unknown action value returned:",str(values)
			raise IOError
		
		xmlhandler.updateValues(values)