Welcome    Usage    Browse    Find CID    Search     Log in

cM API Documentation

cm Namespace Reference

Functions

def init
def is_windows
def load_data
def load_module
def load_code
def gen_uid
def is_uid
def cid2array
def web_print_array_for_debug
def find_path_to_entry
def create_entry
def check_global_writing
def delete_entry
def delete_alias
def substitute_str_in_file
def create_data_entry
def create_default_array_from_description
def convert_file_to_upload_string
def get_current_date_time
def convert_iso_time_to_str
def find_index_in_array
def find_path_to_current_repository
def find_path_to_work_repositories
def load_json_file
def save_array_to_file_as_json
def load_array_from_file
def save_flat_array_to_file
def flatten_array
def flatten_array_internal
def get_value_by_flattened_key
def set_value_by_flattened_key
def replace_from_dict
def restore_flattened_array
def delete_directory
def convert_string_to_html
def flatten_classification
def set_print_mode
def print_for_web
def print_for_con
def get_all_uoa
def get_list_of_all_files
def get_data_description
def system
def gen_cm_tmp_file
def array2cm
def convert_text_to_value
def find_keys_by_prefix
def merge_arrays_ll
def merge_arrays
def str2cm
def array2str
def get_var
def prepare_final_out
def check_cm_json
def convert_cm_array_to_uri
def copy_vars
def convert_str_to_special
def get_cm_version
def convert_str_to_sha1
def prepare_cid
def access_control
def auth_user
def auth_user_and_ini_cm
def access_fe_as_string
def access_fe_through_cmd
def access_fe_from_cmd
def access_fe
def remote_access
def access

Variables

string env_cm_root = 'CM_ROOT'
string env_cm_bin = 'CM_BIN'
string env_cm_tmp = 'CM_TMP'
string env_cm_cfg = 'CM_DEFAULT_CFG'
string env_cm_cfg_path = 'CM_DEFAULT_CFG_PATH'
string env_cm_default_repo = 'CM_DEFAULT_REPO'
string env_cm_local_repo = 'CM_LOCAL_REPO'
string env_cm_user_uoa = 'CM_USER_UOA'
string env_cm_user_password = 'CM_USER_PASSWORD'
string env_cm_user_password1 = 'CM_USER_PASSWORD1'
string env_cm_remote_repo_proxy_http = 'CM_REMOTE_REPO_PROXY_HTTP'
string env_cm_remote_repo_proxy_https = 'CM_REMOTE_REPO_PROXY_HTTPS'
string var_cm_info = '.cm'
string var_cm_data = 'data.json'
string var_cm_cfg_local = 'local'
string var_cm_cfg_default = 'default'
string cm_module_default = 'core'
string cm_module_default_access = 'access'
string cm_action_default = 'default'
string cm_unparsed_sep = '--'
string cm_json_with_text_sep = '*** ### --- CM JSON SEPARATOR --- ### ***'
dictionary ini
 cm_kernel = None
 print_on = True
tuple r = access_fe_from_cmd(sys.argv[1:])

Function Documentation

def cm::access (   i  ) 
Single entry point to access all cM functions.

Input:  {
          Set of global cM variables:

            cm_run_module_uoa - UOA of the module to run
            cm_action         - module action (function)

            (cm_console)       - by default, do not output anything except errors
                                 if 'txt' then output as plain text
                                 if 'web' then output for web (html, image, etc)
                                 if 'json' then output as json

            cm_web            - if 'yes', function was called from web environment
            cm_web_preprocess - if 'yes', we in the preprocessing stage in the web environment,
                                where we can still change the http headers, etc ...

            If cM Web access or fully remote access:
            cm_user_uoa       - user UOA

                                If requires user authentication in web environment!
                                After authentication, passwords will be removed from the array

            cm_user_password  - user password in plain text 
                                (not secure, usually used for web form authentication)
            cm_user_password1 - user password in SHA1
                                (more secure, can be stored in environment, session or cookies)
                                 cM authenicates by taking SHA1(cm_user_password1)...

            If access to remote repository or fully remote access:

            cm_remote_user_uoa      - remote user UOA
            cm_remote_user_password - remote user password

          Set of parameters depending on the called module and action (function)
        }

Output: {
          cm_return  - return code = 0 if successful
                                  > 0 if error
                                  < 0 if warning (rarely used at this moment)
          (cm_error) - error text, if cm_return > 0

          Set of output parameters depending on the called module and action (function)
        }

Definition at line 3647 of file cm.py.

def cm::access_control (   i  ) 
Control access 

Input:  {
          dcfg                    - cfg of the current entry
          module_uoa              - module UOA of the entry
          module_uid              - module UID of the entry
          data_uoa                - data UOA of the entry
          key                     - 'read' or 'write'
        }

Output: {
          cm_return - 0, if Ok; ==32 if access denied
          cm_error  - if access is denied
        }

Definition at line 2903 of file cm.py.

def cm::access_fe (   i  ) 
Front-end to single entry 'access' function
cM will be initialized if needed

Input:  See "access" function
Output: See "access" function

Definition at line 3426 of file cm.py.

def cm::access_fe_as_string (   s  ) 
Front-end to single entry 'access' function as string (if someone finds it easier).

Input:  string that will be converted to array (See "access" function).
Output: See "access" function.

Definition at line 3231 of file cm.py.

def cm::access_fe_from_cmd (   a  ) 
Front-end to single entry 'access' function from command line (bash, windows shell, etc)
If cm_console=='', it will be set to 'txt'
If cm_user_uoa and cm_user_password1 are not in input but in environment, they will be also used

Input:  cmd list that will be converted to array (See "access" function)
Output: See "access" function

Definition at line 3393 of file cm.py.

def cm::access_fe_through_cmd (   i  ) 
FGG TBD: Currently used only in cM web server.
         Should be cleaned and updated!
         Should check that tmp files are deleted!

Main function to access cM through a command line (useful for web server, etc).

Input:  {
           ...                 - see "access" function from this module
           (cm_detach_console) - if 'yes', detach console (for installations or experiments)
        }
Output: {
          cm_return - return code = 0 if successful
          cm_stdout - stdout 
          cm_stderr - stderr
        }

Definition at line 3245 of file cm.py.

def cm::array2cm (   a  ) 
Convert list to cm array

cm_module_uoa cm_action A=B C=D ... @file1.json E=F ... -- <unparsed arguments>

if extension of @file is .tmp, it will be deleted after read!

Input:  input array

Output: {
          cm_return  - return code = 0 if successful
          cm_array   - array
          cm_console - if 'cm_console' in array, set it to the value of 'cm_console' parameter
        }

Definition at line 2339 of file cm.py.

def cm::array2str (   i  ) 
Convert array to string with space

Input:  array

Output: {
          cm_return - 0
          cm_string - string
        }

Definition at line 2562 of file cm.py.

def cm::auth_user (   i  ) 
Authenticate user

Input:  {
          cm_user_uoa       - user UOA
          cm_user_password  - user password in plain text 
                              (not secure, usually used for web form authentication)
          cm_user_password1 - user password in SHA1
                              (more secure, can be stored in environment, session or cookies)
                              cM authenicates by taking SHA1(cm_user_password1)...
          cm_user_password2 - only should be set here by web environment!
        }   

Output: {
          cm_return            - return code = 0 if authenticated
          (cm_error)           - error text, if cm_return > 0
          cm_user_cfg          - user config if authenticated (to check groups, etc)
          cm_user_password2    - user password in SHA1(SHA1)
          cm_user_uid          - user UID
          cm_user_uoa          - user UOA
          cm_user_alias        - user alias
          cm_user_path         - user path
        }

Definition at line 2977 of file cm.py.

def cm::auth_user_and_ini_cm (   i  ) 
Check if need to auth user, try to auth and set cM vars

Input:  {
          cm_user_uoa       - user UOA
          cm_user_password  - user password in plain text 
                              (not secure, usually used for web form authentication)
          cm_user_password1 - user password in SHA1
                              (more secure, can be stored in environment, session or cookies)
                              cM authenicates by taking SHA1(cm_user_password1)...
          cm_user_password2 - only should be set here by web environment!
        }   

Output: {
          cm_return            - return code = 0 if authenticated
          (cm_error)           - error text, if cm_return > 0

           If needed to auth or default user:
          cm_user_cfg          - user config if authenticated (to check groups, etc)
          cm_user_password1    - user password in SHA1
          cm_user_uid          - user UID
          cm_user_uoa          - user UOA
          cm_user_alias        - user alias
          cm_user_path         - user path
          cm_user_status       - 'no_user', 'default', 'logged_in' or 'failed'
        }

Definition at line 3078 of file cm.py.

def cm::check_cm_json (   i  ) 
Check if 'cm_json' exist in array and decode it

Input:  {
          cm_json - array to check
        } 

Output: {...} - returned array where cm_json is decoded

Definition at line 2636 of file cm.py.

def cm::check_global_writing (   i  ) 
Check global writing to repository

Input:  {
        }

Output: {
          cm_return  - return code >0 if writing is not allowed
        }

Definition at line 836 of file cm.py.

def cm::cid2array (   i  ) 
Convert cid to array

Input:  {
          cid      - in format (REPO_UOA:)KEY_UOA:DATA_UOA
          (prefix) - add prefic to output variables (<prefix>_repo_uoa:...)
        }

Output: {
          cm_return - return code = 0 if successful
          cm_array  - array
        }

Definition at line 565 of file cm.py.

def cm::convert_cm_array_to_uri (   i  ) 
Convert cM array to uri (convert various special parameters)

Input:  {
          cm_array   - array to convert to uri
        }

Output: {
          cm_return  - return code (check "access" function for full description)
          (cm_error) - error text  (check "access" function for full description)
          cm_string  - converted string
          cm_string1 - converted string (for urlopen)
        }

Definition at line 2669 of file cm.py.

def cm::convert_file_to_upload_string (   i  ) 
Convert file to upload string

Input:  {
          cm_full_filename - file name to convert
        }

Output: {
          cm_return            - return code =0 if successful
                                             >0 if error
          cm_file_upload_base64 - string that can be used to upload file
        }

Definition at line 1278 of file cm.py.

def cm::convert_iso_time_to_str (   i  ) 
Get current date and time

Input:  {
          cm_iso_datetime    - date and time in ISO format
          (cm_custom_format) - customize view
        }

Output: {
          cm_return       - return code =0 if successful
                                        >0 if error
          cm_string       - user friendly date/time
        }

Definition at line 1345 of file cm.py.

def cm::convert_str_to_sha1 (   i  ) 
Convert string to sha1

Input:  {
          cm_string       - string
        }

Output: {
          cm_return             - return code >0 if not authentificated
          cm_string_sha1        - password in SHA1 (digest)
          cm_string_sha1_hex    - password in SHA1 (digest in hex)
          cm_string_sha1_base64 - BASE64 (SHA1 digest) - compatible with htpasswd format
        }

Definition at line 2785 of file cm.py.

def cm::convert_str_to_special (   s  ) 
Convert string to a special cM string that is used to substitute variables in text

Input:  string

Output: special string 

Definition at line 2744 of file cm.py.

def cm::convert_string_to_html (   i  ) 
Convert string to html (remove special characters)

Input:  {
          cm_string  - string to process
          cm_skip_br - if 'yes', do not add <BR>
        }

Output: {
          cm_return - return code = 0 if successful
          cm_string - processed string
        }

Definition at line 1928 of file cm.py.

def cm::convert_text_to_value (   i  ) 
Convert cm text to cm value

Input:  {
          cm_text - text to convert
          cm_type - type: {float, integer, string, uoa}

Output: {
          cm_return - return code = 0 if successful
          cm_value  - value in python format
        }

Definition at line 2413 of file cm.py.

def cm::copy_vars (   i  ) 
Convert cM array to uri (convert various special parameters)

Input:  {
          cm_input_array  - input array
          cm_output_array - output array
          cm_vars         - list of variables to copy
        }

Output: {
          cm_return  - return code (check "access" function for full description)
        }

Definition at line 2711 of file cm.py.

def cm::create_data_entry (   i  ) 
Create data entry

Input:  {
          cm_path                  - path to the repository
          cm_module_uoa            - module UOA 
          cm_data_uoa              - data UOA 
          (cm_data_uid)            - if cm_data_uoa==alias, we can force a given UID through this variable
          (cm_array)               - array to add to the entry
                                     If not set, the whole array will be added
                                     including all working variables - we do not suggest to do that
          (cm_add_default)         - if 'yes', add default params from descriptions (module/kernel)
          (cm_update)              - if 'yes', update entry
          (cm_description)         - description of the data entry
          (cm_display_as_alias)    - user readable alias to display instead of module:data
          (cm_skip_update_info)    - if == 'yes', do not write 'cm_updated'
          (cm_note)                - note about this data entry
          (cm_like)                - if 'yes' add +1 for this user to the entry

          (cm_file_upload_tmp_uid) - normally generated automatically by web server
                                     when uploading files
          (cm_file_upload_name)    - preffered uploaded file name 
          (cm_file_upload_type)    - type of file (if .zip, it will be automatically unziped)
          (cm_archive)             - if file should be kept as archive

          ...                      - if 'cm_array' not present, add everything else from this array
                                     to the entry 
          (lock_uid)               - unlock data
        }

Output: {
          cm_return  - return code >0 if error
                                   -1 if entry exists
          cm_path    - path to created data entry
          cm_uid     - uid (from UOA)
          cm_alias   - alias (from UOA)
        }

Definition at line 958 of file cm.py.

def cm::create_default_array_from_description (   i  ) 
Create array with default parameters from data description

Input:  {
          cm_data_desc    - cM data description
        }

Output: {
          cm_return       - return code =0 if successful
                                        >0 if error
          cm_array        - array with default parameters
        }

Definition at line 1244 of file cm.py.

def cm::create_entry (   i  ) 
Create an UOA entry directory structure.

Input:  {
          cm_path       - path to a repository
          (cm_data_uoa) - data UOA
          (cm_data_uid) - if cm_data_uoa==alias, we can force a given UID through this variable
          (lock_uid)    - UID of the aquired lock
        }

Output: {
          cm_return - return code =  0 if created entry
                                  = -1 if already exist
                                  >  0 if error

          cm_path   - path to data entry
          cm_uid    - uid (from UOA)
          cm_alias  - alias (from UOA)
          cm_uoa    - alias or uid if alias==''
        }

Definition at line 700 of file cm.py.

def cm::delete_alias (   i  ) 
Delete alias

Input:  {
          cm_path    - path to the entry
          cm_uid     - uid (from UOA)
          cm_alias   - alias (from UOA)
        }

Output: {
          cm_return  - return code >0 if error
        }

Definition at line 883 of file cm.py.

def cm::delete_directory (   i  ) 
Delete a given directory with subdirectories (be careful)

Input:  {
          cm_path - path to delete
        }

Output: {
          cm_return  - return code = 0 if successful
        }

Definition at line 1889 of file cm.py.

def cm::delete_entry (   i  ) 
Delete entry

Input:  {
          cm_path        - path to the entry
          cm_path_module - part of the path with module
          cm_uid         - uid (from UOA), needed to delete alias disambiguator if exists
          cm_alias       - alias (from UOA), needed to delete alias disambiguator if exists
        }

Output: {
          cm_return  - return code >0 if error
        }

Definition at line 854 of file cm.py.

def cm::find_index_in_array (   i  ) 
Find index in array of formart [{cm_index:'a', ...}, {cm_index='b', ...}, ...]
We use such array instead of simple associative array 
when we need to keep an order such as for actions ... 

Input:  {
          cm_array - array of format
          cm_index - index
        }

Output: {
          cm_return - return code =  0 if successful
                                    -1 if not found
          cm_array  - sub-array with given index
        }

Definition at line 1373 of file cm.py.

def cm::find_keys_by_prefix (   i  ) 
Find keys by prefix

Input:  {
          cm_array         - array to search
          cm_prefix        - prefix to search
          cm_sort_key_int  - sort key (int)
          cm_sort_key_text - sort key (text)
        }

Output: {
          cm_return - return code = 0 if successful
          keys      - list of keys
        }

Definition at line 2453 of file cm.py.

def cm::find_path_to_current_repository (   i  ) 
Finds local repository (recursively checks 
all upper directories until it finds the repository)

Input:  {
          cm_get_uid      - if 'yes' load data to get UID besides UOA
        }

Output: {
          cm_return       - return code >0 if error
                                        -1 if doesn't exist
          cm_path         - path to the local repository
          (cm_module_uoa) - module UOA of the current path
          (cm_module_uid) - module UID of the current path
          (cm_data_uoa)   - data UOA of the current path
          (cm_data_uid)   - data UID of the current path
        }

Definition at line 1399 of file cm.py.

def cm::find_path_to_entry (   i  ) 
Find path to an UOA entry (check UID or alias).

Input:  {
          cm_path     - path to a repository
          cm_data_uoa - data UOA
        }

Output: {
          cm_return      - return code =  0 if found path to entry
                                       = -1 if not found path to entry
                                       >  0 if error

          cm_path_orig   - i['cm_path']
          cm_path        - path to data entry
          cm_uid         - uid (from UOA)
          cm_alias       - alias (from UOA)
          cm_uoa         - alias or uid, if alias==''
        }

Definition at line 618 of file cm.py.

def cm::find_path_to_work_repositories (   i  ) 
Find path to work and local repositories

Input:  {
        }

Output: {
          cm_return  - return code >0 if error
          cm_array   - array of paths
        }

Definition at line 1459 of file cm.py.

def cm::flatten_array (   i  ) 
Flatten array
Any list item is converted to @number=value
Any dict item is converted to #key=value
# is always added at the beginning 

Input:  {
          cm_array        - full array
          prefix          - prefix (for recursion)
        }

Output: {
          cm_return - if =0, success
          cm_array  - flattened array
        }

Definition at line 1646 of file cm.py.

def cm::flatten_array_internal (   a,
  aa,
  prefix 
)

Definition at line 1678 of file cm.py.

def cm::flatten_classification (   i  ) 
Flatten classification ["class", "subclass", ..."] to class.subclass. ...

Input:  {
          cm_classification=[]
        }

Output: {
          cm_return - return code = 0 if successful
          cm_string - classification as string
        }

Definition at line 1959 of file cm.py.

def cm::gen_cm_tmp_file (   i  ) 
Generate tmp file name

Input:  {}

Output: {
          cm_return  - return code >0 if error
          cm_path    - path to file
          cm_path1   - path to file without extension
                       (for example, a script will create many sub-files with different extensions)
          cm_uid     - generated uid
        }

Definition at line 2313 of file cm.py.

def cm::gen_uid (   i  ) 
Generate cM UID

Input:  {}

Output: {
          cm_return - return code = 0, if successful
          cm_uid    - cM UID in string format (16 characters 0..9,a..f)
        }

Definition at line 523 of file cm.py.

def cm::get_all_uoa (   i  ) 
Get a list of all entries in the repository

Input:  {
          cm_path                      - path to repository
          (cm_module_uoa)              - module UOA. If =='', return available modules in the repository
                                                     (or use cm_only_available_modules explicitly)
          cm_only_uid                  - 'yes' to show only UIDs
          (cm_classes_uoa)             - prune by classes UOA
          (prune_data_uoa)             - prune by data UOA
          (cm_only_available_modules)  - if 'yes', return only available modules in a given repository
          (skip_data_cfg)              - if 'yes', do not add data cfg
          (cm_admin)                   - if 'yes', override access control - only internal use,
                                         can not be used during web access (explicitly removed)
        }

Output: {
          cm_return     - return code = 0 if successful
          cm_array      - list of UOA or only UID
          cm_mixed      - list of {cm_uid, cm_alias, cm_uoa, cm_display_as_alias, cm_display_html, cm_data_obj_cfg}
        }

Definition at line 2036 of file cm.py.

def cm::get_cm_version (   i  ) 
Get cM version

Input:  {
        }

Output: {
          cm_return  - return code >0 if not authentificated
          cm_array   - array with version
          cm_string  - version
        }

Definition at line 2756 of file cm.py.

def cm::get_current_date_time (   i  ) 
Get current date and time

Input:  {}

Output: {
          cm_return       - return code =0 if successful
                                        >0 if error
          cm_array        - array with date and time
          cm_iso_datetime - date and time in ISO format
        }

Definition at line 1315 of file cm.py.

def cm::get_data_description (   i  ) 
Get data entry description

Input:  {
          cm_run_module_uoa | cm_module_uoa - module UOA
          (cm_desc_key)                     - if this key is specified, take description from this key
          (cm_flat_desc_key)                - if this flat key is specified, take description from this flat key
          (cm_action_key)                   - action key
          cm_which_action                   - action
          (cm_key)                          - if action is specified, use this key instead of default one
        }

Output: {
          cm_return         - return code >0 if error
          cm_data_desc      - data description
          cm_params_default - data description
          ...               - other parameters from load_data
        }

Definition at line 2190 of file cm.py.

def cm::get_list_of_all_files (   i  ) 
Get a list of all files in a given directory recursively

Input:  {
          cm_path      - path
          cm_path_ext  - path extension
          limit        - limit number of files (if huge directories)
          number       - cur. number of files
          cm_all_files - if 'yes' do not ignore special files (like .cm)
        }

Output: {
          cm_return - return code = 0 if successful
          cm_array  - list of files
        }

Definition at line 2138 of file cm.py.

def cm::get_value_by_flattened_key (   i  ) 
Get value from array using flattened key

Input:  {
          cm_array - array
          cm_key   - flattened key
        }

Output: {
          cm_return - if =0, success
          cm_value  - value or None
        }

Definition at line 1700 of file cm.py.

def cm::get_var (   a,
  p 
)
Check if parameter 'p' is in array 'a' and return a[p] or '' otherwise

Input:  a - array
        p - parameter

Output: a[p], if 'p' in 'a'
        '', if 'p' not in 'a'

Definition at line 2577 of file cm.py.

def cm::init (   i  ) 
Module init

Input:  {}

Output: {
          cm_return       - return code = 0, if successful
          (cm_error)      - error text if return code > 0
        }

Definition at line 92 of file cm.py.

def cm::is_uid (   str  ) 
Check if string is cM UID

Input: string to check

Output: True if UID, otherwise False

Definition at line 546 of file cm.py.

def cm::is_windows (  ) 
Is Windows?

Input: None

Output: True if Windows

Definition at line 165 of file cm.py.

def cm::load_array_from_file (   i  ) 
Load array from file

Input:  {
          cm_filename - file name
        }

Output: {
          cm_return  - return code = 0 if successful
          cm_array   - array
        }

Definition at line 1572 of file cm.py.

def cm::load_code (   i  ) 
Load python code

Input:  {
          cm_path      - path
          cm_code_name - name of the python native module
        }

Output: {
          cm_return  - return code = 0, if successful
          code       - python code object
        }

Definition at line 484 of file cm.py.

def cm::load_data (   i  ) 
Load and cache cM data

Input:  {
          cm_module_uoa       - UOA of the module
          cm_data_uoa         - UOA of the data
          (cm_path)           - path to repository  
          (cm_path_array)     - array of paths to search
          (lock_acquire)      - if 'yes', acquire lock
          (lock_retry_num)    - number of retries to acquire lock (default=6)
          (lock_retry_delay)  - delay in sec before retrying to acquire lock (default=11)
          (lock_expire)       - for how long to acquire lock (secs) 
          (unlock_uid)        - unlock data (FGG note: I changed lock_uid to unlock_uid 
                                             not to interfere with update locking)
          (cm_admin)          - if 'yes', override access control - only internal use,
                                can not be used during web access (explicitly removed)
        }

Output: {
          cm_return           - return code = 0, if successful
          (cm_error)          - error text if return code > 0
          cm_data_obj         - cM data object
          cm_path             - path to data entry
          cm_path_module      - path to module entry with this entry
          cm_path_repo        - path to the repository of this entry
          cm_uid              - uid (from UOA)
          cm_alias            - alias (from UOA)
          cm_uoa              - cm_data_uoa (alias or uid if alias=='')
          cm_module_uoa       - module UOA 
          cm_module_uid       - module UID
          cm_display_as_alias - taken from the data
          cm_display_html     - prepare display: "display as alias" or <I>alias</I> or UID
          (lock_uid)          - UID of the aquired lock
        }

Definition at line 182 of file cm.py.

def cm::load_json_file (   i  ) 
Load json from file

Input:  {
          cm_filename - file name with json
        }

Output: {
          cm_return - return code = 0 if successful
          cm_array  - array from json file
        }

Definition at line 1501 of file cm.py.

def cm::load_module (   i  ) 
Load and cache cM module

Input:  {
          cm_module_uoa - UOA of the module
          (cm_path)
        }

Output: {
          cm_return       - return code = 0, if successful
          cm_code         - python code object
          external_module - if 'yes', module is external
          cm_path         - path to data entry
          cm_uid          - uid (from UOA)
          cm_alias        - alias (from UOA)

        }

Definition at line 392 of file cm.py.

def cm::merge_arrays (   i  ) 
Intelligently merge cm_array with cm_array1

Input:  {
          cm_array  - merge this array with cm_array1 (will be directly modified!)
          cm_array1 - cM array

Output: {
          cm_return - return code = 0 if successful
          cm_array  - output array
        }

Definition at line 2504 of file cm.py.

def cm::merge_arrays_ll (   a,
  b 
)
Intelligently merge cm_array with cm_array1

Input:  a  - merge this array with cm_array1 (will be directly modified!)
        b - cM array

Output: {
          cm_return - return code = 0 if successful
        }

Definition at line 2490 of file cm.py.

def cm::prepare_cid (   i  ) 
Prepare cid 

Input:  {
          (cm_repo_uoa)                     - repository UOA
          cm_run_module_uoa | cm_module_uoa - module UOA
          cm_data_uoa                       - data UOA
        }

Output: {
          cm_return               - 0
          cm_string_uid           - cid with only uid
          cm_string_with_repo_uid - cid with only uid
          cm_string_uoa           - cid with alias or uid
          cm_string_with_repo_uoa - cid with alias or uid
          cm_repo_uid             - cm_repo_uid
          cm_repo_uoa             - cm_repo_uoa
          cm_module_uid           - cm_module_uid
          cm_module_uoa           - cm_module_uoa
          cm_data_uid             - cm_data_uid
          cm_data_uoa             - cm_data_uoa
        }

Definition at line 2814 of file cm.py.

def cm::prepare_final_out (   i,
  j 
)
Prepare final output of cM access function depending on cm_console

Input:  i= {
             cm_return    - return code (check "access" function for full description)
             (cm_error)   - error text  (check "access" function for full description)
             ...
           }

        j= {
             (cm_console) - cm_console  (check "access" function for full description)
             (cm_output)  - if !='', save output to file
             ...
           }

Output: {}

Definition at line 2593 of file cm.py.

def cm::print_for_con (   s  ) 
Print string

Input:  s   - string

Output: 

Definition at line 2021 of file cm.py.

def cm::print_for_web (   s  ) 
Print string in UTF-8

Input:  s   - string

Output: 

Definition at line 2006 of file cm.py.

def cm::remote_access (   i  ) 
Remote access to cM

Input:  {
          cm_remote_url             - remote URL
          (cm_user_uoa)             -
          (cm_user_password)        -
          (cm_user_password1)       -
          (remote_repo_uoa)

          (remote_pre_auth)         - if 'yes', need standard http login/password pre-authentication
          (cm_remote_user_name)     - remote username
          (cm_remote_user_password) - remote password

          (cm_web_module_uoa)       - module to run
          (cm_web_action)           - action to perform
                                      if =='download', prepare entry/file download through Internet

          (cm_save_to_file)         - if cm_web_action==download,
                                      save output to this file

          ...                       - all other request parameters
        }

Output: {
          cm_return  - return code = 0 if successful
                                  > 0 if error
                                  < 0 if warning (rarely used at this moment)
          (cm_error) - error text, if cm_return > 0
        }

Definition at line 3488 of file cm.py.

def cm::replace_from_dict (   s,
  rep 
)
Replace substrings from array rep in string s

Input:  s   - string
        rep - array with substrings to replace

Output: new string

Definition at line 1837 of file cm.py.

def cm::restore_flattened_array (   i  ) 
Restore flattened array

Input:  {
          cm_array             - flattened array
          (cm_replace_in_keys) - array with strings to replace in keys
                                 (used in forms to process # and @ through ^35^ and ^64^ for example)
        }

Output: {
          cm_return - if =0, success
          cm_array  - restored array
        }

Definition at line 1853 of file cm.py.

def cm::save_array_to_file_as_json (   i  ) 
Save array to file

Input:  {
          cm_filename - file name with json
          cm_array    - array to save
        }

Output: {
          cm_return - return code = 0 if successful
        }

Definition at line 1534 of file cm.py.

def cm::save_flat_array_to_file (   i  ) 
Load array from file

Input:  {
          cm_array       - array to save (only flat one)
          cm_filename    - file name
          separate_lines - if 'yes', put key and value on separate lines
        }

Output: {
          cm_return  - return code = 0 if successful
        }

Definition at line 1608 of file cm.py.

def cm::set_print_mode (   i  ) 
Set print mode

Input:  {
          'mode' = 'on' | 'off'
        }

Output: 

Definition at line 1987 of file cm.py.

def cm::set_value_by_flattened_key (   i  ) 
Set value in array using flattened key

Input:  {
          cm_array           - array (it will be directly changed!)
          cm_key             - flattened key (or not if doesn't start with #)
          cm_value           - value to set
          cm_replace_in_keys - array with strings to replace in keys
                               (used in forms to process # and @ through ^35^ and ^64^ for example)
        }

Output: {
          cm_return - if =0, success
          cm_array  - modified array
        }

Definition at line 1758 of file cm.py.

def cm::str2cm (   i  ) 
Convert string to cM array

Input:  string

Output: {
          cm_return - return code = 0 if successful
          cm_array  - array
        }

Definition at line 2545 of file cm.py.

def cm::substitute_str_in_file (   i  ) 
Substitute string in file

Input:  {
          cm_file    - file
          cm_string1 - string to be replaced
          cm_string2 - replace string
        }

Output: {
          cm_return  - return code >0 if error
        }

Definition at line 924 of file cm.py.

def cm::system (   i  ) 
System call with timeout (careful, may cause overheads)

Input:  {
          cmd       - command line
          (timeout) - timeout in seconds (granularity 0.01 sec) - may cause overheads ...
        }

Output: {
          cm_return      - return code =0 if success
                                       =1 if timedout and killed
          (cm_error)     - error text  if return code > 0
          cm_return_code - return code of a program
        }

Definition at line 2271 of file cm.py.

Referenced by cm_action().

def cm::web_print_array_for_debug (   i  ) 
Print array for debug purposes (use <pre> and <div align="left")

Input:  {
          some array
        }

Output: {
          cm_return - 0
        }

Definition at line 599 of file cm.py.


Variable Documentation

string cm::cm_action_default = 'default'

Definition at line 61 of file cm.py.

string cm::cm_json_with_text_sep = '*** ### --- CM JSON SEPARATOR --- ### ***'

Definition at line 64 of file cm.py.

cm::cm_kernel = None

Definition at line 87 of file cm.py.

string cm::cm_module_default = 'core'

Definition at line 59 of file cm.py.

string cm::cm_module_default_access = 'access'

Definition at line 60 of file cm.py.

string cm::cm_unparsed_sep = '--'

Definition at line 62 of file cm.py.

string cm::env_cm_bin = 'CM_BIN'

Definition at line 42 of file cm.py.

string cm::env_cm_cfg = 'CM_DEFAULT_CFG'

Definition at line 44 of file cm.py.

string cm::env_cm_cfg_path = 'CM_DEFAULT_CFG_PATH'

Definition at line 45 of file cm.py.

string cm::env_cm_default_repo = 'CM_DEFAULT_REPO'

Definition at line 46 of file cm.py.

string cm::env_cm_local_repo = 'CM_LOCAL_REPO'

Definition at line 47 of file cm.py.

string cm::env_cm_remote_repo_proxy_http = 'CM_REMOTE_REPO_PROXY_HTTP'

Definition at line 51 of file cm.py.

string cm::env_cm_remote_repo_proxy_https = 'CM_REMOTE_REPO_PROXY_HTTPS'

Definition at line 52 of file cm.py.

string cm::env_cm_root = 'CM_ROOT'

Definition at line 41 of file cm.py.

string cm::env_cm_tmp = 'CM_TMP'

Definition at line 43 of file cm.py.

string cm::env_cm_user_password = 'CM_USER_PASSWORD'

Definition at line 49 of file cm.py.

string cm::env_cm_user_password1 = 'CM_USER_PASSWORD1'

Definition at line 50 of file cm.py.

string cm::env_cm_user_uoa = 'CM_USER_UOA'

Definition at line 48 of file cm.py.

dictionary cm::ini
Initial value:
{
     # This variable describes initialization of cM framework
     # -1 - not initalized
     # 0 - initialized 
     # 1 - error during initialization
     'init':-1,
     'loaded_module_by_path':{},
     'loaded_module_by_path_last_modification':{},
     'loaded_data_by_path':{},
     'loaded_data_by_path_last_modification':{},
     'pcfg':'',
     'cfg':{},
     'dcfg':{},
     'path':'',
     'web':'no',
     'web_auth':{},
     'web_style':{},
     'remote_repo':{}
    }

Definition at line 66 of file cm.py.

cm::print_on = True

Definition at line 89 of file cm.py.

tuple cm::r = access_fe_from_cmd(sys.argv[1:])

Definition at line 3933 of file cm.py.

string cm::var_cm_cfg_default = 'default'

Definition at line 57 of file cm.py.

string cm::var_cm_cfg_local = 'local'

Definition at line 56 of file cm.py.

Definition at line 55 of file cm.py.

string cm::var_cm_info = '.cm'

Definition at line 54 of file cm.py.


Generated on Wed May 28 02:49:03 2014 for Collective Mind Framework by DoxyGen 1.6.1
Concept, design and coordination: Grigori Fursin (C) 1993-2013