Example #1
0
def load_exp_uuids_cache():
    exp_dir = osp.join(settings.ROOT_PATH, 'output/run_exp_set')
    exp_names_cache = osp.join(exp_dir, "uuid_cache.txt")
    with open(exp_names_cache, 'r') as f:
        exp_names = f.readlines()
    exp_names = [uuid.strip() for uuid in exp_names]
    print("loaded uuid cache")
    print(exp_names)
    return exp_names
 def query_dev_uuid_path_by_sdx_path(self, sdx_path):
     """
     the behaviour is if we could get the uuid, then return, if not, just return the sdx.
     """
     self.logger.log("querying the sdx path of:{0}".format(sdx_path))
     #blkid path
     p = Popen([self.patching.blkid_path,sdx_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     identity,err = p.communicate()
     identity = identity.lower()
     self.logger.log("blkid output is: \n" + identity)
     uuid_pattern = 'uuid="'
     index_of_uuid = identity.find(uuid_pattern)
     identity = identity[index_of_uuid + len(uuid_pattern):]
     index_of_quote = identity.find('"')
     uuid = identity[0:index_of_quote]
     if(uuid.strip() == ""):
         #TODO this is strange?  BUGBUG
         return sdx_path
     return os.path.join("/dev/disk/by-uuid/",uuid)
 def query_dev_uuid_path_by_sdx_path(self, sdx_path):
     """
     the behaviour is if we could get the uuid, then return, if not, just return the sdx.
     """
     self.logger.log("querying the sdx path of:{0}".format(sdx_path))
     #blkid path
     p = Popen([self.patching.blkid_path,sdx_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     identity,err = p.communicate()
     identity = identity.lower()
     self.logger.log("blkid output is: \n" + identity)
     uuid_pattern = 'uuid="'
     index_of_uuid = identity.find(uuid_pattern)
     identity = identity[index_of_uuid + len(uuid_pattern):]
     index_of_quote = identity.find('"')
     uuid = identity[0:index_of_quote]
     if(uuid.strip() == ""):
         #TODO this is strange?  BUGBUG
         return sdx_path
     return os.path.join("/dev/disk/by-uuid/",uuid)