예제 #1
0
파일: myndfskr.py 프로젝트: zigit/ferenda
 def download(self, basefile=None, reporter=None):
     if basefile:
         # expect a basefile on the form "subrepoalias:basefile" or
         # just "subrepoalias:"
         subrepoalias, basefile = basefile.split(":")
     else:
         subrepoalias = None
     if not basefile:
         basefile = None  # ie convert '' => None
     found = False
     for cls in self.subrepos:
         if (subrepoalias is None or
             cls.alias == subrepoalias):
             found = True
             inst = self.get_instance(cls)
             basefiles = []
             try:
                 ret = inst.download(basefile, reporter=basefiles.append)
             except Exception as e:
                 loc = util.location_exception(e)
                 self.log.error("download for %s failed: %s (%s)" % (cls.alias, e, loc))
                 ret = False
             finally:
                 for b in basefiles:
                     util.link_or_copy(inst.store.documententry_path(b),
                                       self.store.documententry_path(b))
                 # msbfs/entries/.root.json -> myndfs/entries/msbfs.json
                 util.link_or_copy(inst.store.documententry_path(".root"),
                                   self.store.documententry_path(inst.alias))
     if not found:
         self.log.error("Couldn't find any subrepo with alias %s" % subrepoalias)
예제 #2
0
    def copy_parsed(self, basefile, instance):
        # If the distilled and parsed links are recent, assume that
        # all external resources are OK as well
        
        if (not self.config.force and 
            util.outfile_is_newer([instance.store.distilled_path(basefile)],
                                  self.store.distilled_path(basefile)) and
            util.outfile_is_newer([instance.store.parsed_path(basefile)],
                                  self.store.parsed_path(basefile))):
            self.log.debug("%s: Attachments are (likely) up-to-date" % basefile)
            return

        util.link_or_copy(instance.store.documententry_path(basefile),
                          self.store.documententry_path(basefile))

        util.link_or_copy(instance.store.distilled_path(basefile),
                          self.store.distilled_path(basefile))

        util.link_or_copy(instance.store.parsed_path(basefile),
                          self.store.parsed_path(basefile))

        cnt = 0
        if instance.store.storage_policy == "dir":
            for attachment in instance.store.list_attachments(basefile, "parsed"):
                cnt += 1
                src = instance.store.parsed_path(basefile, attachment=attachment)
                target = self.store.parsed_path(basefile, attachment=attachment)
                util.link_or_copy(src, target)
            if cnt:
                self.log.debug("%s: Linked %s attachments from %s to %s" %
                               (basefile,
                                cnt,
                                os.path.dirname(instance.store.parsed_path(basefile)),
                                os.path.dirname(self.store.parsed_path(basefile))))
예제 #3
0
 def download(self, basefile=None, reporter=None):
     if basefile:
         # expect a basefile on the form "subrepoalias:basefile" or
         # just "subrepoalias:"
         subrepoalias, basefile = basefile.split(":")
     else:
         subrepoalias = None
     if not basefile:
         basefile = None  # ie convert '' => None
     found = False
     for cls in self.subrepos:
         if (subrepoalias is None or cls.alias == subrepoalias):
             found = True
             inst = self.get_instance(cls)
             # the feature where subrepos has a slighly higher
             # loglevel to avoid creating almost-duplicate "OK" log
             # messages is not useful for downloading. So we work
             # around it here.
             subrepo_loglevel = inst.log.getEffectiveLevel()
             if subrepo_loglevel == self.log.getEffectiveLevel() + 1:
                 inst.log.setLevel(self.log.getEffectiveLevel())
             basefiles = []
             try:
                 ret = inst.download(basefile, reporter=basefiles.append)
             except Exception as e:
                 loc = util.location_exception(e)
                 self.log.error("download for %s failed: %s (%s)" %
                                (cls.alias, e, loc))
                 ret = False
             finally:
                 inst.log.setLevel(subrepo_loglevel)
                 for b in basefiles:
                     util.link_or_copy(inst.store.documententry_path(b),
                                       self.store.documententry_path(b))
                 # msbfs/entries/.root.json -> myndfs/entries/msbfs.json
                 util.link_or_copy(
                     inst.store.documententry_path(".root"),
                     self.store.documententry_path(inst.alias))
     if not found:
         self.log.error("Couldn't find any subrepo with alias %s" %
                        subrepoalias)
예제 #4
0
 def download(self, basefile=None, reporter=None):
     if basefile:
         # expect a basefile on the form "subrepoalias:basefile" or
         # just "subrepoalias:"
         subrepoalias, basefile = basefile.split(":")
     else:
         subrepoalias = None
     if not basefile:
         basefile = None  # ie convert '' => None
     found = False
     for cls in self.subrepos:
         if (subrepoalias is None or
             cls.alias == subrepoalias):
             found = True
             inst = self.get_instance(cls)
             # the feature where subrepos has a slighly higher
             # loglevel to avoid creating almost-duplicate "OK" log
             # messages is not useful for downloading. So we work
             # around it here.
             subrepo_loglevel = inst.log.getEffectiveLevel()
             if subrepo_loglevel == self.log.getEffectiveLevel() + 1:
                 inst.log.setLevel(self.log.getEffectiveLevel())
             basefiles = []
             try:
                 ret = inst.download(basefile, reporter=basefiles.append)
             except Exception as e:
                 loc = util.location_exception(e)
                 self.log.error("download for %s failed: %s (%s)" % (cls.alias, e, loc))
                 ret = False
             finally:
                 inst.log.setLevel(subrepo_loglevel)
                 for b in basefiles:
                     util.link_or_copy(inst.store.documententry_path(b),
                                       self.store.documententry_path(b))
                 # msbfs/entries/.root.json -> myndfs/entries/msbfs.json
                 util.link_or_copy(inst.store.documententry_path(".root"),
                                   self.store.documententry_path(inst.alias))
     if not found:
         self.log.error("Couldn't find any subrepo with alias %s" % subrepoalias)
예제 #5
0
    def copy_parsed(self, basefile, instance):
        # If the distilled and parsed links are recent, assume that
        # all external resources are OK as well

        if (not self.config.force and util.outfile_is_newer(
            [instance.store.distilled_path(basefile)],
                self.store.distilled_path(basefile)) and util.outfile_is_newer(
                    [instance.store.parsed_path(basefile)],
                    self.store.parsed_path(basefile))):
            self.log.debug("%s: Attachments are (likely) up-to-date" %
                           basefile)
            return

        util.link_or_copy(instance.store.documententry_path(basefile),
                          self.store.documententry_path(basefile))

        util.link_or_copy(instance.store.distilled_path(basefile),
                          self.store.distilled_path(basefile))

        util.link_or_copy(instance.store.parsed_path(basefile),
                          self.store.parsed_path(basefile))

        cnt = 0
        if instance.store.storage_policy == "dir":
            for attachment in instance.store.list_attachments(
                    basefile, "parsed"):
                cnt += 1
                src = instance.store.parsed_path(basefile,
                                                 attachment=attachment)
                target = self.store.parsed_path(basefile,
                                                attachment=attachment)
                util.link_or_copy(src, target)
            if cnt:
                self.log.debug(
                    "%s: Linked %s attachments from %s to %s" %
                    (basefile, cnt,
                     os.path.dirname(instance.store.parsed_path(basefile)),
                     os.path.dirname(self.store.parsed_path(basefile))))