示例#1
0
 def runChildTasks(self):
     workfile = self.task.getParent('workfile')
     parentTag = self.task.getParentWithAttribute('hasChildElements')
     if hasattr(parentTag.adapter,'hasChildElements') and \
             not parentTag.adapter.hasChildElements:
         workfile.adapter.file.write(">")
         parentTag.adapter.hasChildElements = True
     indent = ""
     attributes = ""
     if self.task.properties:
         elementAttributes = []
         for key in self.task.properties.keys():
             if key in self.attributeList:
                 elementAttributes.append("%s=\"%s\"" % \
                     (key, self.task.getProperty(key)))
         if elementAttributes:
             attributes = " " + " ".join(elementAttributes)
     if self.block or htmlElement.blockMode or self.startWithNewLine:
             indent = "\n" + " " * htmlElement.level
     if self.block:
         htmlElement.level = htmlElement.level + 1
         self.blockMode = True
     workfile.adapter.file.write("%s<%s%s" % (indent, self.tag, attributes))
     htmlElement.blockMode = self.block
     TaskAdapter.runChildTasks(self)
示例#2
0
 def runChildTasks(self):
     """ open working file for child tasks
     """
     self.path = self.task.getProperty("path")
     update = True
     self.mode = 'w'
     self.file = None
     if not os.path.exists(os.path.dirname(self.path)):
         os.makedirs(os.path.dirname(self.path))
     elif os.path.exists(self.path):
         if not os.path.isfile(self.path):
             raise Exception, "work file can not be a directory"
         if self.task.getProperty("append"):
             self.mode = 'a'
         else:
             divert =  self.task.getProperty("divert")
             backup =  self.task.getProperty("backup")
             if divert:
                 self.path = '.'.join((self.path, divert))
                 self.task.log("diverting to %s" % self.path, logging.DEBUG)
             elif backup:
                 dst = '.'.join((self.path, backup))
                 while os.path.exists(dst):
                     self.task.log("%s exists!" % dst, logging.WARNING)
                     dst = '.'.join((dst, backup))
                 os.rename(self.path, dst)
                 self.task.log("backup to %s" % dst, logging.DEBUG)
             else:
                 update = False
                 self.task.log("file %s exists" % self.path, logging.DEBUG)
     if update or self.task.getProperty("overwrite"):
         self.task.log("open file %s (%s)" % (self.path, self.mode), logging.DEBUG)
         TaskAdapter.runChildTasks(self)
     else:
         self.task.log("%s: nothing to do" % self.path, logging.INFO)
示例#3
0
 def runChildTasks(self):
     if 'key' in self.task.properties:
         self.key = self.task.getProperty('key')
     else:
         self.key = '_'.join((str(self.task.taskId), self.task.type))
     if not self.key in lock.locks:
         lock.locks[self.key] = open('/tmp/sweetpotato_%s' % self.key, 'a')
         self.task.log('Created queue %s' % self.key, logging.DEBUG)
     l = self.getLock()
     fcntl.flock(l, fcntl.LOCK_EX)
     TaskAdapter.runChildTasks(self)
     fcntl.flock(l, fcntl.LOCK_UN)
示例#4
0
 def runChildTasks(self):
     self.url = self.task.getProperty('url')
     self.doc = parse(self.url).getroot() 
     TaskAdapter.runChildTasks(self)
示例#5
0
 def runChildTasks(self):
     while True:
         TaskAdapter.runChildTasks(self)
         time.sleep(23);