-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/fix-prospector-issues' into develop
- Loading branch information
Showing
46 changed files
with
857 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
sha: 64943e86417774b9d6ba63c74e00f8cc3e2119e0 | ||
hooks: | ||
- id: check-ast | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- id: double-quote-string-fixer | ||
- id: fix-encoding-pragma | ||
- id: trailing-whitespace | ||
- id: name-tests-test | ||
|
||
- repo: https://github.com/guykisel/prospector-mirror | ||
sha: 00fbd80101566b1b9c873c71f2ab7b95b8bd0a7d | ||
hooks: | ||
- id: prospector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pycrypto==2.6 | ||
pycrypto==2.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Package with CLI tool and API.""" | ||
__version__ = (0, 7, 2) | ||
|
||
|
||
def get_version(): | ||
"""Return current version.""" | ||
return '.'.join([str(i) for i in __version__]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Package with account command set.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,60 @@ | ||
# coding: utf-8 | ||
""" | ||
Copyright (c) 2013 Crystalnix. | ||
License BSD, see LICENSE for more details. | ||
""" | ||
# -*- coding: utf-8 -*- | ||
"""Module to keep login and logout command.""" | ||
import six | ||
from getpass import getpass | ||
from ..core.commands import AbstractCommand | ||
from .managers import AccountManager | ||
|
||
|
||
# pylint: disable=abstract-method | ||
class BaseAccountCommand(AbstractCommand): | ||
"""Base class for login and logout commands.""" | ||
|
||
def __init__(self, app, app_args, cmd_name=None): | ||
"""Construct new instance.""" | ||
super(BaseAccountCommand, self).__init__(app, app_args, cmd_name) | ||
self.manager = AccountManager(self.config) | ||
|
||
|
||
class LoginCommand(BaseAccountCommand): | ||
|
||
"""Sign into serverauditor cloud.""" | ||
|
||
# pylint: disable=no-self-use | ||
def prompt_username(self): | ||
"""Ask username prompt.""" | ||
return six.moves.input("Serverauditor's username: ") | ||
|
||
def get_parser(self, prog_name): | ||
"""Create command line argument parser. | ||
Use it to add extra options to argument parser. | ||
""" | ||
parser = super(LoginCommand, self).get_parser(prog_name) | ||
parser.add_argument('-u', '--username', metavar='USERNAME') | ||
parser.add_argument('-p', '--password', metavar='PASSWORD') | ||
parser.add_argument('--sync-sshconfig', action='store_true') | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
"""Process CLI call.""" | ||
username = parsed_args.username or self.prompt_username() | ||
password = parsed_args.password or self.prompt_password() | ||
self.manager.login(username, password) | ||
self.log.info('Sign into serverauditor cloud.') | ||
|
||
|
||
class LogoutCommand(BaseAccountCommand): | ||
|
||
"""Sign out serverauditor cloud.""" | ||
|
||
def get_parser(self, prog_name): | ||
"""Create command line argument parser. | ||
Use it to add extra options to argument parser. | ||
""" | ||
parser = super(LogoutCommand, self).get_parser(prog_name) | ||
parser.add_argument('--clear-sshconfig', action='store_true') | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
def take_action(self, _): | ||
"""Process CLI call.""" | ||
self.manager.logout() | ||
self.log.info('Sign out serverauditor cloud.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
# coding: utf-8 | ||
# -*- coding: utf-8 -*- | ||
"""Module for main app class.""" | ||
import logging | ||
# pylint: disable=import-error | ||
from cliff.app import App | ||
# pylint: disable=import-error | ||
from cliff.commandmanager import CommandManager | ||
|
||
from . import __version__ | ||
|
||
|
||
def get_version(): | ||
return '.'.join(map(str, __version__)) | ||
from . import get_version | ||
|
||
|
||
# pylint: disable=too-few-public-methods | ||
class ServerauditorApp(App): | ||
"""Class for CLI application.""" | ||
|
||
def __init__(self): | ||
"""Construct new CLI application.""" | ||
super(ServerauditorApp, self).__init__( | ||
description='Serverauditor app', | ||
version=get_version(), | ||
command_manager=CommandManager('serverauditor.handlers'), | ||
) | ||
|
||
def configure_logging(self): | ||
"""Change logging level for request package.""" | ||
super(ServerauditorApp, self).configure_logging() | ||
logging.getLogger('requests').setLevel(logging.WARNING) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Package with user data manipulation command.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.