Perform a COPY request to a path
500279
def copy(path, options = {}, &block)
      perform_request Net::HTTP::Copy, path, options, &block
    end
1081796
def post(self, path, payload):
        """"""
        body = json.dumps(payload)
        return self._request(path, 'POST', body)
1090009
def pushPath_copy(self, d_msg, **kwargs):
        

        # Parse "header" information
        d_meta              = d_msg['meta']
        d_local             = d_meta['local']
        str_localPath       = d_local['path']
        d_remote            = d_meta['remote']
        d_transport         = d_meta['transport']
        d_copy              = d_transport['copy']

        # Pull the actual data into a dictionary holder
        d_curl                      = {
                                        'remoteServer': self.push_core(d_msg),
                                        'copy': {}
                                       }
        d_curl['copy']['status']    = d_curl['remoteServer']['status']
        if not d_curl['copy']['status']:
            d_curl['copy']['msg']   = "Copy on remote server failed!"
        else:
            d_curl['copy']['msg']   = "Copy on remote server success!"

        return d_curl
699598
def copy(self, src_url, dst_url):
        """"""
        src_bucket, src_key = _parse_url(src_url)
        dst_bucket, dst_key = _parse_url(dst_url)

        if not dst_bucket:
            dst_bucket = src_bucket
        params = {
            'copy_source': '/'.join((src_bucket, src_key)),
            'bucket': dst_bucket,
            'key': dst_key,
        }
        return self.call("CopyObject", **params)
614034
def request(self, path, action, data=''):
        """"""
        # Check if the path includes URL or not.
        head = self.base_url
        if path.startswith(head):
            path = path[len(head):]
            path = quote_plus(path, safe='/')
        if not path.startswith(self.api):
            path = self.api + path
        log.debug('Using path %s' % path)

        # If we have data, convert to JSON
        if data:
            data = json.dumps(data)
            log.debug('Data to sent: %s' % data)
        # In case of key authentication
        if self.private_key and self.public_key:
            timestamp = str(int(time.time()))
            log.debug('Using timestamp: {}'.format(timestamp))
            unhashed = path + timestamp + str(data)
            log.debug('Using message: {}'.format(unhashed))
            self.hash = hmac.new(str.encode(self.private_key),
                                 msg=unhashed.encode('utf-8'),
                                 digestmod=hashlib.sha256).hexdigest()
            log.debug('Authenticating with hash: %s' % self.hash)
            self.headers['X-Public-Key'] = self.public_key
            self.headers['X-Request-Hash'] = self.hash
            self.headers['X-Request-Timestamp'] = timestamp
            auth = False
        # In case of user credentials authentication
        elif self.username and self.password:
            auth = requests.auth.HTTPBasicAuth(self.username, self.password)
        # Set unlock reason
        if self.unlock_reason:
            self.headers['X-Unlock-Reason'] = self.unlock_reason
            log.info('Unlock Reason: %s' % self.unlock_reason)
        url = head + path
        # Try API request and handle Exceptions
        try:
            if action == 'get':
                log.debug('GET request %s' % url)
                self.req = requests.get(url, headers=self.headers, auth=auth,
                                        verify=False)
            elif action == 'post':
                log.debug('POST request %s' % url)
                self.req = requests.post(url, headers=self.headers, auth=auth,
                                         verify=False, data=data)
            elif action == 'put':
                log.debug('PUT request %s' % url)
                self.req = requests.put(url, headers=self.headers,
                                        auth=auth, verify=False,
                                        data=data)
            elif action == 'delete':
                log.debug('DELETE request %s' % url)
                self.req = requests.delete(url, headers=self.headers,
                                           verify=False, auth=auth)

            if self.req.content == b'':
                result = None
                log.debug('No result returned.')
            else:
                result = self.req.json()
                if 'error' in result and result['error']:
                    raise TPMException(result['message'])

        except requests.exceptions.RequestException as e:
            log.critical("Connection error for " + str(e))
            raise TPMException("Connection error for " + str(e))

        except ValueError as e:
            if self.req.status_code == 403:
                log.warning(url + " forbidden")
                raise TPMException(url + " forbidden")
            elif self.req.status_code == 404:
                log.warning(url + " forbidden")
                raise TPMException(url + " not found")
            else:
                message = ('%s: %s %s' % (e, self.req.url, self.req.text))
                log.debug(message)
                raise ValueError(message)

        return result
188654
def put_file(self, in_path, out_path):
        '''  '''

        vvv("PUT %s TO %s" % (in_path, out_path), host=self.host)
        if not os.path.exists(in_path):
            raise errors.AnsibleFileNotFound("file or module does not exist: %s" % in_path)
        try:
            shutil.copyfile(in_path, out_path)
        except shutil.Error:
            traceback.print_exc()
            raise errors.AnsibleError("failed to copy: %s and %s are the same" % (in_path, out_path))
        except IOError:
            traceback.print_exc()
            raise errors.AnsibleError("failed to transfer file to %s" % out_path)
293676
def copy(self, path):
        
        directoryPath = os.path.dirname(path)
        if not os.path.exists(directoryPath):
            os.makedirs(directoryPath)

        logger.debug('Create copy of %s in %s', os.path.basename(path), directoryPath)

        with self._snapshot() as source, _Directory(directoryPath) as dest:
            dest.SNAP_CREATE_V2(
                flags=BTRFS_SUBVOL_RDONLY,
                name=str(os.path.basename(path)),
                fd=source.fd,
            )

        with SnapShot(path) as destShot:
            flags = destShot.SUBVOL_GETFLAGS()
            destShot.SUBVOL_SETFLAGS(flags=flags.flags & ~BTRFS_SUBVOL_RDONLY)

            destShot.SET_RECEIVED_SUBVOL(
                uuid=self.received_uuid or self.uuid,
                stransid=self.sent_gen or self.current_gen,
                stime=timeOrNone(self.info.stime) or timeOrNone(self.info.ctime) or 0,
                flags=0,
            )

            destShot.SUBVOL_SETFLAGS(flags=flags.flags)
293337
function copyFile(srcPath, destPath) {
        let srcFileInfo = path.parse(srcPath) || {};
        if (!path.extname(destPath) && srcFileInfo.ext) {
            // destination is a directory!
            return copyFileIntoDirectory(srcPath, destPath);
        } else {
            return new Promise(function (resolve, reject) {
                fs.copy(srcPath, destPath, function (err) {
                    if (!err) {
                        resolve();
                    } else {
                        reject(err);
                    }
                });
            });
        }
    }
410190
def copy_file(self, path):
        
        if "*" in path:
            paths = _expand_paths(path)
            if paths:
                for path in paths:
                    self._copy_file(path)
        else:
            if os.path.isfile(path):
                return self._copy_file(path)
            else:
                logger.debug("File %s does not exist", path)
                return False
541673
async function copyFiles(srcPath: string, destPath: string) {
  return Promise.all(
    walk(srcPath).map(async absoluteSrcFilePath => {
      const relativeFilePath = path.relative(srcPath, absoluteSrcFilePath);
      await copyFile(
        absoluteSrcFilePath,
        path.resolve(destPath, relativeFilePath),
      );
    }),
  );
}
295387
public void copy(CopyRequest request) {
    call(
      new PostRequest(path("copy"))
        .setParam("id", request.getId())
        .setParam("name", request.getName())
        .setParam("organization", request.getOrganization())
        .setMediaType(MediaTypes.JSON)
    ).content();
  }
299687
function copyFileSync(sourcePath, destPath) {
  var data = fs.readFileSync(sourcePath);
  var stat = fs.statSync(sourcePath);
  fs.writeFileSync(destPath, data);
  fs.chmodSync(destPath, stat.mode);
}
1356215
def _request(self, path, method, body=None):
        ""
        h = httplib2.Http()
        resp, content = h.request(
            self.base_url + path,
            method,
            body = json.dumps(body),
        )
        if resp['status'] == "200":
            return json.loads(content)
        else:
            raise IOError(
                "Got %s reponse from server (%s)" % (
                    resp['status'],
                    content,
                )
            )
216149
def request(self, path, method='GET', params=None, type=REST_TYPE):
        """"""
        response_text = self._get_http_client(type).request(path, method, params)

        if not response_text:
            return response_text

        response_json = json.loads(response_text)

        if 'errors' in response_json:
            raise (ErrorException([Error().load(e) for e in response_json['errors']]))

        return response_json
531821
def _copy(self):
    """"""
    copied_uri = Uri(self.uri.scheme, self.uri.host, self.uri.port,
                     self.uri.path, self.uri.query.copy())
    new_request = HttpRequest(uri=copied_uri, method=self.method,
                              headers=self.headers.copy())
    new_request._body_parts = self._body_parts[:]
    return new_request
725453
def put(self, path, payload):
        """"""
        body = json.dumps(payload)
        return self._request(path, 'PUT', body)
474836
def copyfile(source, destination, force=True):
    '''
    '''
    if os.path.exists(destination) and force is True:
        os.remove(destination)
    shutil.copyfile(source, destination)
    return destination