diff --git a/CHANGELOG.md b/CHANGELOG.md index d50f6ad..a6f4e24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index de0a579..1517434 100644 --- a/README.md +++ b/README.md @@ -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/* diff --git a/drf_client/connection.py b/drf_client/connection.py index 083b42c..b02aff1 100644 --- a/drf_client/connection.py +++ b/drf_client/connection.py @@ -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()) diff --git a/drf_client/helpers/base_main.py b/drf_client/helpers/base_main.py index 8c40e48..f489310 100644 --- a/drf_client/helpers/base_main.py +++ b/drf_client/helpers/base_main.py @@ -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/', } @@ -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: @@ -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 @@ -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 diff --git a/requirements-build.txt b/requirements-build.txt index 5486025..5865eca 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -1,3 +1,6 @@ pip -twine +pip +twine==3.2.0 +setuptools>=40.8.0 +wheel tox \ No newline at end of file diff --git a/setup.py b/setup.py index 8f67d56..43ae96e 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ import pathlib from setuptools import find_packages, setup -import version # The directory containing this file HERE = pathlib.Path(__file__).parent @@ -9,7 +8,7 @@ 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", @@ -17,7 +16,10 @@ author='David Karchmer', author_email="dkarchmer@gmail.com", license='MIT', - packages=find_packages(exclude=("tests",)), + packages=[ + 'drf_client', + 'drf_client.helpers', + ], install_requires=[ 'requests', ], diff --git a/version.py b/version.py deleted file mode 100644 index d5b63fd..0000000 --- a/version.py +++ /dev/null @@ -1 +0,0 @@ -version = '0.3.0' \ No newline at end of file