mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
release 0.10
This commit is contained in:
+5
-4
@@ -4,26 +4,27 @@ import subprocess
|
||||
from subprocess import Popen, PIPE
|
||||
from pythonbrew.log import logger
|
||||
from pythonbrew.util import to_str
|
||||
from pythonbrew.exceptions import CurlFetchException
|
||||
|
||||
class Curl(object):
|
||||
def __init__(self):
|
||||
returncode = subprocess.call("command -v curl > /dev/null", shell=True)
|
||||
if returncode:
|
||||
logger.info("pythonbrew required curl. curl was not found in your path.")
|
||||
logger.log("pythonbrew required curl. curl was not found in your path.")
|
||||
sys.exit(1)
|
||||
|
||||
def read(self, url):
|
||||
p = Popen("curl -skL %s" % url, stdout=PIPE, shell=True)
|
||||
p.wait()
|
||||
if p.returncode:
|
||||
raise
|
||||
raise Exception('Failed to read.')
|
||||
return p.stdout.read()
|
||||
|
||||
def readheader(self, url):
|
||||
p = Popen("curl --head -skL %s" % url, stdout=PIPE, shell=True)
|
||||
p.wait()
|
||||
if p.returncode:
|
||||
raise
|
||||
raise Exception('Failed to readheader.')
|
||||
respinfo = {}
|
||||
for line in p.stdout:
|
||||
line = to_str(line.strip())
|
||||
@@ -39,4 +40,4 @@ class Curl(object):
|
||||
p = Popen("curl -# -kL %s -o %s" % (url, filename), shell=True)
|
||||
p.wait()
|
||||
if p.returncode:
|
||||
raise
|
||||
raise CurlFetchException('Failed to fetch.')
|
||||
|
||||
Reference in New Issue
Block a user