def generate_url(self, method, bucket, key, path_args, headers):
     
     expires = long(0)
     
     if self.expiresin:
         expires = long(round(time.time() * 1000)) + long(self.expiresin)  #time.time()*1000获取当前时间的毫秒数
     elif self.expires:
         expires = long(self.expires)
     else:
         raise Exception("Illegal expires state")
    
     #单位转换为秒
     expires /= 1000
     canonical_string = Utils.make_canonicalstring(method, bucket, key, path_args, headers, str(expires))
     encoded_canonical = Utils.encode(self.secret_access_key, canonical_string, True)
     
     path_args = path_args if path_args else {}
     path_args["Signature"] = encoded_canonical
     path_args["Expires"] = str(expires)  #将long型转换为string型
     path_args["AWSAccessKeyId"] = self.access_key_id
            
     calling_format = Utils.get_callingformat_for_bucket(self.calling_format, bucket)
     
     if self.is_secure and not isinstance(calling_format, PathFormat) and bucket.find( "." ) != -1:
         raise Exception("You are making an SSL connection, however, the bucket contains periods and \
                          the wildcard certificate will not match by default.  Please consider using HTTP.") 
     
     #需要进行异常检查
     try:
         return_string = calling_format.get_full_url(self.is_secure, self.server, self.port, bucket, key, path_args)
     except Exception as e:
         return_string = "Exception generating url " + e.strerror
            
     return return_string