Common code for url/options handling
This commit is contained in:
		
							
								
								
									
										19
									
								
								morss.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								morss.py
									
									
									
									
									
								
							@@ -457,27 +457,26 @@ def Gather(url, cachePath, mode='feed'):
 | 
				
			|||||||
	return root.tostring(xml_declaration=True, encoding='UTF-8')
 | 
						return root.tostring(xml_declaration=True, encoding='UTF-8')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
	if 'REQUEST_URI' in os.environ:
 | 
						url, options = parseOptions(OPTIONS)
 | 
				
			||||||
		url, options = parseOptions(OPTIONS)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if 'REQUEST_URI' in os.environ:
 | 
				
			||||||
		print 'Status: 200'
 | 
							print 'Status: 200'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if options == 'progress':
 | 
							if options == 'progress':
 | 
				
			||||||
			print 'Content-Type: application/octet-stream\n'
 | 
								print 'Content-Type: application/octet-stream'
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			print 'Content-Type: text/html\n'
 | 
								print 'Content-Type: text/html'
 | 
				
			||||||
 | 
							print
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cache = os.getcwd() + '/cache'
 | 
							cache = os.getcwd() + '/cache'
 | 
				
			||||||
		log(url)
 | 
							log(url)
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
		url, options = parseOptions(OPTIONS)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if url is None:
 | 
					 | 
				
			||||||
			print "Please provide url."
 | 
					 | 
				
			||||||
			sys.exit(1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		cache =	os.path.expanduser('~') + '/.cache/morss'
 | 
							cache =	os.path.expanduser('~') + '/.cache/morss'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if url is None:
 | 
				
			||||||
 | 
							print "Please provide url."
 | 
				
			||||||
 | 
							sys.exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if options == 'progress':
 | 
						if options == 'progress':
 | 
				
			||||||
		MAX_TIME = -1
 | 
							MAX_TIME = -1
 | 
				
			||||||
	if options == 'cache':
 | 
						if options == 'cache':
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user