Use HOLD in log()
So as not to write to the output when using on an HTTP server, during the writing of headersmaster
parent
97acdd9530
commit
09ba8ca644
8
morss.py
8
morss.py
|
@ -34,6 +34,7 @@ DELAY = 10*60 # xml cache & ETag cache (in sec)
|
|||
TIMEOUT = 2 # http timeout (in sec)
|
||||
|
||||
DEBUG = False
|
||||
HOLD = False
|
||||
|
||||
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'
|
||||
|
@ -51,6 +52,9 @@ if 'REQUEST_URI' in os.environ:
|
|||
|
||||
def log(txt):
|
||||
if DEBUG:
|
||||
if HOLD:
|
||||
open('morss.log', 'a').write("%s\n" % repr(txt))
|
||||
else:
|
||||
print repr(txt)
|
||||
|
||||
|
||||
|
@ -495,6 +499,8 @@ if __name__ == '__main__':
|
|||
DEBUG = bool(options.debug)
|
||||
|
||||
if 'REQUEST_URI' in os.environ:
|
||||
HOLD = True
|
||||
|
||||
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:
|
||||
print 'Status: 304'
|
||||
|
@ -516,6 +522,8 @@ if __name__ == '__main__':
|
|||
print 'Content-Type: text/xml'
|
||||
print ''
|
||||
|
||||
HOLD = False
|
||||
|
||||
cache = os.getcwd() + '/cache'
|
||||
else:
|
||||
cache = os.path.expanduser('~') + '/.cache/morss'
|
||||
|
|
Loading…
Reference in New Issue