Пример #1
0
    def do_run(self):
        self.rcount = 0
        self.rlen = len(self.recipes)
        if not self.one_file:
            self.outdir = self.out
            if os.path.exists(self.outdir):
                if not os.path.isdir(self.outdir):
                    self.outdir = self.unique_name(self.outdir)
                    os.makedirs(self.outdir)
            else:
                os.makedirs(self.outdir)

        oneFileOpenByMyself = self.one_file \
                and type(self.out) in [str,unicode] \
                and self.open_files
        multiFileOpenByMyself = not self.one_file and self.open_files

        if oneFileOpenByMyself:
            self.ofi = open(self.out, 'wb')
        else:
            self.ofi = self.out
        self.write_header()
        self.suspended = False
        self.terminated = False
        first = True
        self.append_referenced_recipes()
        for r in self.recipes:
            self.check_for_sleep()
            msg = _("Exported %(number)s of %(total)s recipes") % {
                'number': self.rcount,
                'total': self.rlen
            }
            self.emit('progress', float(self.rcount) / float(self.rlen), msg)
            fn = None
            if multiFileOpenByMyself:
                fn = self.generate_filename(r, self.ext, add_id=True)
                self.ofi = open(fn, 'wb')
            if self.padding and not first:
                self.ofi.write(self.padding)
            e = self.exporter(out=self.ofi,
                              r=r,
                              rd=self.rd,
                              **self.exporter_kwargs)
            self.connect_subthread(e)
            e.do_run()
            self.recipe_hook(r, fn, e)
            if multiFileOpenByMyself:
                self.ofi.close()
            self.rcount += 1
            first = False
        self.write_footer()
        if oneFileOpenByMyself:
            self.ofi.close()
        self.timer.end()
        self.emit('progress', 1, _("Export complete."))
        print_timer_info()
Пример #2
0
 def do_run (self):
     self.rcount = 0
     self.rlen = len(self.recipes)        
     if not self.one_file:
         self.outdir=self.out
         if os.path.exists(self.outdir):
             if not os.path.isdir(self.outdir):
                 self.outdir=self.unique_name(self.outdir)
                 os.makedirs(self.outdir)
         else: os.makedirs(self.outdir)
     
     oneFileOpenByMyself = self.one_file and type(self.out)==str and self.open_files   
     multiFileOpenByMyself = not self.one_file and self.open_files
                 
     if oneFileOpenByMyself:
         self.ofi=open(self.out,'wb')
     else: self.ofi = self.out
     self.write_header()
     self.suspended = False
     self.terminated = False
     first = True
     self.append_referenced_recipes()
     for r in self.recipes:
         self.check_for_sleep()
         msg = _("Exported %(number)s of %(total)s recipes")%{'number':self.rcount,'total':self.rlen}
         self.emit('progress',float(self.rcount)/float(self.rlen), msg)
         fn=None
         if multiFileOpenByMyself:
             fn=self.generate_filename(r,self.ext,add_id=True)
             self.ofi=open(fn,'wb')
         if self.padding and not first:
             self.ofi.write(self.padding)
         e=self.exporter(out=self.ofi, r=r, rd=self.rd, **self.exporter_kwargs)
         self.connect_subthread(e)
         e.do_run()
         self.recipe_hook(r,fn,e)
         if multiFileOpenByMyself:
             self.ofi.close()
         self.rcount += 1
         first = False
     self.write_footer()
     if oneFileOpenByMyself:
         self.ofi.close()
     self.timer.end()
     self.emit('progress',1,_("Export complete."))
     print_timer_info()
Пример #3
0
 def suspend (self):
     timeaction = TimeAction('importer.suspend',10)
     debug('Suspend!',0)
     self.suspended = True
     timeaction.end()
     print_timer_info()
Пример #4
0
 def suspend (self):
     timeaction = TimeAction('importer.suspend',10)
     debug('Suspend!',0)
     self.suspended = True
     timeaction.end()
     print_timer_info()
Пример #5
0
 def suspend(self):
     timeaction = TimeAction("importer.suspend", 10)
     debug("Suspend!", 0)
     self.suspended = True
     timeaction.end()
     print_timer_info()