Exemple #1
0
def image_type_form(extract_path: str) -> ImageType:
    for entry in image_type_list:
        has_root = False
        if entry.root_path is None:
            has_root = True
        else:
            root_path = extract_path + entry.root_path
            has_root = SUDO.folder_check(root_path)
        has_meta = False
        if entry.meta_path is None:
            has_meta = True
        else:
            meta_path = extract_path + entry.meta_path
            has_meta = SUDO.file_check(meta_path)
        if has_root and has_meta:
            return entry
    raise Exception(f"missing type for {extract_path}")
Exemple #2
0
 def smart_get(self, local_url:str, remote_url:str) -> None:
     "fetch resource when local-vs-remote headers have changed"
     local, remote = self.parse(local_url, remote_url)
     if SUDO.file_check(local.path):
         logger.debug(f"smart.get.present: {remote_url}")
         local_head = self.local_head(local_url)
         remote_head = self.remote_head(remote_url)
         head_comp = compare_header(local_head, remote_head)
         logger.debug(f"smart.get.{head_comp}: {remote_url}")
         if head_comp == HeadComp.same:
             pass
         elif head_comp == HeadComp.different:
             logger.debug(f"smart.get.{head_comp}: remote={remote_head}")
             logger.debug(f"smart.get.{head_comp}:  local={local_head}")
             self.get(local_url, remote_url)
         elif head_comp == HeadComp.undetermined:
             logger.debug(f"smart.get.{head_comp}: remote={remote_head}")
             logger.debug(f"smart.get.{head_comp}:  local={local_head}")
             self.get(local_url, remote_url)
         else:
             assert False, f"wrong head_comp: {head_comp}"
     else:
         logger.debug(f"smart.get.missing: {remote_url}")
         self.get(local_url, remote_url)
Exemple #3
0
 def has_archive(self) -> bool:
     return SUDO.file_check(self.archive_path())