From f642bfb3982698171b60d56d239212a247c780f6 Mon Sep 17 00:00:00 2001 From: david <> Date: Sun, 25 Aug 2002 01:09:53 +0000 Subject: [PATCH] Flag erros if output file is zero-length. Go right to home page on login/logout. --- LDP/lampadas/pylib/DataLayer.py | 5 ++--- LDP/lampadas/pylib/Globals.py | 1 + LDP/lampadas/pylib/Makefile.py | 16 ++++++++++++++-- LDP/lampadas/pylib/data/session.py | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/LDP/lampadas/pylib/DataLayer.py b/LDP/lampadas/pylib/DataLayer.py index b481213f..8cf70075 100755 --- a/LDP/lampadas/pylib/DataLayer.py +++ b/LDP/lampadas/pylib/DataLayer.py @@ -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 diff --git a/LDP/lampadas/pylib/Globals.py b/LDP/lampadas/pylib/Globals.py index a8a49107..62017e8f 100755 --- a/LDP/lampadas/pylib/Globals.py +++ b/LDP/lampadas/pylib/Globals.py @@ -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): """ diff --git a/LDP/lampadas/pylib/Makefile.py b/LDP/lampadas/pylib/Makefile.py index f58b6c99..48987524 100755 --- a/LDP/lampadas/pylib/Makefile.py +++ b/LDP/lampadas/pylib/Makefile.py @@ -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] diff --git a/LDP/lampadas/pylib/data/session.py b/LDP/lampadas/pylib/data/session.py index 9f68fda4..3043a292 100644 --- a/LDP/lampadas/pylib/data/session.py +++ b/LDP/lampadas/pylib/data/session.py @@ -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)