Skip to content

Latest commit

 

History

History
396 lines (319 loc) · 16.3 KB

index.md

File metadata and controls

396 lines (319 loc) · 16.3 KB

About

Table of contents

Introduction

Memsource CLI is a framework to help with automation of Memsource related tasks. This empowers you to automate repetitive tasks such as project, job creation, analysis runs and others. The framework is cabable to talk to Memsource API using REST client and show you the results of the execution on the screen.

Please if you have any idea on any improvements please do not hesitate to open an issue.

Releases

Highlights

  • Extensions are written in Python
  • Allows you to use formatter -f to choose one of many different formats: csv,json,table,value,yaml
  • You can sort by any individual columns or multiple columns using --sort-column
  • Specify the columns that you are interested in using -c

Framework will download additional packages:

  • cliff
  • certifi>=2017.4.17
  • python-dateutil>=2.1
  • six>=1.10
  • urllib3>=1.23

What's new

Version 0.3.6

Added new feature such as

Version 0.3.4

Added new features such as

Version 0.3.3

Fixed #20 [BUG] memsource job create --debug displays empty output
Fixed #23 [BUG] memsource job download didn't display help

Version 0.3.2

[0.3.2] Fixed user.py syntax error for python2

Version 0.3.1

Fixed #19 [BUG] List users
Fixed #12 [BUG] Assign jobs to poviders
Fixed #15 [BUG] 'charmap' error on bilingual download
[0.3.1] Add new command 'memsource use list'
[0.3.1] Add new command 'memsource job edit'
[0.3.1] memsource job download can work on multiple job_uids
[0.3.1] force directory creation with --output-dir on job download
[0.3.1] Add Memsource custom base url

Added new features such as

Option to use custom URL:

  --ms-auth-url <auth-url>
                        Authentication URL (Env: MEMSOURCE_URL)

or add to your memsourcerc file:

export MEMSOURCE_URL="https://cloud.memsource.com/web"

Version 0.3

[0.3] Adding feature project template list
[0.3] Move memsource project template create to project create --template-id

Version 0.2.10

[0.2.10] Adding feature template show

Added new features such as

Version 0.2.9

[0.2.9] Adding feature job translations delete all
[0.2.9] Job download renamed
[0.2.9] Add Translation pre-translate option
[0.2.9] Customized output directory for file downloads
[0.2.9] Fix to datetime JSON serialization
[0.2.9] Minor fix: invalid JSON in references in memsource project list

Added features such as

Version 0.2.8

Fixed #6 [BUG] A CLI returns invalid JSON with single-quotes bug low triaged

Version 0.2.6 contains features such as:

Version 0.2.5 contains features such as:

For more information see CHANGELOG.md

How does it looks like?

Check how does it look in an execution at: asciicast

Collaborate

Usage

$ memsource --help
usage: memsource [--version] [-v | -q] [--log-file LOG_FILE] [-h] [--debug]
                 [--ms-username <auth-username>]
                 [--ms-password <auth-password>] [--ms-token <auth-token>]
                 [--ms-auth-url <auth-url>]

Unofficial Memsource CLI client

optional arguments:
  --version             show program's version number and exit
  -v, --verbose         Increase verbosity of output. Can be repeated.
  -q, --quiet           Suppress output except warnings and errors.
  --log-file LOG_FILE   Specify a file to log output. Disabled by default.
  -h, --help            Show help message and exit.
  --debug               Show tracebacks on errors.
  --ms-username <auth-username>
                        Authentication username (Env: MEMSOURCE_USERNAME)
  --ms-password <auth-password>
                        Authentication password (Env: MEMSOURCE_PASSWORD)
  --ms-token <auth-token>
                        Authentication token (Env: MEMSOURCE_TOKEN)
  --ms-auth-url <auth-url>
                        Authentication URL (Env: MEMSOURCE_URL)

Commands:
  analyse create  Create analysis
  analyse delete  Delete analysis
  analyse language create  Create analyses by languages
  analyse project list  List analyses by project
  analyse show   Get Analysis
  auth login     Login
  auth whoami    Who am I
  complete       print bash completion command (cliff)
  help           print detailed help for another command (cliff)
  job create     Creates job in project
  job delete     Delete jobs
  job download   Download job file
  job edit       Edit job
  job list       List jobs in project
  job show       Get job
  job translations delete  Delete translations
  project create  Create new project
  project delete  Deletes a project
  project list   List projects
  project show   Get project
  template list  List templates
  template show  Show template
  translation pre-translate  Pre-translate job
  user create    Create user
  user get       Get user
  user list      List users

Getting Started

Requirements for python2 environments:

  • package python-virtualenv

Install from PyPI

DIRECTORY="${HOME}/git/memsource-cli-client/"
if [[ ! -d ${DIRECTORY} ]]; then
  mkdir -p ${DIRECTORY}
fi
cd $DIRECTORY

if [[ -f $(which python3) ]];
then
  python3 -m venv --system-site-packages .memsource
else
  if [[ ! -f $(which virtualenv) ]];
  then
    sudo yum -y install python-virtualenv
  fi
  virtualenv --system-site-packages .memsource
fi

source .memsource/bin/activate
pip install -U pip
pip install -U setuptools
pip install memsource-cli

clear
memsource --help

Install from Github

DIRECTORY="$HOME/git/"

if [[ ! -d ${DIRECTORY} ]]; then
  mkdir ${DIRECTORY}
fi
cd ${DIRECTORY}
if [[ ! -d ${DIRECTORY}/memsource-cli-client ]]; then
  git clone https://github.com/unofficial-memsource/memsource-cli-client.git
  cd memsource-cli-client/
  if [[ -f $(which python3) ]];
  then
    python3 -m venv --system-site-packages .memsource
  else
    if [[ ! -f $(which virtualenv) ]];
    then
      sudo yum -y install python-virtualenv
    fi
    virtualenv --system-site-packages .memsource
    for py in $(find memsource_cli -name "*.py"); do sed -i -e 's#/usr/bin/env python3#/usr/bin/env python#' $py; done
  fi
  source .memsource/bin/activate
  pip install -U pip
  pip install -U setuptools
  pip install -e .
  deactivate
else
  cd memsource-cli-client/
  rm -Rf .memsource
  if [[ -f $(which python3) ]];
  then
    python3 -m venv --system-site-packages .memsource
  else
    if [[ ! -f $(which virtualenv) ]];
    then
      sudo yum -y install python-virtualenv
    fi
    virtualenv --system-site-packages .memsource
    for py in $(find memsource_cli -name "*.py"); do sed -i -e 's#/usr/bin/env python3#/usr/bin/env python#' $py; done
  fi
  source .memsource/bin/activate
  git checkout master
  git reset --hard
  git pull
  if [[ ! -f $(which python3) ]];
  then
    for py in $(find memsource_cli -name "*.py"); do sed -i -e 's#/usr/bin/env python3#/usr/bin/env python#' $py; done
  fi
  source .memsource/bin/activate
  pip install -e .
  deactivate
fi
source ${DIRECTORY}/memsource-cli-client/.memsource/bin/activate
clear
memsource --help

And that's it!

Configuration

This way you can configure your username/password and set up memsource token for faster authentication:

source ${HOME}/git/memsource-cli-client/.memsource/bin/activate
export MEMSOURCE_URL="https://cloud.memsource.com/web"
export MEMSOURCE_USERNAME=<username>
export MEMSOURCE_PASSWORD=<password>
export MEMSOURCE_TOKEN=$(memsource auth login --user-name $MEMSOURCE_USERNAME --password "${MEMSOURCE_PASSWORD}" -c token -f value)

Or you can create a file:

Edit file with vi ~/.memsourcerc and paste following content:

source ${HOME}/git/memsource-cli-client/.memsource/bin/activate
export MEMSOURCE_URL="https://cloud.memsource.com/web"
export MEMSOURCE_USERNAME=<username>
export MEMSOURCE_PASSWORD=<password>
export MEMSOURCE_TOKEN=$(memsource auth login --user-name $MEMSOURCE_USERNAME --password "${MEMSOURCE_PASSWORD}" -c token -f value)

Then only source that file to start using memsource-cli:

source ~/.memsourcerc

Requirements:

  • jq

Autocompletion

To add autocompletion to your shell so you can type:

mem[tab] pr[tab] cr[tab] which will translate to:

memsource project create

memsource complete | sudo tee /etc/bash_completion.d/memsource > /dev/null
. /etc/bash_completion.d/memsource

Now you should be fine to use memsource

Contact us!

This project is maintained on Github.

Code Status

GitHub Coverage Status Build Status PyPI version GitHub release (latest by date) Unofficial Memsource CLI Telegram Group Google group : Unofficial Memsource CLI Forum Quality Gate Status Codacy Badge