Python Developer Setup

Instructions for installation of Python-based Commander with the intent on modifying source code

Installation

To develop or test Keeper Commander from source, use a Python virtual environment to isolate dependencies.

Clone the Commander Repository

Clone the GitHub repository to your local machine: https://github.com/Keeper-Security/Commander

git clone https://github.com/Keeper-Security/Commander
cd Commander

The "master" branch will mirror the production release. The "release" branch references the upcoming release. To optionally switch to the release branch:

git checkout release

Install Python

Install the most recent Python3 installation from python.org.

Install Virtualenv

sudo pip3 install virtualenv

Create and Activate Virtual Environment

virtualenv -p python3 venv
source venv/bin/activate

Install Dependencies and Set Up in Dev Mode

pip install -r requirements.txt
pip install -e .

Setup Complete

You can now launch the Commander CLI:

keeper shell

See the Logging in section to understand the authentication process. Explore all of the Commands available.


Sample Python Code

To run bash-formatted CLI commands directly from a python script, you can import the cli package from the keepercommander library and run its do_command function:

from keepercommander.__main__ import get_params_from_config
from keepercommander import cli

my_params = get_params_from_config("{{path_to_config_file}}")

cli.do_command(my_params, "{{cli_command}}")

In the above example, authentication is handled with the get_params_from_config function, which is pointing to your config.json file. See Building a Persistent Login Config for more information on how to build this configuration file.

Alternatively, you can leverage the full scope of the Commander SDK by using its internal classes and functions. Several standalone python scripts can be found here, with examples for searching records, creating teams and sharing folders, and more.

Last updated

Was this helpful?