示例#1
0
文件: Plugin.py 项目: stpierre/bcfg2
    def load(self):
        """Load any pending data from a file."""
        if not os.path.exists(self.pending_file):
            return True
        pending_data = []
        try:
            savefile = open(self.pending_file, 'r')
            pending_data = cPickle.load(savefile)
            savefile.close()
        except Exception:
            e = sys.exc_info()[1]
            self.logger.warning("Failed to load pending data: %s" % e)
            return False
        for (pmetadata, pdata) in pending_data:
            # check that shutdown wasnt called early
            if self.terminate.isSet():
                return False

            try:
                while True:
                    try:
                        metadata = self.core.build_metadata(pmetadata)
                        break
                    except MetadataRuntimeError:
                        pass

                    self.terminate.wait(5)
                    if self.terminate.isSet():
                        return False

                self.work_queue.put_nowait((metadata,
                                            lxml.etree.XML(pdata,
                                                           parser=Bcfg2.Server.XMLParser)))
            except Full:
                self.logger.warning("Queue.Full: Failed to load queue data")
                break
            except lxml.etree.LxmlError:
                lxml_error = sys.exc_info()[1]
                self.logger.error("Unable to load saved interaction: %s" %
                                  lxml_error)
            except MetadataConsistencyError:
                self.logger.error("Unable to load metadata for save "
                                  "interaction: %s" % pmetadata)
        try:
            os.unlink(self.pending_file)
        except:
            self.logger.error("Failed to unlink save file: %s" %
                              self.pending_file)
        self.logger.info("Loaded pending %s data" % self.name)
        return True
示例#2
0
 def load_state(self):
     if not self.use_yum:
         data = file(self.cachefile)
         (self.packages, self.deps, self.provides, self.filemap,
          self.url_map) = cPickle.load(data)
示例#3
0
文件: Apt.py 项目: mkdfh/bcfg2-dev
 def load_state(self):
     data = file(self.cachefile)
     self.pkgnames, self.deps, self.provides = cPickle.load(data)
示例#4
0
 def load_state(self):
     data = file(self.cachefile)
     self.pkgnames, self.deps, self.provides = cPickle.load(data)
示例#5
0
文件: Yum.py 项目: calvinchengx/bcfg2
 def load_state(self):
     if not self.use_yum:
         data = file(self.cachefile)
         (self.packages, self.deps, self.provides,
          self.filemap, self.url_map) = cPickle.load(data)
示例#6
0
文件: Apt.py 项目: stpierre/bcfg2
 def load_state(self):
     data = open(self.cachefile)
     (self.pkgnames, self.deps, self.provides,
      self.essentialpkgs) = cPickle.load(data)
示例#7
0
 def load_state(self):
     data = BUILTIN_FILE_TYPE(self.cachefile)
     self.pkgnames, self.deps, self.provides = cPickle.load(data)
示例#8
0
 def load_state(self):
     data = BUILTIN_FILE_TYPE(self.cachefile)
     (self.packages, self.deps, self.provides, \
      self.filemap, self.url_map) = cPickle.load(data)