def recv_file(self, request, stream, labels, start_position=0, retries=_max_retries): method_string, resource, headers = request.get_triplet() if self.config.progress_meter: progress = self.config.progress_class(labels, 0) else: info("Receiving file '%s', please wait..." % stream.name) timestamp_start = time.time() try: conn = ConnMan.get(self.get_hostname(resource['bucket'])) conn.c.putrequest(method_string, self.format_uri(resource)) for header in headers.keys(): conn.c.putheader(header, str(headers[header])) if start_position > 0: debug("Requesting Range: %d .. end" % start_position) conn.c.putheader("Range", "bytes=%d-" % start_position) conn.c.endheaders() response = {} http_response = conn.c.getresponse() response["status"] = http_response.status response["reason"] = http_response.reason response["headers"] = convertTupleListToDict( http_response.getheaders()) debug("Response: %s" % response) except ParameterError, e: raise
def recv_file(self, request, stream, labels, start_position = 0, retries = _max_retries): method_string, resource, headers = request.get_triplet() if self.config.progress_meter: progress = self.config.progress_class(labels, 0) else: info("Receiving file '%s', please wait..." % stream.name) timestamp_start = time.time() try: conn = ConnMan.get(self.get_hostname(resource['bucket'])) conn.c.putrequest(method_string, self.format_uri(resource)) for header in headers.keys(): conn.c.putheader(header, str(headers[header])) if start_position > 0: debug("Requesting Range: %d .. end" % start_position) conn.c.putheader("Range", "bytes=%d-" % start_position) conn.c.endheaders() response = {} http_response = conn.c.getresponse() response["status"] = http_response.status response["reason"] = http_response.reason response["headers"] = convertTupleListToDict(http_response.getheaders()) if response["headers"].has_key("x-amz-meta-s3cmd-attrs"): attrs = parse_attrs_header(response["headers"]["x-amz-meta-s3cmd-attrs"]) response["s3cmd-attrs"] = attrs debug("Response: %s" % response) except ParameterError, e: raise
def send_request(self, request, body = None, retries = _max_retries): method_string, resource, headers = request.get_triplet() debug("Processing request, please wait...") if not headers.has_key('content-length'): headers['content-length'] = body and len(body) or 0 try: # "Stringify" all headers for header in headers.keys(): headers[header] = str(headers[header]) conn = ConnMan.get(self.get_hostname(resource['bucket'])) uri = self.format_uri(resource) debug("Sending request method_string=%r, uri=%r, headers=%r, body=(%i bytes)" % (method_string, uri, headers, len(body or ""))) conn.c.request(method_string, uri, body, headers) response = {} http_response = conn.c.getresponse() response["status"] = http_response.status response["reason"] = http_response.reason response["headers"] = convertTupleListToDict(http_response.getheaders()) response["data"] = http_response.read() if response["headers"].has_key("x-amz-meta-s3cmd-attrs"): attrs = parse_attrs_header(response["headers"]["x-amz-meta-s3cmd-attrs"]) response["s3cmd-attrs"] = attrs debug("Response: " + str(response)) ConnMan.put(conn) except ParameterError, e: raise
def send_file(self, request, file, labels, buffer = '', throttle = 0, retries = _max_retries, offset = 0, chunk_size = -1): method_string, resource, headers = request.get_triplet() print method_string print resource print headers print "File size is " + str(file.content_length) data = file.stream.read() #data = ':'.join(format(ord(c), 'b') for c in file.stream.read()) size_left = size_total = len(data) print " I am inb here" if self.config.progress_meter: progress = self.config.progress_class(labels, size_total) else: info("Sending file '%s', please wait..." % file.name) timestamp_start = time.time() try: conn = ConnMan.get(self.get_hostname(resource['bucket'])) conn.c.putrequest(method_string, self.format_uri(resource)) print dir(file) headers['content-length'] = len(data) #headers['content-type'] = 'binary/octet-stream' for header in headers.keys(): print " Trying to print header" print header + " : " + str(headers[header]) conn.c.putheader(header, str(headers[header])) conn.c.endheaders() except ParameterError, e: raise
def send_request(self, request, body=None, retries=_max_retries): method_string, resource, headers = request.get_triplet() debug("Processing request, please wait...") if not headers.has_key('content-length'): headers['content-length'] = body and len(body) or 0 try: # "Stringify" all headers for header in headers.keys(): headers[header] = str(headers[header]) conn = ConnMan.get(self.get_hostname(resource['bucket'])) uri = self.format_uri(resource) debug( "Sending request method_string=%r, uri=%r, headers=%r, body=(%i bytes)" % (method_string, uri, headers, len(body or ""))) conn.c.request(method_string, uri, body, headers) response = {} http_response = conn.c.getresponse() response["status"] = http_response.status response["reason"] = http_response.reason response["headers"] = convertTupleListToDict( http_response.getheaders()) response["data"] = http_response.read() debug("Response: " + str(response)) ConnMan.put(conn) except ParameterError, e: raise
def send_file(self, request, file, labels, buffer = '', throttle = 0, retries = _max_retries, offset = 0, chunk_size = -1): method_string, resource, headers = request.get_triplet() size_left = size_total = headers.get("content-length") if self.config.progress_meter: progress = self.config.progress_class(labels, size_total) else: info("Sending file '%s', please wait..." % file.name) timestamp_start = time.time() try: conn = ConnMan.get(self.get_hostname(resource['bucket'])) conn.c.putrequest(method_string, self.format_uri(resource)) for header in headers.keys(): conn.c.putheader(header, str(headers[header])) conn.c.endheaders() except ParameterError, e: raise
def get_connection(self): conn = ConnMan.get(self.config.cloudfront_host, ssl=True) return conn
def get_connection(self): if self.config.proxy_host != "": raise ParameterError("CloudFront commands don't work from behind a HTTP proxy") conn = ConnMan.get(self.config.cloudfront_host) return conn
def get_connection(self): conn = ConnMan.get(self.config.cloudfront_host, ssl = True) return conn
def get_connection(self): if self.config.proxy_host != "": raise ParameterError( "CloudFront commands don't work from behind a HTTP proxy") conn = ConnMan.get(self.config.cloudfront_host) return conn