Use HOLD in log()
So as not to write to the output when using on an HTTP server, during the writing of headers
This commit is contained in:
		
							
								
								
									
										10
									
								
								morss.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								morss.py
									
									
									
									
									
								
							@@ -34,6 +34,7 @@ DELAY = 10*60	# xml cache & ETag cache (in sec)
 | 
				
			|||||||
TIMEOUT = 2	# http timeout (in sec)
 | 
					TIMEOUT = 2	# http timeout (in sec)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEBUG = False
 | 
					DEBUG = False
 | 
				
			||||||
 | 
					HOLD = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UA_RSS = 'Liferea/1.8.12 (Linux; fr_FR.utf8; http://liferea.sf.net/)'
 | 
					UA_RSS = 'Liferea/1.8.12 (Linux; fr_FR.utf8; http://liferea.sf.net/)'
 | 
				
			||||||
UA_HTML = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11'
 | 
					UA_HTML = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11'
 | 
				
			||||||
@@ -51,7 +52,10 @@ if 'REQUEST_URI' in os.environ:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def log(txt):
 | 
					def log(txt):
 | 
				
			||||||
	if DEBUG:
 | 
						if DEBUG:
 | 
				
			||||||
		print repr(txt)
 | 
							if HOLD:
 | 
				
			||||||
 | 
								open('morss.log', 'a').write("%s\n" % repr(txt))
 | 
				
			||||||
 | 
							else:
 | 
				
			||||||
 | 
								print repr(txt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def lenHTML(txt):
 | 
					def lenHTML(txt):
 | 
				
			||||||
@@ -495,6 +499,8 @@ if __name__ == '__main__':
 | 
				
			|||||||
	DEBUG = bool(options.debug)
 | 
						DEBUG = bool(options.debug)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if 'REQUEST_URI' in os.environ:
 | 
						if 'REQUEST_URI' in os.environ:
 | 
				
			||||||
 | 
							HOLD = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if 'HTTP_IF_NONE_MATCH' in os.environ and not options.force:
 | 
							if 'HTTP_IF_NONE_MATCH' in os.environ and not options.force:
 | 
				
			||||||
			if time.time() - int(os.environ['HTTP_IF_NONE_MATCH'][1:-1]) < DELAY:
 | 
								if time.time() - int(os.environ['HTTP_IF_NONE_MATCH'][1:-1]) < DELAY:
 | 
				
			||||||
				print 'Status: 304'
 | 
									print 'Status: 304'
 | 
				
			||||||
@@ -516,6 +522,8 @@ if __name__ == '__main__':
 | 
				
			|||||||
			print 'Content-Type: text/xml'
 | 
								print 'Content-Type: text/xml'
 | 
				
			||||||
		print ''
 | 
							print ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							HOLD = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cache = os.getcwd() + '/cache'
 | 
							cache = os.getcwd() + '/cache'
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
		cache =	os.path.expanduser('~') + '/.cache/morss'
 | 
							cache =	os.path.expanduser('~') + '/.cache/morss'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user