Commit 340c944d authored by Łukasz Nowak's avatar Łukasz Nowak

recurls: Simplfy from recurlests

parent 2ed59df0
...@@ -23,11 +23,11 @@ from setuptools import setup, find_packages ...@@ -23,11 +23,11 @@ from setuptools import setup, find_packages
setup( setup(
name='recurlests', name='recurls',
version='0.0.0', version='0.0.0',
author='Lukasz Nowak', author='Lukasz Nowak',
author_email='luke@nexedi.com', author_email='luke@nexedi.com',
description="Recurlests - requests like curl wrapper", description="Recurls - requests like curl wrapper",
long_description=__doc__, long_description=__doc__,
classifiers=[ classifiers=[
'Environment :: Console', 'Environment :: Console',
...@@ -38,7 +38,7 @@ setup( ...@@ -38,7 +38,7 @@ setup(
'later (GPLv3+)', 'later (GPLv3+)',
], ],
keywords='requests url curl', keywords='requests url curl',
url='https://lab.nexedi.com/luke/recurlests', url='https://lab.nexedi.com/luke/recurls',
license='GPLv3+ with wide exception for FOSS', license='GPLv3+ with wide exception for FOSS',
install_requires=[ install_requires=[
'requests', # for the great CaseInsensitiveDict 'requests', # for the great CaseInsensitiveDict
...@@ -50,7 +50,7 @@ setup( ...@@ -50,7 +50,7 @@ setup(
package_dir={"": "src"}, package_dir={"": "src"},
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'recurl = recurlests.cli:runRecurl', 'recurl = recurls.cli:runRecurl',
] ]
}, },
) )
import click import click
from pprint import pprint from pprint import pprint
from . import recurlests from . import recurls
@click.command(short_help="Runs curl's wrapper recurl") @click.command(short_help="Runs curl's wrapper recurl")
@click.option('--headers/--no-headers', help="Shows response headers", default=False, show_default=True) @click.option('--headers/--no-headers', help="Shows response headers", default=False, show_default=True)
...@@ -10,7 +10,7 @@ from . import recurlests ...@@ -10,7 +10,7 @@ from . import recurlests
@click.option('--ip', help="IP to resolve to") @click.option('--ip', help="IP to resolve to")
@click.argument("url") @click.argument("url")
def runRecurl(headers, output, curl, follow, ip, url): def runRecurl(headers, output, curl, follow, ip, url):
mimikra = recurlests.Recurlests(curl) mimikra = recurls.Recurls(curl)
response = mimikra.get(url, ip=ip, allow_redirects=follow) response = mimikra.get(url, ip=ip, allow_redirects=follow)
print('Effective HTTP version:', response.effective_http_version) print('Effective HTTP version:', response.effective_http_version)
print('Response status code:', response.status_code) print('Response status code:', response.status_code)
......
...@@ -7,7 +7,7 @@ import gzip ...@@ -7,7 +7,7 @@ import gzip
import os import os
class RecurlestsResponse(object): class RecurlsResponse(object):
# properties: # properties:
# content Content of the response, in bytes. # content Content of the response, in bytes.
# cookies A CookieJar of Cookies the server sent back. # cookies A CookieJar of Cookies the server sent back.
...@@ -27,7 +27,7 @@ class RecurlestsResponse(object): ...@@ -27,7 +27,7 @@ class RecurlestsResponse(object):
return json.loads(self.text, *args, **kwargs) return json.loads(self.text, *args, **kwargs)
class Recurlests(object): class Recurls(object):
"""curl command wrapper, mimicing requests""" """curl command wrapper, mimicing requests"""
def __init__(self, curl='curl'): def __init__(self, curl='curl'):
self.curl = curl self.curl = curl
...@@ -120,7 +120,7 @@ class Recurlests(object): ...@@ -120,7 +120,7 @@ class Recurlests(object):
prc = subprocess.Popen( prc = subprocess.Popen(
command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE
) )
response = RecurlestsResponse() response = RecurlsResponse()
response.command_output, response.command_error = [ response.command_output, response.command_error = [
q.decode() for q in prc.communicate()] q.decode() for q in prc.communicate()]
response.command_returncode = prc.returncode response.command_returncode = prc.returncode
......
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