Ejemplo n.º 1
0
    def local_sha1sum(self, local_file, task_id):
        try:
            sha_handler = lsha1()
            with open(local_file, 'r') as open_file:
                for line in open_file:
                    sha_handler.update(line)
            return sha_handler.hexdigest()
        except Exception, e:
	    logging.warning("Exception in local_checksum %s" % str(e))
            self.ret_map[task_id] = (-1, "local_sha1sum %s %s" %
                                     (local_file, str(e)))
            return None
Ejemplo n.º 2
0
 def local_sha1sum(self, local_file, task_id):
     try:
         sha_handler = lsha1()
         with open(local_file, 'r') as open_file:
             for line in open_file:
                 sha_handler.update(line)
         return sha_handler.hexdigest()
     # except (OSError, IOError):
     except Exception, e:
         self.ret_map[task_id] = (-1, "local_sha1sum %s %s" %
                                  (local_file, str(e)))
         return None
Ejemplo n.º 3
0
 def local_sha1sum(self, local_file, task_id):
     try:
         sha_handler = lsha1()
         with open(local_file, "r") as open_file:
             lines = open_file.readlines()
             for line in lines:
                 sha_handler.update(line)
             return sha_handler.hexdigest()
     # except (OSError, IOError):
     except Exception, e:
         self.ret_map[task_id] = (-1, "local_sha1sum %s failed" % local_file)
         return None
Ejemplo n.º 4
0
def cal_sha1sum(path_file):
    """
    calcualte a local file's checksum
    """
    sha_handler = lsha1()
    try:
        open_file = open(path_file, 'r')
    except (OSError, IOError):
        Log.error("Can not open file: %s" % path_file)
        return None
    lines = open_file.readlines()
    for line in lines:
        sha_handler.update(line)
    open_file.close()
    return sha_handler.hexdigest()