From 01fc72fc089846dc1fe79a8aee66668a5d5f4b32 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 19 Aug 2004 15:44:22 +0000 Subject: move Exceptions inline 2004/08/19 10:23:18-05:00 anl.gov!desai add Cron support (Logical change 1.44) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@267 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Core.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index b481033c4..09dd1d086 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -5,11 +5,16 @@ from os import stat from stat import ST_MODE, S_ISDIR from syslog import syslog, LOG_ERR -from Error import PublishError from Types import Clause import _fam +class GeneratorError(Exception): + pass + +class PublishError(Exception): + pass + class fam(object): '''The fam object contains alteration monitors''' @@ -56,6 +61,7 @@ class Core(object): self.fam = fam() self.pubspace = {} self.structures = [] + self.cron = {} for structure in structures: m = getattr(__import__("Bcfg2.Server.Structures.%s"%(structure)).Server.Structures, structure) s = getattr(m, structure) @@ -111,3 +117,11 @@ class Core(object): print g, "failed" raise KeyError, (entry.tag,entry.attrib['name']) + def RunCronTasks(self): + g = [x for x in self.generators if x.__croninterval__] + for generator in g: + t = time() + if ((t - self.cron.get(generator,0)) > generator.__croninterval__): + generator.Cron() + self.cron[generator] = t + -- cgit v1.2.3-1-g7c22