Python clint.textui.colored.blue() Examples

The following are 21 code examples of clint.textui.colored.blue(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module clint.textui.colored , or try the search function .
Example #1
Source File: __init__.py    From s3tk with MIT License 6 votes vote down vote up
def reset_object(bucket_name, key, dry_run, acl):
    obj = s3().Object(bucket_name, key)
    str_key = unicode_key(key)

    try:
        obj_acl = obj.Acl()
        mode = determine_mode(obj_acl)

        if mode == acl:
            puts(str_key + ' ' + colored.green('ACL already ' + acl))
            return 'ACL already ' + acl
        elif dry_run:
            puts(str_key + ' ' + colored.yellow('ACL to be updated to ' + acl))
            return 'ACL to be updated to ' + acl
        else:
            obj_acl.put(ACL=acl)
            puts(str_key + ' ' + colored.blue('ACL updated to ' + acl))
            return 'ACL updated to ' + acl

    except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e:
        puts(str_key + ' ' + colored.red(str(e)))
        return 'error' 
Example #2
Source File: __init__.py    From s3tk with MIT License 6 votes vote down vote up
def delete_unencrypted_version(bucket_name, key, id, dry_run):
    object_version = s3().ObjectVersion(bucket_name, key, id)

    try:
        obj = object_version.get()
        if obj.get('ServerSideEncryption') or obj.get('SSECustomerAlgorithm'):
            puts(key + ' ' + id + ' ' + colored.green('encrypted'))
            return 'encrypted'
        else:
            if dry_run:
                puts(key + ' ' + id + ' ' + colored.blue('to be deleted'))
                return 'to be deleted'
            else:
                puts(key + ' ' + id + ' ' + colored.blue('deleted'))
                object_version.delete()
                return 'deleted'
    except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e:
        puts(key + ' ' + id + ' ' + colored.red(str(e)))
        return 'error' 
Example #3
Source File: iptv.py    From IPTV with MIT License 6 votes vote down vote up
def menu():
    print ""
    print colored.yellow("################")
    print colored.yellow("##### IPTV #####")
    print colored.yellow("##### v" + cr.version + " ###")
    print colored.yellow("################")
    print ""
    print colored.blue("Menu")
    print "0 - Exit"
    print "1 - Search for some Servers"
    print "2 - Look at the servers list"
    print "3 - Select language, default is Italian"
    print "4 - Brute force all server from the list"
    print "5 - Brute force random server from the list"
    print "6 - Brute force specific server from the list"
    print "7 - Provide a random server to attack"
    print "" 
Example #4
Source File: __init__.py    From s3tk with MIT License 6 votes vote down vote up
def fix_check(klass, buckets, dry_run, fix_args={}):
    for bucket in fetch_buckets(buckets):
        check = klass(bucket)
        check.perform()

        if check.status == 'passed':
            message = colored.green('already ' + check.pass_message)
        elif check.status == 'denied':
            message = colored.red('access denied')
        else:
            if dry_run:
                message = colored.yellow('to be ' + check.pass_message)
            else:
                try:
                    check.fix(fix_args)
                    message = colored.blue('just ' + check.pass_message)
                except botocore.exceptions.ClientError as e:
                    message = colored.red(str(e))

        puts(bucket.name + ' ' + message) 
Example #5
Source File: utils.py    From mech with MIT License 5 votes vote down vote up
def init_box(name, version, force=False, save=True, requests_kwargs={}):
    if not locate('.mech', '*.vmx'):
        name_version_box = add_box(name, name=name, version=version, force=force, save=save, requests_kwargs=requests_kwargs)
        if not name_version_box:
            puts_err(colored.red("Cannot find a valid box with a VMX file in it"))
            sys.exit(1)
        name, version, box = name_version_box
        # box = locate(os.path.join(*filter(None, (HOME, 'boxes', name, version))), '*.box')

        puts_err(colored.blue("Extracting box '{}'...".format(name)))
        makedirs('.mech')
        if sys.platform == 'win32':
            cmd = tar_cmd('-xf', box, force_local=True)
        else:
            cmd = tar_cmd('-xf', box)
        if cmd:
            startupinfo = None
            if os.name == "nt":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
            proc = subprocess.Popen(cmd, cwd='.mech', startupinfo=startupinfo)
            if proc.wait():
                puts_err(colored.red("Cannot extract box"))
                sys.exit(1)
        else:
            tar = tarfile.open(box, 'r')
            tar.extractall('.mech')

        if not save and box.startswith(tempfile.gettempdir()):
            os.unlink(box)

    vmx = get_vmx()

    update_vmx(vmx)

    return vmx 
Example #6
Source File: action_pp.py    From angr-platforms with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def action_pp(state):
    actions = state.actions.hardcopy
    for a in actions:
        if isinstance(a, SimActionExit):
            print(blue("[%#08x] ===> %s %s" % (a.ins_addr, a.exit_type, a.target)))
        elif isinstance(a, SimActionData):
            print("[%#08x] %s %s: %s" % (a.ins_addr, a.action, str(a.tmp), a.data))
        elif isinstance(a, SimActionOperation):
            print(red("[%#08x] %s %s" % (a.ins_addr, a.op, ", ".join([str(e) for e in a.exprs])))) 
Example #7
Source File: cli.py    From blockade with Apache License 2.0 5 votes vote down vote up
def cmd_events(opts):
    """Get the event log for a given blockade
    """
    config = load_config(opts.config)
    b = get_blockade(config, opts)

    if opts.json:
        outf = None
        _write = puts
        if opts.output is not None:
            outf = open(opts.output, "w")
            _write = outf.write
        try:
            delim = ""
            logs = b.get_audit().read_logs(as_json=False)
            _write('{"events": [')
            _write(os.linesep)
            for l in logs:
                _write(delim + l)
                delim = "," + os.linesep
            _write(os.linesep)
            _write(']}')
        finally:
            if opts.output is not None:
                outf.close()
    else:
        puts(colored.blue(columns(["EVENT",         10],
                                  ["TARGET",        16],
                                  ["STATUS",         8],
                                  ["TIME",          16],
                                  ["MESSAGE",       25])))

        logs = b.get_audit().read_logs(as_json=True)
        for l in logs:
            puts(columns([l['event'],                          10],
                         [str([str(t) for t in l['targets']]), 16],
                         [l['status'],                          8],
                         [str(l['timestamp']),                 16],
                         [l['message'],                        25])) 
Example #8
Source File: cli.py    From blockade with Apache License 2.0 5 votes vote down vote up
def print_containers(containers, to_json=False):
    containers = sorted(containers, key=lambda c: c.name)

    if to_json:
        d = [c.to_dict() for c in containers]
        puts(json.dumps(d, indent=2, sort_keys=True, separators=(',', ': ')))

    else:
        puts(colored.blue(columns(["NODE",               15],
                                  ["CONTAINER ID",       15],
                                  ["STATUS",              7],
                                  ["IP",                 15],
                                  ["NETWORK",            10],
                                  ["PARTITION",          10])))

        def partition_label(c):
            if c.holy:
                return "H"
            elif c.partition:
                if c.neutral:
                    return str(c.partition) + " [N]"
                else:
                    return str(c.partition)
            elif c.neutral:
                return "N"
            else:
                return ""

        for container in containers:
            puts(columns([container.name,                15],
                         [container.container_id[:12],   15],
                         [container.status,               7],
                         [container.ip_address or "",    15],
                         [container.network_state,       10],
                         [partition_label(container),    10])) 
Example #9
Source File: genome.py    From VCF-kit with MIT License 5 votes vote down vote up
def download_genomes(genome_db):
    if os.path.isfile(genome_db):
        fileTime = os.path.getmtime(genome_db)
    else:
        fileTime = 0
    if (time() - fileTime) > (3 * 30 * 24 * 60 * 60) or is_non_zero_file(genome_db) is False:
        with indent(2):
            puts(colored.blue('\nDownloading list of reference genomes\n'))
        r = requests.get("http://ftp.ncbi.nlm.nih.gov/genomes/ASSEMBLY_REPORTS/assembly_summary_refseq.txt")
        genome_file = open(genome_db, "w")
        with genome_file as f:
            f.write(r.text.encode('utf-8').strip()) 
Example #10
Source File: __init__.py    From VCF-kit with MIT License 5 votes vote down vote up
def message(message, n_indent = 4, color = "blue"):
    with indent(n_indent):
        if color == "blue":
            puts_err(colored.blue('\n' + message + '\n'))
        elif color == "red":
            puts_err(colored.blue('\n' + message + '\n')) 
Example #11
Source File: utils.py    From mech with MIT License 5 votes vote down vote up
def add_box_file(name, version, filename, url=None, force=False, save=True):
    puts_err(colored.blue("Checking box '{}' integrity...".format(name)))

    if sys.platform == 'win32':
        cmd = tar_cmd('-tf', filename, '*.vmx', wildcards=True, fast_read=True, force_local=True)
    else:
        cmd = tar_cmd('-tf', filename, '*.vmx', wildcards=True, fast_read=True)
    if cmd:
        startupinfo = None
        if os.name == "nt":
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
        proc = subprocess.Popen(cmd, startupinfo=startupinfo)
        valid_tar = not proc.wait()
    else:
        tar = tarfile.open(filename, 'r')
        files = tar.getnames()
        valid_tar = False
        for i in files:
            if i.endswith('vmx'):
                valid_tar = True
                break
            if i.startswith('/') or i.startswith('..'):
                puts_err(colored.red(textwrap.fill(
                    "This box is comprised of filenames starting with '/' or '..' "
                    "Exiting for the safety of your files."
                )))
                sys.exit(1)

    if valid_tar:
        if save:
            boxname = os.path.basename(url if url else filename)
            box = os.path.join(*filter(None, (HOME, 'boxes', name, version, boxname)))
            path = os.path.dirname(box)
            makedirs(path)
            if not os.path.exists(box) or force:
                copyfile(filename, box)
        else:
            box = filename
        return name, version, box 
Example #12
Source File: mech.py    From mech with MIT License 5 votes vote down vote up
def reload(self, arguments):
        """
        Restarts Mech machine, loads new Mechfile configuration.

        Usage: mech reload [options] [<instance>]

        Options:
                --provision                  Enable provisioning
            -h, --help                       Print this help
        """
        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)

        puts_err(colored.blue("Reloading machine..."))
        started = vmrun.reset()
        if started is None:
            puts_err(colored.red("VM not restarted"))
        else:
            time.sleep(3)
            puts_err(colored.blue("Getting IP address..."))
            lookup = self.get("enable_ip_lookup", False)
            ip = vmrun.getGuestIPAddress(lookup=lookup)
            if ip:
                if started:
                    puts_err(colored.green("VM started on {}".format(ip)))
                else:
                    puts_err(colored.yellow("VM already was started on {}".format(ip)))
            else:
                if started:
                    puts_err(colored.green("VM started on an unknown IP address"))
                else:
                    puts_err(colored.yellow("VM already was started on an unknown IP address")) 
Example #13
Source File: error.py    From datacats with GNU Affero General Public License v3.0 5 votes vote down vote up
def pretty_print(self):
        """
        Print the error message to stdout with colors and borders
        """
        print colored.blue("-" * 40)
        print colored.red("datacats: problem was encountered:")
        print self.message
        print colored.blue("-" * 40) 
Example #14
Source File: error.py    From datacats with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, message, parent_exception=None):
        self.message = message
        if parent_exception and hasattr(parent_exception, 'user_description'):
            vals = {
                "original": self.message,
                "type_description": parent_exception.user_description,
                "message": str(parent_exception),
            }
            self.message = "".join([str(colored.blue("{original}\n\n")),
                                    "-" * 30,
                                    "\n{type_description}:\n",
                                    str(colored.yellow("{message}\n"))]
                                    ).format(**vals)

        super(DatacatsError, self).__init__(message) 
Example #15
Source File: utils.py    From mech with MIT License 4 votes vote down vote up
def build_mechfile(descriptor, name=None, version=None, requests_kwargs={}):
    mechfile = {}
    if descriptor is None:
        return mechfile
    if any(descriptor.startswith(s) for s in ('https://', 'http://', 'ftp://')):
        mechfile['url'] = descriptor
        if not name:
            name = os.path.splitext(os.path.basename(descriptor))[0]
        mechfile['box'] = name
        if version:
            mechfile['box_version'] = version
        return mechfile
    elif descriptor.startswith('file:') or os.path.isfile(re.sub(r'^file:(?://)?', '', descriptor)):
        descriptor = re.sub(r'^file:(?://)?', '', descriptor)
        try:
            with open(descriptor) as fp:
                catalog = json.loads(uncomment(fp.read()))
        except Exception:
            mechfile['file'] = descriptor
            if not name:
                name = os.path.splitext(os.path.basename(descriptor))[0]
            mechfile['box'] = name
            if version:
                mechfile['box_version'] = version
            return mechfile
    else:
        try:
            account, box, v = (descriptor.split(os.path.sep, 2) + ['', ''])[:3]
            if not account or not box:
                puts_err(colored.red("Provided box name is not valid"))
            if v:
                version = v
            puts_err(colored.blue("Loading metadata for box '{}'{}".format(descriptor, " ({})".format(version) if version else "")))
            url = 'https://app.vagrantup.com/{}/boxes/{}'.format(account, box)
            r = requests.get(url, **requests_kwargs)
            r.raise_for_status()
            catalog = r.json()
        except (requests.HTTPError, ValueError) as exc:
            puts_err(colored.red("Bad response from HashiCorp's Vagrant Cloud API: %s" % exc))
            sys.exit(1)
        except requests.ConnectionError:
            puts_err(colored.red("Couldn't connect to HashiCorp's Vagrant Cloud API"))
            sys.exit(1)
    return catalog_to_mechfile(catalog, name, version) 
Example #16
Source File: utils.py    From mech with MIT License 4 votes vote down vote up
def provision_shell(vm, inline, path, args=[]):
    tmp_path = vm.createTempfileInGuest()
    if tmp_path is None:
        return

    try:
        if path and os.path.isfile(path):
            puts_err(colored.blue("Configuring script {}...".format(path)))
            if vm.copyFileFromHostToGuest(path, tmp_path) is None:
                return
        else:
            if path:
                if any(path.startswith(s) for s in ('https://', 'http://', 'ftp://')):
                    puts_err(colored.blue("Downloading {}...".format(path)))
                    try:
                        r = requests.get(path)
                        r.raise_for_status()
                        inline = r.read()
                    except requests.HTTPError:
                        return
                    except requests.ConnectionError:
                        return
                else:
                    puts_err(colored.red("Cannot open {}".format(path)))
                    return

            if not inline:
                puts_err(colored.red("No script to execute"))
                return

            puts_err(colored.blue("Configuring script..."))
            fp = tempfile.NamedTemporaryFile(delete=False)
            try:
                fp.write(inline)
                fp.close()
                if vm.copyFileFromHostToGuest(fp.name, tmp_path) is None:
                    return
            finally:
                os.unlink(fp.name)

        puts_err(colored.blue("Configuring environment..."))
        if vm.runScriptInGuest('/bin/sh', "chmod +x '{}'".format(tmp_path)) is None:
            return

        puts_err(colored.blue("Executing program..."))
        return vm.runProgramInGuest(tmp_path, args)

    finally:
        vm.deleteFileInGuest(tmp_path, quiet=True) 
Example #17
Source File: mech.py    From mech with MIT License 4 votes vote down vote up
def resume(self, arguments):
        """
        Resume a paused/suspended Mech machine.

        Usage: mech resume [options] [<instance>]

        Options:
                --provision                  Enable provisioning
            -h, --help                       Print this help
        """
        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        utils.index_active_instance(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)

        # Try to unpause
        if vmrun.unpause(quiet=True) is not None:
            time.sleep(1)
            puts_err(colored.blue("Getting IP address..."))
            lookup = self.get("enable_ip_lookup", False)
            ip = vmrun.getGuestIPAddress(lookup=lookup)
            if ip:
                puts_err(colored.green("VM resumed on {}".format(ip)))
            else:
                puts_err(colored.green("VM resumed on an unknown IP address"))

        # Otherwise try starting
        else:
            started = vmrun.start()
            if started is None:
                puts_err(colored.red("VM not started"))
            else:
                time.sleep(3)
                puts_err(colored.blue("Getting IP address..."))
                lookup = self.get("enable_ip_lookup", False)
                ip = vmrun.getGuestIPAddress(lookup=lookup)
                puts_err(colored.blue("Sharing current folder..."))
                vmrun.enableSharedFolders()
                vmrun.addSharedFolder('mech', os.getcwd(), quiet=True)
                if ip:
                    if started:
                        puts_err(colored.green("VM started on {}".format(ip)))
                    else:
                        puts_err(colored.yellow("VM already was started on {}".format(ip)))
                else:
                    if started:
                        puts_err(colored.green("VM started on an unknown IP address"))
                    else:
                        puts_err(colored.yellow("VM already was started on an unknown IP address")) 
Example #18
Source File: vk.py    From VCF-kit with MIT License 4 votes vote down vote up
def main():
    args = docopt(__doc__,
                  argv=debug,
                  options_first=True,
                  version=__version__)
    argv = [args['<command>']] + args['<args>']
    program_list = {"bwa": "bwa",
                    "samtools": "samtools",
                    "bcftools": "bcftools",
                    "blast": "blastn",
                    "muscle": "muscle"}
    if args["<command>"] == "setup":
        """
            Use Homebrew to install programs!
        """
        program_installed = program_list.keys()
        for install_name, program in program_list.items():
            check_output(["brew", "tap", "homebrew/science"])
            try:
                with indent(4):
                    puts(colored.blue("Installing " + install_name))
                check_output(["brew", "install", install_name])
                program_installed.remove(install_name)
            except CalledProcessError:
                try:
                    check_output(["which", program])
                    with indent(4):
                        puts(colored.blue(program + " previously installed"))
                    program_installed.remove(install_name)
                except CalledProcessError:
                    with indent(4):
                        puts(colored.red("Error installing " + install_name))
        if len(program_installed) == 0:
            with indent(4):
                puts(colored.blue("Programs successfully installed!"))
        else:
            with indent(4):
                puts(colored.red("Error: Not all programs successfully installed: " + ", ".join(program_installed)))
    elif args["<command>"] == "":
        print(__doc__)
        for prog in program_list.values():
            try:
                check_output(["which", prog])
            except CalledProcessError:
                with indent(4):
                    puts(
                        colored.red(prog + " not installed. Use a package manager to install or try using 'vk setup'\n"))
    elif args['<command>'] in command_list:
        comm = ['python', getScriptPath() + '/' + args["<command>"] + ".py"] + argv
        exit(call(comm))
    else:
        levs = [(x, lev(args['<command>'], x)) for x in command_list]
        closest =  min(levs, key = lambda x: x[1])[0]
        command = args['<command>']
        message("There is no command '{command}'. Did you mean 'vk {closest}'?".format(**locals())) 
Example #19
Source File: bcwallet.py    From bcwallet with Apache License 2.0 4 votes vote down vote up
def display_balance_info(wallet_obj, verbose=False):
    if not USER_ONLINE:
        return

    mpub = wallet_obj.serialize_b58(private=False)

    wallet_name = get_blockcypher_walletname_from_mpub(
            mpub=mpub,
            subchain_indices=[0, 1],
            )

    verbose_print('Wallet Name: %s' % wallet_name)
    verbose_print('API Key: %s' % BLOCKCYPHER_API_KEY)

    coin_symbol = coin_symbol_from_mkey(mpub)

    wallet_details = get_wallet_balance(
            wallet_name=wallet_name,
            api_key=BLOCKCYPHER_API_KEY,
            coin_symbol=coin_symbol,
            )
    verbose_print(wallet_details)

    puts('-' * 70 + '\n')
    balance_str = 'Balance: %s' % (
            format_crypto_units(
                input_quantity=wallet_details['final_balance'],
                input_type='satoshi',
                output_type=UNIT_CHOICE,
                coin_symbol=coin_symbol,
                print_cs=True,
            ))
    puts(colored.green(balance_str))
    if wallet_details['unconfirmed_balance']:
        balance_str += ' (%s%s of this is unconfirmed)' % (
                '+' if wallet_details['unconfirmed_balance'] else '',  # hack
                format_crypto_units(
                    input_quantity=wallet_details['unconfirmed_balance'],
                    input_type='satoshi',
                    output_type=UNIT_CHOICE,
                    print_cs=True,
                    coin_symbol=coin_symbol,
                ),
                )

    tx_string = 'Transactions: %s' % wallet_details['final_n_tx']
    if wallet_details['unconfirmed_n_tx']:
        tx_string += ' (%s unconfirmed)' % wallet_details['unconfirmed_n_tx']
    puts(colored.green(tx_string + '\n'))

    puts('More info:')
    puts(colored.blue(get_public_wallet_url(mpub)))
    puts()

    return wallet_details['final_balance'] 
Example #20
Source File: mech.py    From mech with MIT License 4 votes vote down vote up
def up(self, arguments):
        """
        Starts and provisions the mech environment.

        Usage: mech up [options] [<instance>]

        Options:
                --gui                        Start GUI
                --provision                  Enable provisioning
                --insecure                   Do not validate SSL certificates
                --cacert FILE                CA certificate for SSL download
                --capath DIR                 CA certificate directory for SSL download
                --cert FILE                  A client SSL cert, if needed
                --checksum CHECKSUM          Checksum for the box
                --checksum-type TYPE         Checksum type (md5, sha1, sha256)
                --no-cache                   Do not save the downloaded box
            -h, --help                       Print this help
        """
        gui = arguments['--gui']
        save = not arguments['--no-cache']
        requests_kwargs = utils.get_requests_kwargs(arguments)

        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        utils.index_active_instance(instance_name)

        vmx = utils.init_box(self.box_name, self.box_version, requests_kwargs=requests_kwargs, save=save)
        vmrun = VMrun(vmx, user=self.user, password=self.password)
        puts_err(colored.blue("Bringing machine up..."))
        started = vmrun.start(gui=gui)
        if started is None:
            puts_err(colored.red("VM not started"))
        else:
            time.sleep(3)
            puts_err(colored.blue("Getting IP address..."))
            lookup = self.get("enable_ip_lookup", False)
            ip = vmrun.getGuestIPAddress(lookup=lookup)
            puts_err(colored.blue("Sharing current folder..."))
            vmrun.enableSharedFolders()
            vmrun.addSharedFolder('mech', os.getcwd(), quiet=True)
            if ip:
                if started:
                    puts_err(colored.green("VM started on {}".format(ip)))
                else:
                    puts_err(colored.yellow("VM was already started on {}".format(ip)))
            else:
                if started:
                    puts_err(colored.green("VM started on an unknown IP address"))
                else:
                    puts_err(colored.yellow("VM was already started on an unknown IP address")) 
Example #21
Source File: __init__.py    From s3tk with MIT License 4 votes vote down vote up
def encrypt_object(bucket_name, key, dry_run, kms_key_id, customer_key):
    obj = s3().Object(bucket_name, key)
    str_key = unicode_key(key)

    try:
        if customer_key:
            obj.load(SSECustomerAlgorithm='AES256', SSECustomerKey=customer_key)

        encrypted = None
        if customer_key:
            encrypted = obj.sse_customer_algorithm is not None
        elif kms_key_id:
            encrypted = obj.server_side_encryption == 'aws:kms'
        else:
            encrypted = obj.server_side_encryption == 'AES256'

        if encrypted:
            puts(str_key + ' ' + colored.green('already encrypted'))
            return 'already encrypted'
        else:
            if dry_run:
                puts(str_key + ' ' + colored.yellow('to be encrypted'))
                return 'to be encrypted'
            else:
                copy_source = {'Bucket': bucket_name, 'Key': obj.key}

                # TODO support going from customer encryption to other forms
                if kms_key_id:
                    obj.copy_from(
                        CopySource=copy_source,
                        ServerSideEncryption='aws:kms',
                        SSEKMSKeyId=kms_key_id
                    )
                elif customer_key:
                    obj.copy_from(
                        CopySource=copy_source,
                        SSECustomerAlgorithm='AES256',
                        SSECustomerKey=customer_key
                    )
                else:
                    obj.copy_from(
                        CopySource=copy_source,
                        ServerSideEncryption='AES256'
                    )

                puts(str_key + ' ' + colored.blue('just encrypted'))
                return 'just encrypted'

    except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e:
        puts(str_key + ' ' + colored.red(str(e)))
        return 'error'