Flag erros if output file is zero-length.

Go right to home page on login/logout.
This commit is contained in:
david 2002-08-25 01:09:53 +00:00
parent 9ed4fa9935
commit f642bfb398
4 changed files with 19 additions and 7 deletions

View File

@ -440,9 +440,8 @@ class Doc:
self.sk_seriesid = trim(row[24])
self.replaced_by_id = safeint(row[25])
self.lint_time = time2str(row[26])
self.pub_time = time2str(row[26])
self.mirror_time = time2str(row[27])
self.pub_time = time2str(row[27])
self.mirror_time = time2str(row[28])
def save(self):
"""
FIXME: use cursor.execute(sql,params) instead! --nico

View File

@ -56,6 +56,7 @@ ERR_MIRROR_URL_RETRIEVE = 202 # A error occurred retrieving a remote file.
ERR_MAKE_NO_SOURCE = 301 # A source file does not exist and has no target.
ERR_MAKE_EXIT_STATUS = 302 # A command returned a nonzero exit (failure) code.
ERR_MAKE_STDERR = 303 # Something was written to STDERR
ERR_MAKE_ZERO_LENGTH = 304 # Command produced a zero-length file.
def random_string(length):
"""

View File

@ -184,8 +184,8 @@ class Projects(LampadasCollection):
class Project:
def __init__(self, doc_id):
self.doc_id = doc_id
self.doc = lampadas.docs[doc_id]
self.doc_id = int(doc_id)
self.doc = lampadas.docs[self.doc_id]
self.workdir = config.cache_dir + str(self.doc_id) + '/work/'
self.filename = ''
self.targets = Targets()
@ -373,6 +373,14 @@ class Project:
if exit_status==0:
exit_status = 1;
# Zero filesize indicates failure. Fail and erase file.
filestat = os.stat(self.workdir + command.output_to)
filesize = filestat[stat.ST_SIZE]
if filesize==0:
self.doc.errors.add(ERR_MAKE_ZERO_LENGTH)
print 'ERROR: The command left a zero-length file. Removing.'
os.remove(self.workdir + command.output_to)
if exit_status <> 0:
return(exit_status, timestamp)
@ -406,6 +414,10 @@ class Project:
def write(self):
"""Writes the contents of a regular Makefile to disk."""
# Do not publish any document which has not been mirrored.
if self.doc.mirror_time=='':
return
contents = ''
for key in self.targets.sort_by('sort_order'):
target = self.targets[key]

View File

@ -51,7 +51,7 @@ def login(req, username, password):
log(3, 'setting cookie')
req.headers_out['Set-Cookie']='lampadas=' + session_id + '; path=/; expires=Wed, 09-Nov-2030 23:59:00 GMT'
uri = URI('logged_in' + referer_lang_ext(req))
uri = URI('home' + referer_lang_ext(req))
uri.base = '../../'
return page_factory.page(uri)
else:
@ -68,6 +68,6 @@ def logout(req, username):
log(3, 'clearing cookie')
req.headers_out['Set-Cookie']='lampadas=foo; path=/; expires=Wed, 09-Nov-1980 23:59:00 GMT'
uri = URI('logged_out' + referer_lang_ext(req))
uri = URI('home' + referer_lang_ext(req))
uri.base = '../../'
return page_factory.page(uri)