The JIP command line package contains utilities and the modules that expose command line functions for the JIP command. The module hosts a set of utility functions that can be used to simplify the process of interacting with the JIP API from within a command line tool.
Functions in this module might have certain limitations when you want to use them as general API calls. Most of the output generation functions print to stdout and this can not be changed. In addition, be very careful the dry(), it calles sys.exit(1) in case of a failure.
Warning
Both run() and dry() call sys.exit(1) in case of a failure! Be very careful when you want to call them outside of a command line tool that is allowed terminate!
Note
Please note that you can use the module to implement custom command line utilities, but it was written to support the commands that are shipped with JIP. That means the modules functions might change according to the needs of the internal command line utilities.
Maps job states to colors
Colorize a string using ANSI colors.
The jip.cli module contains a few ANSI color definitions that are used quiet often in the system.
Parameters: |
|
---|
Print the message and ask the user to confirm. Return True if the user confirmed with Y.
Parameters: |
|
---|
Create a table.
Parameters: |
|
---|---|
Returns: | Texttable table instance |
Load the script and initialize it with the given arguments, then perform a dry run and print the options and commands
Warning
This method calls sys.exit(1) in case an Exception is raised
Parameters: |
|
---|
Parse the command line options
Parameters: |
|
---|---|
Returns: | parsed options as dictionary |
Resolves job and clsuter ids specified in the args –job and –cluster-job options. In additon, this reads job ids from stdin.
Parameters: | args – parsed command line options |
---|---|
Returns: | tuple of job ids and cluster ids |
Read job ids from a stream
Create a simple ASCII table and returns its string representation.
Parameters: |
|
---|---|
Returns: | string representation of the table |
Resolve ranges from a list of ids. Given list of id strings can contain ranges separated with ‘-‘. For example, ‘1-10’ will result in a range from 1..10.
Parameters: | ids (string or list of strings) – string or list of strings of ids |
---|---|
Returns: | resolved list of ids |
Return type: | list of integers |
Raises ValueError: | |
if on of the ids could not be converted to a valid, positive id |
Print the commands for the given list of jobs
Parameters: | jobs (list of jip.db.Job) – list of jobs |
---|
Print the dry-run table to stdout
Parameters: |
|
---|
Print the job profile for a given list of jobs.
The job profile contains the following properties:
Parameters: |
|
---|
Print the job states table for a list of jobs.
Parameters: |
|
---|
Prints the job hierarchy as a tree structure
Parameters: |
|
---|
Print the options to a table
Parameters: |
|
---|
Translates the given value to a string that can be rendered in a table. This functions deals primarily with datatime.datetime and datetime.timedelta values. For all other types, the default string representation is returned.
Parameters: |
|
---|---|
Returns: | table compatible string representation |
Return type: | string |