示例#1
0
 def do_import(self, arg, opts=None):
     '''Import an untracked job store to db.'''
     if opts.job not in self.cf.sections():
         self.stdout.write("Unexistent job.\n")
     else:
         cs = getattr(self.cf, opts.job)
         s = Scheme(self.cf, opts.job)
         lock = s.lock('import')
         i = Importer(self.cf, opts.job, session=s.sess)
         i.load()
         self.stdout.write("Job store imported.\n")
         self.stdout.write("Rebuilding the dmd database...\n")
         dmdfile = os.path.expanduser("~/.dardrive/dmd/%s.dmd" % opts.job)
         if os.path.exists(dmdfile):
             os.unlink(dmdfile)
         s.sess.delete(lock)
         s = Scheme(self.cf, opts.job)
         lock2 = s.lock('rebuild')
         r = Report(opts.job, session=s.sess)
         for cat in r.get_catalogs(order="asc"):
             if cat.date >= dt.strptime(cs.catalog_begin, "%Y-%m-%d"):
                 s.add_to_dmd(cat.id)
         s.sess.delete(lock2)
         s.sess.commit()
示例#2
0
 def do_rebuild_dmd(self, arg, opts=None):
     '''Re-creates the dmd for a given job.'''
     cf = getattr(self.cf, opts.job)
     sl = Scheme(self.cf, opts.job)
     lock = sl.lock("rebuild_dmd")
     self.logger.debug("Removing dmd for %s" % opts.job)
     dmdfile = os.path.expanduser("~/.dardrive/dmd/%s.dmd" % opts.job)
     if os.path.exists(dmdfile):
         os.unlink(dmdfile)
     s = Scheme(self.cf, opts.job)
     r = Report(opts.job, session=s.sess)
     for cat in r.get_catalogs(after=cf.catalog_begin, order="asc"):
         s.add_to_dmd(cat.id)
     sl.sess.delete(lock)
     sl.sess.commit()
     s.sess.commit()