(self, *args, **kwargs)
return cmd
Prepare curl command line according to invocation options
Prepare curl command line according to invocation options
Prepare curl command line according to invocation options
def _mkcurlcmd(self, *args, **kwargs):
        """Prepare curl command line according to invocation options"""
        self._files["url"] = str(args[0])
        if "follow" in kwargs and kwargs["follow"]:
            self._opts["follow"] = ["-L"]
        if "post" in kwargs:
            self._opts["post"] = ["-X", "POST", "-H",
                                  "Content-Type: application/json"]
            self._opts["post"] += ["-d", json.dumps(kwargs["post"])]
        if "ctimeout" in kwargs:
            self._opts["ctimeout"] = ["--connect-timeout",
                                      str(kwargs["ctimeout"])]
        if "timeout" in kwargs:
            self._opts["timeout"] = ["-m", str(kwargs["timeout"])]
        if "proxy" in kwargs and kwargs["proxy"]:
            self._opts["proxy"] = ["--proxy", str(kwargs["proxy"])]
        elif self.http_proxy:
            self._opts["proxy"] = ["--proxy", self.http_proxy]
        if "header" in kwargs:
            for header_item in kwargs["header"]:
                if str(header_item).startswith("Authorization: Bearer"):
                    if "Signature=" in self._files["url"]:
                        continue
                    if "redirect" in kwargs:
                        continue
                self._opts["header"] += ["-H", str(header_item)]
        if 'v' in kwargs and kwargs['v']:
            self._opts["verbose"] = ["-v"]
        if "nobody" in kwargs and kwargs["nobody"]:
            self._opts["nobody"] = ["--head"]
        if "ofile" in kwargs:
            FileUtil(self._files["output_file"]).remove()
            self._files["output_file"] = kwargs["ofile"] + ".tmp"
            self._opts["timeout"] = ["-m", str(self.download_timeout)]
            if "resume" in kwargs and kwargs["resume"]:
                self._opts["resume"] = ["-C", "-"]
        cmd = ["curl"]
        if self._curl_exec and is_genstr(self._curl_exec):
            cmd = [self._curl_exec]
        for opt in self._opts.values():
            cmd += opt
        cmd.extend(["-D", self._files["header_file"], "-o",
                    self._files["output_file"], "--stderr",
                    self._files["error_file"], self._files["url"]])
        return cmd
def _mkcurlcmd ( self , * args , * * kwargs ) : self . _files [ "url" ] = str ( args [ 0 ] ) if "follow" in kwargs and kwargs [ "follow" ] : self . _opts [ "follow" ] = [ "-L" ] if "post" in kwargs : self . _opts [ "post" ] = [ "-X" , "POST" , "-H" , "Content-Type: application/json" ] self . _opts [ "post" ] += [ "-d" , json . dumps ( kwargs [ "post" ] ) ] if "ctimeout" in kwargs : self . _opts [ "ctimeout" ] = [ "--connect-timeout" , str ( kwargs [ "ctimeout" ] ) ] if "timeout" in kwargs : self . _opts [ "timeout" ] = [ "-m" , str ( kwargs [ "timeout" ] ) ] if "proxy" in kwargs and kwargs [ "proxy" ] : self . _opts [ "proxy" ] = [ "--proxy" , str ( kwargs [ "proxy" ] ) ] elif self . http_proxy : self . _opts [ "proxy" ] = [ "--proxy" , self . http_proxy ] if "header" in kwargs : for header_item in kwargs [ "header" ] : if str ( header_item ) . startswith ( "Authorization: Bearer" ) : if "Signature=" in self . _files [ "url" ] : continue if "redirect" in kwargs : continue self . _opts [ "header" ] += [ "-H" , str ( header_item ) ] if 'v' in kwargs and kwargs [ 'v' ] : self . _opts [ "verbose" ] = [ "-v" ] if "nobody" in kwargs and kwargs [ "nobody" ] : self . _opts [ "nobody" ] = [ "--head" ] if "ofile" in kwargs : FileUtil ( self . _files [ "output_file" ] ) . remove ( ) self . _files [ "output_file" ] = kwargs [ "ofile" ] + ".tmp" self . _opts [ "timeout" ] = [ "-m" , str ( self . download_timeout ) ] if "resume" in kwargs and kwargs [ "resume" ] : self . _opts [ "resume" ] = [ "-C" , "-" ] cmd = [ "curl" ] if self . _curl_exec and is_genstr ( self . _curl_exec ) : cmd = [ self . _curl_exec ] for opt in self . _opts . values ( ) : cmd += opt cmd . extend ( [ "-D" , self . _files [ "header_file" ] , "-o" , self . _files [ "output_file" ] , "--stderr" , self . _files [ "error_file" ] , self . _files [ "url" ] ] ) return cmd