Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest setuptools wheel
python -m pip install flake8 pyright pyflakes pytest setuptools wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --ignore=E203,W503,E722,E731 --max-complexity=100 --max-line-length=160
- name: Lint with pyright (type checking)
run: |
echo TODO - fix pyright errors # pyright cf_remote
- name: Lint with pyflakes
run: |
pyflakes cf_remote
- name: Test with pytest
run: |
pytest
Expand Down
5 changes: 5 additions & 0 deletions cf_remote/aramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def __init__(
connection to the host

"""
assert type(user) is str and len(user) > 0
assert type(host_name) is str and len(host_name) > 0
parts = urlparse("ssh://%s" % host_name)
self.user = user or parts.username
self.port = port or parts.port
Expand All @@ -226,12 +228,15 @@ def __init__(
@property
def login(self):
"""user@host_name for the host"""
assert self.user is not None
assert self.host_name is not None
return self.user + "@" + self.host_name

@property
def host_name_port(self):
""" "host_name:port" or just "host_name" if using standard port"""
port_spec = (":%d" % self.port) if self.port != _DEFAULT_SSH_PORT else ""
assert self.host_name is not None
return self.host_name + port_spec

def __str__(self):
Expand Down
3 changes: 2 additions & 1 deletion cf_remote/cloud_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"region": "eu-west-1",
},
"windows": {
"note": "Note that typically we rely on custom pre-configured windows imimages with ssh installed and pre-populated public keys so an image spawned from this criteria will not come with ssh built-in and ready to go.",
"note": "Note that typically we rely on custom pre-configured windows imimages with ssh installed and pre-populated public keys"
+ " so an image spawned from this criteria will not come with ssh built-in and ready to go.",
"owner_id": "801119661308",
"name_pattern": "Windows_Server-{version}-English-Core-Base*",
"user": "Administrator",
Expand Down
5 changes: 1 addition & 4 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
whoami,
get_package_name,
user_error,
)
from cf_remote.utils import (
user_error,
is_package_url,
print_progress_dot,
ChecksumError,
Expand Down Expand Up @@ -477,7 +474,7 @@ def spawn(

def _is_saved_group(vms_info, group_name):
group = vms_info[group_name]
return group.get("meta", {}).get("saved") == True
return group.get("meta", {}).get("saved") is True


def _delete_saved_group(vms_info, group_name):
Expand Down
3 changes: 1 addition & 2 deletions cf_remote/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from cf_remote.utils import is_in_past, canonify
from cf_remote import log
import re
import sys


class Artifact:
Expand Down Expand Up @@ -223,7 +222,7 @@ def __init__(self, edition="enterprise"):
and release["lts_branch"] not in self.supported_branches
):
continue
if "latestLTS" in release and release["latestLTS"] == True:
if "latestLTS" in release and release["latestLTS"] is True:
self.default = rel
rel.default = True
self.releases.append(rel)
Expand Down
3 changes: 2 additions & 1 deletion cf_remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ def install_host(
return 1
else:
log.warning(
"You did not specify --bootstrap in the install command, so CFEngine has been installed, but not started.\nTo fix this, run:\ncf-remote agent --hosts HOSTS --bootstrap BOOTSTRAP"
"You did not specify --bootstrap in the install command, so CFEngine has been installed, but not started.\n"
+ "To fix this, run:\ncf-remote agent --hosts HOSTS --bootstrap BOOTSTRAP"
)
if demo:
if hub:
Expand Down
4 changes: 2 additions & 2 deletions cf_remote/spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def region(self):
return data.extra["zone"].name

region = self._driver.region
if (type(region) != str) and hasattr(region, "name"):
if (type(region) is not str) and hasattr(region, "name"):
return region.name
else:
return str(region)
Expand Down Expand Up @@ -397,7 +397,7 @@ def spawn_vm_in_aws(
sizes = criteria.get("sizes") or aws_defaults["sizes"]
small = sizes[architecture]["size"]
large = sizes[architecture]["xlsize"]
if size == None:
if size is None:
size = (large or small) if (role == "hub") else (small or large)
user = criteria.get("user") or aws_defaults["user"]
ami = criteria.get("ami") or _get_ami(criteria, driver)
Expand Down
2 changes: 1 addition & 1 deletion cf_remote/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def copy_file(input_path, output_path):


def is_different_checksum(checksum, content):
assert type(content) == bytes
assert type(content) is bytes

digest = hashlib.sha256(content).digest().hex()
return checksum != digest
Expand Down
2 changes: 0 additions & 2 deletions cf_remote/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from collections import OrderedDict
from cf_remote.utils import (
is_different_checksum,
user_error,
write_json,
mkdir,
parse_json,
)
from cf_remote import log
from cf_remote.paths import cf_remote_dir, cf_remote_packages_dir
Expand Down
6 changes: 0 additions & 6 deletions tests/test_packages.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import json
from collections import OrderedDict

from cf_remote.packages import Release
from cf_remote.utils import read_json
from cf_remote import log

# log.set_level("debug")


def test_release():
Expand Down