Skip to content

Commit

Permalink
Merge pull request #143 from termius/update-copyright
Browse files Browse the repository at this point in the history
Update copyright
  • Loading branch information
EvgeneOskin authored Mar 2, 2020
2 parents 2a5e944 + d15c9b9 commit 94ce520
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[run]
branch = True
include = termius/**.py
source = termius
omit = tests/unit/*

[report]
precision = 2
Expand Down
5 changes: 5 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pep257:
- D203 # 1 blank line required before
- D213
- D400
- D415

pylint:
options:
Expand All @@ -28,6 +29,10 @@ pylint:
- fixme
disable:
- super-on-old-class
- no-self-use
- useless-object-inheritance
- consider-using-dict-comprehension
- keyword-arg-before-vararg

pyroma:
run: true
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
install:
- git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh .. && cd -
- sudo apt-get install pandoc
- pip install -U pip setuptools
- pip install -U . -r dev-requirements.txt
- pip install -r dev-requirements.txt
- pip install -U -e .
- pip install codecov
# command to run tests
script:
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013, Crystalnix.
Copyright (c) 2020, Termius Corporation.

Redistribution and use in source and binary forms of the software as well
as documentation, with or without modification, are permitted provided
Expand Down Expand Up @@ -27,4 +27,4 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
DAMAGE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Termius CLI utility

[![Build status](https://travis-ci.org/Crystalnix/termius-cli.svg?branch=master)](https://travis-ci.org/Crystalnix/termius-cli)
[![Code Climate](https://codeclimate.com/github/Crystalnix/termius-cli/badges/gpa.svg)](https://codeclimate.com/github/Crystalnix/termius-cli)
[![Test Coverage](https://codeclimate.com/github/Crystalnix/termius-cli/badges/coverage.svg)](https://codeclimate.com/github/Crystalnix/termius-cli/coverage)
[![Build status](https://travis-ci.org/termius/termius-cli.svg?branch=master)](https://travis-ci.org/termius/termius-cli)
[![Code Climate](https://codeclimate.com/github/termius/termius-cli/badges/gpa.svg)](https://codeclimate.com/github/termius/termius-cli)
[![Test Coverage](https://codeclimate.com/github/termius/termius-cli/badges/coverage.svg)](https://codeclimate.com/github/termius/termius-cli/coverage)

Provides command line interface for cross-platform terminal Termius.

Expand Down Expand Up @@ -131,4 +131,4 @@ $ termius export-ssh-config # Export to ./termius/sshconfig

## License

Please see [LICENSE](https://github.com/Crystalnix/termius-cli/blob/master/LICENSE).
Please see [LICENSE](https://github.com/termius/termius-cli/blob/master/LICENSE).
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
tar_url='https://github.com/Crystalnix/termius-cli/archive/master.zip'
tar_url='https://github.com/termius/termius-cli/archive/master.zip'

command_exists() {
command -v "$@" > /dev/null 2>&1
Expand Down
6 changes: 4 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
mock
nose
pytest
pytest-cov
coverage
prospector[with_pyroma]==0.12.4
pylint==1.6.5
prospector[with_pyroma]==1.1.6.2
pyflakes==1.6.0
pyroma==2.0
paver
bumpversion
Expand Down
10 changes: 2 additions & 8 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,16 @@ def bats():
sh('bats --tap tests/integration')


@task
def nosetests():
"""Run unit tests."""
sh('nosetests')


@task
def completion_tests():
"""Run integration tests for bash completion."""
sh('nosetests tests/integration/completion/bash/')
sh('pytest tests/integration/completion/bash/')


@task
def coverage():
"""Run test and collect coverage."""
sh('nosetests --with-coverage')
sh('pytest --cov -- tests/unit')
sh('coverage xml')


Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def get_long_description():
name='termius',
version=__version__,
license='BSD',
author='Crystalnix',
author_email='contacts@crystalnix.com',
url='https://github.com/Crystalnix/termius-cli',
author='Termius Corporation',
author_email='[email protected].com',
url='https://github.com/termius/termius-cli',
description='Termius ssh-config utility.',
long_description=get_long_description(),
keywords=['termius', 'crystalnix'],
Expand Down
4 changes: 2 additions & 2 deletions termius/account/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def extend_parser(self, parser):
)
return parser

def take_action(self, args):
def take_action(self, parsed_args):
"""Process CLI call."""
settings = {
k: getattr(args, k)
k: getattr(parsed_args, k)
for k in ('synchronize_key', 'agent_forwarding')
}
self.manager.set_settings(settings)
Expand Down
1 change: 0 additions & 1 deletion termius/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def configure_logging(self):
"""Change logging level for request package."""
super(TermiusApp, self).configure_logging()
logging.getLogger('requests').setLevel(logging.WARNING)
return

# pylint: disable=no-self-use
def configure_signals(self):
Expand Down
8 changes: 4 additions & 4 deletions termius/cloud/client/cryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ def post_encrypt_data(self, data):
data = base64.b64encode(data)
return to_str(data)

def _aes_encrypt(self, *args):
return self._aes_process(self.encryptor, *args)
def _aes_encrypt(self, *args, **kwargs):
return self._aes_process(self.encryptor, *args, **kwargs)

def _aes_decrypt(self, *args):
return self._aes_process(self.decryptor, *args)
def _aes_decrypt(self, *args, **kwargs):
return self._aes_process(self.decryptor, *args, **kwargs)

def _aes_process(self, get_operation, initialization_vector, data):
operation = get_operation(self.get_cipher(initialization_vector))
Expand Down
1 change: 1 addition & 0 deletions termius/cloud/client/transformers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ class DeletBadEncrypted(TermiusException):

def __init__(self, model):
"""Create new exception and keep model for reuse."""
super(DeletBadEncrypted, self).__init__()
self.model = model
20 changes: 9 additions & 11 deletions termius/cloud/client/transformers/many.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ def supported_models(self):
Host, PFRule,
TagHost
)
else:
return (
Snippet, SshConfig,
Tag, Group,
Host, PFRule,
TagHost
)
return (
Snippet, SshConfig,
Tag, Group,
Host, PFRule,
TagHost
)


class SoftDeleteMixin(object):
Expand All @@ -65,8 +64,7 @@ def soft_delete(self, model):
"""
if model.id:
return self.storage.delete(model)
else:
return self.get_delete_strategy().delete(model)
return self.get_delete_strategy().delete(model)

def delete_list(self, models):
"""Delete models from the storage and put it to deleted_set."""
Expand Down Expand Up @@ -164,8 +162,8 @@ def to_model_child_list(self, transformer, payload):
for i in payload:
try:
child_model = transformer.to_model(i)
except DeletBadEncrypted as e:
bad_encrypted_models.append(e.model)
except DeletBadEncrypted as exception:
bad_encrypted_models.append(exception.model)
else:
models.append(child_model)
return models, bad_encrypted_models
Expand Down
3 changes: 1 addition & 2 deletions termius/cloud/client/transformers/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def to_payload(self, model):
return None
if model.remote_instance:
return model.remote_instance.id
else:
return '{model.set_name}/{model.id}'.format(model=model)
return '{model.set_name}/{model.id}'.format(model=model)

def id_from_payload(self, payload):
"""Get remote id from payload."""
Expand Down
2 changes: 1 addition & 1 deletion termius/core/commands/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def get_visible_identity(self, ssh_config_merger):
i.identity for i in ssh_config_merger.get_entry_stack()
if i.identity and i.identity.get('is_visible')
]
return (stack and stack[0]) or None
return stack[0] if stack else None

# pylint: disable=no-self-use
def get_identity_merger(self, ssh_config_merger):
Expand Down
3 changes: 1 addition & 2 deletions termius/core/commands/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,4 @@ def generate_requirement_message(self, options):
"""Render error message for missed required options."""
if len(options) == 1:
return 'Option {} is required!'.format(options[0])
else:
return 'Options {} are required!'.format(','.join(options))
return 'Options {} are required!'.format(','.join(options))
2 changes: 1 addition & 1 deletion termius/core/models/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __setattr__(self, name, value):
def transform_int(self, value):
"""Transform value to int or return None."""
try:
return (value is not None and int(value)) or None
return int(value) if value is not None else None
except ValueError as exception:
return self.handle_value_error(exception)

Expand Down
2 changes: 1 addition & 1 deletion termius/core/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate(self):
return list(self.iterate_groups())

def iterate_groups(self):
"""Iterator over instances parent groups."""
"""Iterate over instances parent groups."""
group = self.root_group
while group:
yield group
Expand Down
2 changes: 1 addition & 1 deletion termius/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Config(object):
"""Class for application config."""

paths = ['{application_directory}/config']
write_mode = (PY2 and 'wb') or 'w'
write_mode = 'wb' if PY2 else 'w'

def __init__(self, command, **kwargs):
"""Create new config."""
Expand Down
4 changes: 2 additions & 2 deletions termius/core/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def _internal_delete(self, model):
assert identificator

models = self._internal_get_all(type(model))
for index, model in enumerate(models):
if model.id == identificator:
for index, model_obj in enumerate(models):
if model_obj.id == identificator:
models.pop(index)
break
self.driver[model.set_name] = models
Expand Down
2 changes: 1 addition & 1 deletion termius/core/storage/idgenerators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
""""Package to keep storage id generating logic."""
"""Package to keep storage id generating logic."""
from uuid import uuid4


Expand Down
4 changes: 2 additions & 2 deletions termius/core/storage/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def delete(self, model):
self.set_delete_sets(delete_sets)
return model

def remove_intersection(self, sets):
def remove_intersection(self, deleted_sets):
"""Remove from deleted_sets intersection with sets passed."""
delete_sets = self.get_delete_sets()
for set_name, id_list in sets.items():
for set_name, id_list in deleted_sets.items():
delete_sets.remove_all(set_name, id_list)
self.set_delete_sets(delete_sets)
13 changes: 6 additions & 7 deletions termius/formatters/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ def format_identity_file(ssh_key_file):
if ssh_key_file:
safe_key_path = shlex_quote(str(ssh_key_file))
return '-i {}'.format(safe_key_path)
else:
return ''
return ''


def format_port(port):
"""Render port option."""
return (port and '-p {}'.format(port)) or ''
return '-p {}'.format(port) if port else ''


def format_pfrule(pfrule):
"""Render port forwarding option."""
format_str = '-{0.pf_type} {binding}'.format
return (pfrule and format_str(pfrule, binding=pfrule.binding)) or ''
return format_str(pfrule, binding=pfrule.binding) if pfrule else ''


def format_strict_host_key(strict):
Expand All @@ -68,13 +67,13 @@ def format_use_ssh_key(use_ssh_key):
def format_timeout(timeout):
"""Render server alive interval option."""
format_str = '-o ServerAliveInterval={}'.format
return (timeout and format_str(timeout)) or ''
return format_str(timeout) if timeout else ''


def format_keep_alive_packages(keep_alive_packages):
"""Render server alive count max option."""
format_str = '-o ServerAliveCountMax={}'.format
return (keep_alive_packages and format_str(keep_alive_packages)) or ''
return format_str(keep_alive_packages) if keep_alive_packages else ''


def format_agent_forwarding(agent_forwarding):
Expand All @@ -86,4 +85,4 @@ def format_agent_forwarding(agent_forwarding):
def _bool_to_text(format_str, value):
if value is None:
return ''
return value and format_str('yes') or format_str('no')
return format_str('yes') if value else format_str('no')
1 change: 0 additions & 1 deletion termius/formatters/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ def emit_one(self, column_names, data, stdout, parsed_args):
address = parsed_args.address or ssh_config['address']
ssh_key_path = ssh_config.get('ssh_key_path')
stdout.write(self.render_command(ssh_config, address, ssh_key_path))
return
3 changes: 1 addition & 2 deletions termius/handlers/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ def take_action(self, parsed_args):
host = instance.host if instance.host else instance
ssh_config = self.get_merged_ssh_config(host)
self.call_ssh_command(ssh_config, host, instance)
return

def call_ssh_command(self, ssh_config, host, instance):
"""Call ssh command to connect to host."""
pfrule = isinstance(instance, PFRule) and instance or None
pfrule = instance if isinstance(instance, PFRule) else None
command = self.ssh_config_to_command(ssh_config, host.address, pfrule)
subprocess.call(command, shell=True)

Expand Down
6 changes: 3 additions & 3 deletions termius/handlers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def extend_parser(self, parser):
self.ssh_config_args.add_agrs(parser)
return parser

def validate(self, group):
def validate(self, instance):
"""Raise an error when group have cyclic folding."""
group_id = group.id
group_id = instance.id
if not group_id:
return
group_stack = self.get_group_stack(group)
group_stack = self.get_group_stack(instance)
not_unique = any([i.id for i in group_stack if i.id == group_id])
if not_unique:
raise InvalidArgumentException('Cyclic group founded!')
Expand Down
2 changes: 1 addition & 1 deletion termius/handlers/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_hosts(self, parent_group):
group_stack = self.get_group_stack(parent_group)
group_id_stack = [i.id for i in group_stack]
filter_operation = {'group': None}
if len(group_id_stack) > 0:
if group_id_stack:
filter_operation['group.id.rcontains'] = group_id_stack
return self.storage.exclude(Host, any, **filter_operation)

Expand Down
1 change: 1 addition & 0 deletions termius/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_ssh_key_field(self, args):
)
if args.ssh_key:
return self.get_safely_instance(SshKey, args.ssh_key)
return None

def extend_parser(self, parser):
"""Add more arguments to parser."""
Expand Down
Loading

0 comments on commit 94ce520

Please sign in to comment.