Skip to content

Commit

Permalink
Fix several small issues with BaseMain
Browse files Browse the repository at this point in the history
Up version to 0.4.1
  • Loading branch information
dkarchmer committed Mar 13, 2022
1 parent 6cbd37a commit af42d4c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

### v0.4.1 (2022-03-13)

* Fix BaseMain Login method
* Fix PYPI error

### v0.3.0 (2022-03-13)

* Add missing PYPI long description
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ py.test
```bash
pip install -r requirements-build.txt

python setup.py sdist
python setup.py sdist bdist_wheel
twine check dist/*
# Publish
twine upload dist/*
Expand Down
7 changes: 2 additions & 5 deletions drf_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,8 @@ def login(self, password, username=None):
r = requests.post(url, data=payload, headers=DEFAULT_HEADERS)
if r.status_code in [200, 201]:
content = json.loads(r.content.decode())
if self.token_type in content:
self.token = content[self.token_type]

self.username = content['username']
logger.info('Welcome @{0} (token: {1})'.format(self.username, self.token))
self.token = content['token']
self.username = username
return True
else:
logger.error('Login failed: ' + str(r.status_code) + ' ' + r.content.decode())
Expand Down
11 changes: 8 additions & 3 deletions drf_client/helpers/base_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BaseMain(object):
'API_PREFIX': 'api/v1',
'TOKEN_TYPE': 'jwt',
'TOKEN_FORMAT': 'JWT {token}',
'USERNAME_KEY': 'username',
'LOGIN': 'auth/login/',
'LOGOUT': 'auth/logout/',
}
Expand Down Expand Up @@ -60,8 +61,7 @@ def main(self):
4. Call after_loging to do actual work with server data
"""
self.domain = self.get_domain()
self.options['DOMAIN'] = self.domain
self.api = RestApi(self.options)
self.api = RestApi(self.get_options())
self.before_login()
ok = self.login()
if ok:
Expand All @@ -70,6 +70,11 @@ def main(self):
# Following functions can be overwritten if needed
# ================================================

def get_options(self):
options = self.options
options['DOMAIN'] = self.domain
return options

def config_logging(self):
"""
Overwrite to change the way the logging package is configured
Expand Down Expand Up @@ -99,7 +104,7 @@ def login(self) -> bool:
Get password from user and login
"""
password = getpass.getpass()
ok = self.api.d1g1t_login(username=self.args.username, password=password)
ok = self.api.login(username=self.args.username, password=password)
if ok:
LOG.info('Welcome {0}'.format(self.args.username))
return ok
Expand Down
5 changes: 4 additions & 1 deletion requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pip
twine
pip
twine==3.2.0
setuptools>=40.8.0
wheel
tox
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pathlib
from setuptools import find_packages, setup
import version

# The directory containing this file
HERE = pathlib.Path(__file__).parent
Expand All @@ -9,15 +8,18 @@
README = (HERE / "README.md").read_text()

setup(name='django-rest-framework-client',
version=version.version,
version='0.4.1',
description='Python client for a DjangoRestFramework based web site',
long_description=README,
long_description_content_type="text/markdown",
url='https://github.com/dkarchmer/django-rest-framework-client',
author='David Karchmer',
author_email="[email protected]",
license='MIT',
packages=find_packages(exclude=("tests",)),
packages=[
'drf_client',
'drf_client.helpers',
],
install_requires=[
'requests',
],
Expand Down
1 change: 0 additions & 1 deletion version.py

This file was deleted.

0 comments on commit af42d4c

Please sign in to comment.