Skip to content

Commit 0721e4e

Browse files
author
Mark Beacom
authored
Merge pull request #11 from mbeacom/misc-updates
Update docstrings, docs, and typing
2 parents 6112fb7 + c358087 commit 0721e4e

File tree

12 files changed

+201
-75
lines changed

12 files changed

+201
-75
lines changed

.DS_Store

-8 KB
Binary file not shown.

.stickler.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
linters:
3+
black:
4+
fixer: false
5+
flake8:
6+
python: 3
7+
max-line-length: 120
8+
max-complexity: 20
9+
fixer: false

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
password: $PYPI_PASSWORD
3232
distributions: "sdist bdist_wheel"
3333
skip_existing: true
34+
skip_cleanup: true
3435
on:
3536
tags: true
3637
- provider: releases

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Change Log
2+
3+
## [v0.0.3](https://github.com/mbeacom/cloudendure-python/tree/v0.0.3) (2019-06-20)
4+
[Full Changelog](https://github.com/mbeacom/cloudendure-python/compare/v0.0.2...v0.0.3)
5+
6+
**Implemented enhancements:**
7+
8+
- Update pip dependencies [\#3](https://github.com/mbeacom/cloudendure-python/pull/3) ([mbeacom](https://github.com/mbeacom))
9+
10+
**Merged pull requests:**
11+
12+
- Update README.md [\#4](https://github.com/mbeacom/cloudendure-python/pull/4) ([twarnock2w](https://github.com/twarnock2w))
13+
14+
## [v0.0.2](https://github.com/mbeacom/cloudendure-python/tree/v0.0.2) (2019-06-16)
15+
[Full Changelog](https://github.com/mbeacom/cloudendure-python/compare/v0.0.1...v0.0.2)
16+
17+
**Implemented enhancements:**
18+
19+
- Pointed API usecase and CLI additions [\#2](https://github.com/mbeacom/cloudendure-python/pull/2) ([mbeacom](https://github.com/mbeacom))
20+
21+
## [v0.0.1](https://github.com/mbeacom/cloudendure-python/tree/v0.0.1) (2019-05-30)
22+
23+
24+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

Pipfile.lock

Lines changed: 34 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# cloudendure-python
22

3-
Python wrapper and CLI for CloudEndure
3+
Python wrapper and CLI for [CloudEndure](https://www.cloudendure.com/)
44

55
[![Build Status](https://travis-ci.com/mbeacom/cloudendure-python.svg?branch=master)](https://travis-ci.com/mbeacom/cloudendure-python)
66

77
[Documentation](https://mbeacom.github.io/cloudendure-python/)
88

9-
Package version: `0.0.3`
9+
Package version: `0.0.4`
1010

1111
## Requirements
1212

@@ -95,3 +95,7 @@ Logging in for the first time will generate the `~/.cloudendure.yml` file.
9595
## Coming Soon
9696

9797
This project is currently a work in progress and will actively change. This client has not yet been finalized and is entirely subject to change.
98+
99+
## Changelog
100+
101+
Check out the [CHANGELOG](CHANGELOG.md)

cloudendure/api.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,12 @@ def login(self, username="", password=""):
9090
_xsrf_token (str): The XSRF token to be used for subsequent API requests.
9191
9292
"""
93-
endpoint: str = "login"
9493
_username: str = self.config.active_config["username"] or username
9594
_password: str = self.config.active_config["password"] or password
9695
_auth: Dict[str, str] = {"username": _username, "password": _password}
9796

9897
# Attempt to login to the CloudEndure API via a POST request.
99-
response: requests.Response = self.api_call(
100-
"login", "post", data=json.dumps(_auth)
101-
)
102-
# response: requests.Response = self.session.post(f'{self.api_endpoint}/{endpoint}', json=_auth)
98+
response: requests.Response = self.api_call("login", "post", data=json.dumps(_auth))
10399

104100
# Check whether or not the request was successful.
105101
if response.status_code not in [200, 307]:
@@ -117,8 +113,11 @@ def login(self, username="", password=""):
117113
)
118114
raise CloudEndureUnauthorized()
119115

120-
# print('response: ', response, response.cookies)
121-
_xsrf_token: str = str(response.cookies["XSRF-TOKEN"])
116+
# Grab the XSRF token received from the response, as stored in cookies.
117+
# _xsrf_token: str = str(response.cookies["XSRF-TOKEN"])
118+
_xsrf_token: str = str(response.cookies.get("XSRF-TOKEN", ""))
119+
if not _xsrf_token:
120+
raise CloudEndureException("Failed to fetch a token from CloudEndure!")
122121

123122
# Strip the XSRF token of wrapping double-quotes from the cookie.
124123
if _xsrf_token.startswith('"') and _xsrf_token.endswith('"'):

cloudendure/cloudendure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
MIGRATION_WAVE: str = os.environ.get("CLOUDENDURE_MIGRATION_WAVE", "0")
3131
CLONE_STATUS: str = os.environ.get("CLOUDENDURE_CLONE_STATUS", "NOT_STARTED")
3232
MAX_LAG_TTL: int = int(os.environ.get("CLOUDENDURE_MAX_LAG_TTL", "90"))
33+
SHARE_IMAGE: str = os.environ.get("", "")
3334

3435

3536
class CloudEndure:
@@ -201,6 +202,7 @@ def update_blueprint(
201202
except Exception as e:
202203
print(f"Updating blueprint task failed! {e}")
203204
return False
205+
return True
204206

205207
def launch(self, project_id=global_project_id, launch_type="test", dry_run=False):
206208
"""Launch the test target instances."""

lambda/exceptions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
"""Define the Lambda specific exceptions."""
3+
4+
5+
class LambdaException(Exception):
6+
"""Define the generic AWS Lambda exception."""
7+
8+
pass
9+
10+
11+
class InvalidPayload(LambdaException):
12+
"""Define the exception to be raised when an invalid payload is encountered."""
13+
14+
pass
15+
16+
17+
class ImproperlyConfigured(LambdaException):
18+
"""Define the exception to be raised if the environment is improperly configured or missing."""
19+
20+
pass

0 commit comments

Comments
 (0)