NetEase Cloud Object store access log by default generates a log file by the hour, which is not conducive to the overall data of the day, so consider merging multiple log files into one file #!/usr/bin/evn python# -*- coding: utf-8 -*-import nosimport timeimport sysimport osimport reaccess_key = "54175b3a0a544f07a81d618719d44a0a" secret_key = "513b131cd66d46f6bc5a3e5ca5784780" bucket = "Access-log" date = time.strftime ('%y-%m-%d ', Time.localtime (Time.time () - 24*60*60)) prefix = ' Aoshu ' +dateclient = nos. Client (Access_key, secret_key) def get_object_lists (): try: object_lists = client.list_objects (Bucket, prefix=prefix) file_lists = [] for object_list in object_lists["Response"].findall ("Contents"): file_lists.append (Object_list.finD ("Key"). Text) print object_ List.find ("Key") .text if not file_lists: print "There is no log file in this time period, quit program ..." sys.exit (1) else: #print file_ lists return file_lists except nos.exceptions.ServiceException as e: print ( " serviceexception: %s\n " " Status_ Code: %s\n " "error_type: %s\n" "error_code: %s\n" "request_id: %s\n" "message: %s\n" ) % ( e, e.status_code, e.error_type,  E.ERROR_CODE,             E.REQUEST_ID, e.message ) except nos.exceptions.clientexception as e: print ( " clientexception: %s\n " " message: %s\n " ) % ( e, e.message ) Def save_log (): objects_lists = get_object_lists () log_file_name= "Nos.log" with open (Log_file_name, ' a ') as f: for object in objects_lists: try: &Nbsp; result = client.get_ Object (Bucket,object) f.write (Result.get ("body"). Read ()) except nos.exceptions.ServiceException as e: print ( "serviceexception: %s\n" "status_code: %s\n" "error_type: %s \ n " " Error_code : %s\n "   &Nbsp; "request_id: %s\n" "message: %s\n" ) % ( e , e.status_code, e.error_type, e.error_code, e.request_id, e.message ) except nos.exceptions.ClientException as e: print ( "Clientexception: %s\ N " " message: %s\n " ) % ( e, e.message ) return log_file_nameif __name__== ' __main__ ': save_log ()
Python script implements access log merge