Commit 8c6e7352 authored by Łukasz Nowak's avatar Łukasz Nowak

backup

parent 1797eb42
......@@ -48,6 +48,9 @@ setup(
python_requires=">=3.5",
packages=find_packages("src"),
package_dir={"": "src"},
extras_require={
"dev": ["pytest", "pyflakes", "mock"]
},
entry_points={
'console_scripts': [
'recurl = recurls.cli:runRecurl',
......
from .recurls import Recurls
from .recurls import Recurls, RecurlsResponse
......@@ -38,6 +38,16 @@ class Recurls(object):
def put(self, url, **kwargs):
return self.request('PUT', url, **kwargs)
def _call_curl(self, command_list):
prc = subprocess.Popen(
command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
response = RecurlsResponse()
response.command_output, response.command_error = [
q.decode() for q in prc.communicate()]
response.command_returncode = prc.returncode
return response
def request(
self,
method,
......@@ -117,17 +127,8 @@ class Recurls(object):
'--connect-timeout', str(timeout[0]),
'--max-time', str(timeout[1])])
command_list.append(url)
prc = subprocess.Popen(
command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
response = RecurlsResponse()
response.command_output, response.command_error = [
q.decode() for q in prc.communicate()]
response.command_returncode = prc.returncode
try:
response.write_out_json = json.loads(response.command_output)
except Exception:
raise
response = self._call_curl(command_list)
response.write_out_json = json.loads(response.command_output)
with open(response_header_file) as fh:
response.header_text = fh.read()
response.headers = CaseInsensitiveDict()
......@@ -184,7 +185,7 @@ class Recurls(object):
response.time_starttransfer = response.write_out_json[
'time_starttransfer']
response.time_total = response.write_out_json['time_total']
response.elapsed = float(response.time_total)
response.elapsed = response.time_total
response.url = response.write_out_json['url']
response.url_effective = response.write_out_json['url_effective']
response.urlnum = response.write_out_json['urlnum']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment