Package: crux
Crux Python ClientA Python library for interacting with the Crux platform.The aim of this module is to be a Pythonic way to use the Crux API reliably. It covers client functionality including scanning subscriptions, getting delivery status, and downloading files.Python 3.6+ is supported.Seecrux-python.cruxinformatics.comfor detailed documentation.InstallationInstall a recent version of Python, and a Python dependency and virtual environment manager likepipenv. On macOS run:brewinstallpython
brewinstallpipenvInstallcruxfrom PyPIin a virtual environment, and get a shell in that environment:mkdir-pcrux_examplecdcrux_example
pipenvinstall"crux==1.3"pipenvshellGetting StartedCreate a file, like example.py, and use thecruxmodule:fromcruximportCruxconn=Crux()identity=conn.whoami()print("I am",identity.email)Run the script:HISTCONTROL=ignorebothexportCRUX_API_KEY='YOUR_API_KEY'python3example.pySee theinstallationandauthenticationdocumentation for details.DevelopmentPython 3.7 is required for development, which can be installed withbrew install python. For heavy development work, every supported version of Python must be installed, see the pyenv documentation below.Pipenvshould be used to manage dependancies during development.Install Pipenv, on macOS runbrew install pipenvgit clone https://github.com/cruxinformatics/crux-python.gitcd crux-pythonpipenv install --devto install the dependanciespipenv shellto get a shell in the virtual environmentMultiple Python versionsTo be able to run tests against all supported Python versions, you must have all supported Python versions installed. The test runner will look for binaries calledpython2.7,python3.5,python3.6, etc. There are multiple ways to install Python versions, we'll document usingpyenv.brew install pyenvto installPuteval "$(pyenv init -)"towards the end of the shell configuration file (~/.bashrc or ~/.bash_profile), because it manipulates$PATH, for example:echo-e'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi'>>~/.bashrcOpen a new Terminal to get an updated shellInstall required/missing Python versions (this assumes you have Python 2.7 already installed, otherwise install it too):pyenvinstall3.5.6
pyenvinstall3.6.6
pyenvinstall3.7.0pyenv global system 3.5.6 3.6.6 3.7.0to make all the Python versions availableIf you already have pipenv virtual environment, remove it withpipenv --rmso it detects the Python versionspipenv install --devto install all the dependanciespipenv shellto get a shell in the virtual environmentRunning testsWe useNoxto automate running tests, and usemaketo automate running some commands. These commands should be run within a shell created withpipenv shell.# Run all tests: lint, unit, format_checkmaketest# Ornox# Run only lint checksmakelint# Ornox-slint# Run unit tests against all available Python versionsmakeunit# Ornox-sunit# Run integration tests agains all available Python versionsexportCRUX_API_KEY="12345"exportCRUX_API_HOST="https://api.example.com"makeintegration# OrexportCRUX_API_KEY="12345"exportCRUX_API_HOST="https://api.example.com"nox--sintegration# Check formattingmakeformat_check# Ornox-sformat_check# List all commands availablemake# Ornox-l# Run unit test only against Python 3.7nox-sunit-3.7# Reformat codemakeformat# Generate Sphinx HTML documentationmakedocsRunning test scriptsManual testing scripts could be found attests/regression.
In order to run one, i.e.client.py, follow the steps:copy corresponding.env.distfile as.envfile (if you plan to runclient.py, copyclient.env.distasclient.env)fill variables within.envfilelaunch the script (while being in thetests/regressionfolder, executepython client.py)