Exemplo n.º 1
0
        # Save all the command line arguments as attributes of self
        self.__dict__.update(args.__dict__)

    def name_as_invoked(self):
        return self.prog_name


# Main (fold)
cmd_line = CommandLine(sys.argv)
try:
    with Logging(
            argv=sys.argv, prog_name=cmd_line.name_as_invoked(),
            use_notifier=cmd_line.notify
    ) as logger:
        generator = PasswordGenerator(
            logger=logger,
            init=cmd_line.init,
            stateless=cmd_line.stateless)
        if cmd_line.init:
            logger.terminate()

        # Open the accounts file
        generator.read_accounts(cmd_line.template)

        # If requested, list the available templates and then exit
        if cmd_line.list:
            logger.display(
                "MASTER PASSWORDS:\n   " + '\n   '.join(
                    sorted(generator.master_password.password_names())))
            logger.display(
                "\nTEMPLATES:\n   " + '\n   '.join(
                    sorted(generator.all_templates())))
Exemplo n.º 2
0
from .authkeys import AuthKeys
from .utils import run_sftp, date
from shlib import to_path, Run
from inform import (
    comment, cull, conjoin, error, fatal, fmt, narrate, os_error, warn
)
from abraxas import PasswordGenerator, PasswordError, Logging
import pexpect

# Open Abraxas password generator
logger = Logging(exception=PasswordError)
pw = PasswordGenerator(logger=logger)
pw.read_accounts()

# Class that manages the SSH key pairs
class Key:
    def __init__(self, name, data, update, skip, trial_run):
        self.keyname = name
        self.data = data
        self.update = update
        self.skip = skip
        self.trial_run = trial_run
        self.warning = ''
        narrate(name)

    def generate(self):
        comment('    creating key')
        keyname = self.keyname
        data = self.data
        servers = self.data.get('servers', [])