def copy_remote(data, dest, use_put=None):
 ret = None
 req = urllib2.Request(dest, data=data)
 if use_put:
  req.add_header('Content-Type', 'application/octet-stream')
  end = ((use_put['start'] + use_put['size']) - 1)
  req.add_header('Content-Range', ('bytes %s-%s/%s' % (use_put['start'], end, use_put['total'])))
  req.add_header('Content-Length', ('%s' % use_put['size']))
  req.get_method = (lambda : 'PUT')
 try:
  res = utils.urlopen(req)
  ret = res.info()
  res.close()
 except urllib2.HTTPError as e:
  if (e.code == 500):
   raise BkrProxyException('We have been aborted!!!')
  elif ((e.code == 400) and use_put):
   log.error(('Error(%s) failed to upload file %s' % (e.code, dest)))
 return ret

def copy_remote ( data , dest , use_put = None ) : ret = None req = urllib2 . Request ( dest , data = data ) if use_put : req . add_header ( 'Content-Type' , 'application/octet-stream' ) end = ( ( use_put [ 'start' ] + use_put [ 'size' ] ) - 1 ) req . add_header ( 'Content-Range' , ( 'bytes %s-%s/%s' % ( use_put [ 'start' ] , end , use_put [ 'total' ] ) ) ) req . add_header ( 'Content-Length' , ( '%s' % use_put [ 'size' ] ) ) req . get_method = ( lambda : 'PUT' ) try : res = utils . urlopen ( req ) ret = res . info ( ) res . close ( ) except urllib2 . HTTPError as e : if ( e . code == 500 ) : raise BkrProxyException ( 'We have been aborted!!!' ) elif ( ( e . code == 400 ) and use_put ) : log . error ( ( 'Error(%s) failed to upload file %s' % ( e . code , dest ) ) ) return ret
copy data to a remote server using http calls post or put using http post and put methods .