erecord_cmn.utils package

Submodules

erecord_cmn.utils.coding module

erecord_cmn.utils.coding

Coding methods

erecord_cmn.utils.coding.byteify(input)[source]

unicode to utf-8

Convert any decoded JSON object from using unicode strings to UTF-8-encoded byte strings

erecord_cmn.utils.coding.get_val(value)[source]

JSON object to utf-8

erecord_cmn.utils.dir_and_file module

erecord_cmn.utils.dir_and_file

Methods on directories and files

class erecord_cmn.utils.dir_and_file.ReadableWorksheet[source]

Bases: object

further for a xlrd.Worksheet

classmethod get_sheet(filepath, sheetname)[source]

returns the sheet named sheetname into filepath

classmethod read_sheet_column(sh, ind)[source]

Reads in sheet and returns the column ind

classmethod read_sheet_rows(sh)[source]

Reads and returns the sheet rows

class erecord_cmn.utils.dir_and_file.WritableWorksheet[source]

Bases: object

further for a xlwt.Worksheet

COLUMN_LIMIT = 256
ROW_LIMIT = 65536
default_style = <xlwt.Style.XFStyle object>
head_font = <xlwt.Formatting.Font object>
head_style = <xlwt.Style.XFStyle object>
help_font = <xlwt.Formatting.Font object>
help_style = <xlwt.Style.XFStyle object>
classmethod write(ws, row, col, v, style=None)[source]

Writes v into the (row, col) cell of the ws xlwt.Worksheet

Truncation : writes v if limits OK and else does nothing.

classmethod write_group_bycol(ws, info_list, nb_head=0, row_main=[], row_ini=0, title=None)[source]

Writes title and info_list into a xlwt.Worksheet (a col by data)

classmethod write_group_byrow(ws, info_list, nb_head=0, col_main=[], row_ini=0, title=None)[source]

Writes title and info_list into a xlwt.Worksheet (a row by data)

classmethod write_help(ws, row_ini, text)[source]

Writes a help text into a xlwt.Worksheet

classmethod write_line_feed(ws, row_ini)[source]

Writes a line feed into a xlwt.Worksheet

classmethod write_lines_bycol(ws, row_ini, lines, nb_head=0, row_main=[])[source]

Writes lines into a xlwt.Worksheet (a col by line)

classmethod write_lines_byrow(ws, row_ini, lines, nb_head=0, col_main=[])[source]

Writes lines into a xlwt.Worksheet (a row by line)

classmethod write_title(ws, row_ini, title)[source]

Writes a title into a xlwt.Worksheet

erecord_cmn.utils.dir_and_file.clean_dir(dirpath)[source]

Create the directory dirpath after having deleting dirpath if still existing.

erecord_cmn.utils.dir_and_file.create_dir_if_absent(dirpath)[source]

Create the directory dirpath if dirpath does not yet exist.

Returns True if the creation has been done.

erecord_cmn.utils.dir_and_file.create_dirs_if_absent(path_list)[source]
erecord_cmn.utils.dir_and_file.delete_path_if_present(path)[source]

Delete the path if it exists.

Returns True if the deletion has been done.

erecord_cmn.utils.dir_and_file.get_available_pathname(rootpath, rootname)[source]

Defines and returns a path name that doesn’t yet exist.

The path name is based on rootname, is the one of a rootpath subdirectory.

The pathname directory should be immediately created !

erecord_cmn.utils.dir_and_file.is_a_directory(path)[source]

Return True if path exists as a directory and else return False

erecord_cmn.utils.dir_and_file.make_csv_file(row_list, filename, dirpath, delimiter=';')[source]

Builds a csv file from row_list and saves it as filename under dirpath

erecord_cmn.utils.dir_and_file.make_zip_folder(folderpath)[source]

Builds the zip file of the folderpath.

Returns the zip file path name.

erecord_cmn.utils.dir_and_file.recursive_overwrite(src, dest)[source]

recursive overwrite taking into account directories and files

Links are not taken into account

erecord_cmn.utils.dir_and_file.save_posted_file(data, key, filepath)[source]

Save into the filepath file a file that is sent in POST data as key.

erecord_cmn.utils.dir_and_file.unzip_file(zip_file_path, path)[source]

unzip zip_file_path into path.

Returns True if success, and else False.

erecord_cmn.utils.erecord_package module

erecord_cmn.utils.erecord_package

Methods about erecord package

erecord_cmn.utils.erecord_package.control_in(vlehome_path, vle_version, pkgname, vpzname)[source]

Makes controls and returns a message about errors met

Controls : - path about pkgname is a directory - path about vpzname is a file

Note : the returned message is “” if no error met.

erecord_cmn.utils.erecord_package.control_out(runvle_path)[source]

Makes controls and returns reports

Controls : - stderr_filename under runvle_path - stdout_filename under runvle_path - ok_filename under runvle_path

erecord_cmn.utils.erecord_package.copy_erecord_data_file(vlehome_path, vle_version, src_folder, file_name)[source]

Copies file_name file from src_folder to data folder of erecord pkg

erecord_cmn.utils.erecord_package.create_and_fill_jsonfile(content, folder_path, file_name)[source]
erecord_cmn.utils.erecord_package.get_file_jsoncontent(folder_path, file_name)[source]
erecord_cmn.utils.erecord_package.get_value_type(json_value_type)[source]

Conversion of a value type coming from erecord pkg (json format)

Note : json_value_type values are : - vle::value::Value::type values - “” for unknown vle::value::Value::type value

or for vle::value::Value::USER that is treated as unknown
erecord_cmn.utils.erecord_package.print_vle_read_vpz_result(res)[source]
erecord_cmn.utils.erecord_package.print_vle_run_vpz_result(res)[source]
erecord_cmn.utils.erecord_package.run_simulation(runvle_path, vlehome_path, vle_usr_path, pkgname, vpzname)[source]
erecord_cmn.utils.erecord_package.vle_modify_vpz(runvle_path, vlehome_path, vle_version, vle_usr_path, pkgname, vpzname, storaged_list, conditions, begin, duration)[source]

Prepares and runs modify_vpz.vpz simulation of erecord pkg

As a result : the vpzname file simulator of the pkgname package (under vlehome_path) has been modified and is ready to be simulated or read.

Attention : give a pkgname, vpzname that is not a link but a copy

erecord_cmn.utils.erecord_package.vle_read_vpz(runvle_path, vlehome_path, vle_version, vle_usr_path, pkgname, vpzname)[source]

Prepares and runs read_vpz.vpz simulation of erecord pkg

This simulation produces (under runvle_path) the read_output.json json file that contains the input information of vpzname simulator.

Returns the input information of vpzname as json data

erecord_cmn.utils.erecord_package.vle_run_vpz(runvle_path, vlehome_path, vle_version, vle_usr_path, pkgname, vpzname, plan, restype)[source]

Prepares and runs run_vpz.vpz simulation of erecord pkg

This simulation produces (under runvle_path) the run_output.json json file that contains the results of vpzname simulation.

Returns results of vpzname simulation as json data

erecord_cmn.utils.errors module

erecord_cmn.utils.errors

Utils to manage errors

exception erecord_cmn.utils.errors.Http400[source]

Bases: exceptions.Exception

exception erecord_cmn.utils.errors.Http401[source]

Bases: exceptions.Exception

exception erecord_cmn.utils.errors.Http403[source]

Bases: exceptions.Exception

erecord_cmn.utils.errors.build_error_message(error=None, msg=None)[source]

builds a message error

The message is composed by msg (optional) and error message(s) (optional)

erecord_cmn.utils.errors.get_error_status(e)[source]
erecord_cmn.utils.errors.logger_report_error(LOGGER)[source]

Reports an error to log

erecord_cmn.utils.logger module

erecord_cmn.utils.logger

erecord_cmn.utils.logger.get_logger(name)[source]

Creates a logger

Creates a logger with LOGGING_FILE file destination (if not None) and with console destination (if IN_PRODUCTION False).

erecord_cmn.utils.logger.report_error()[source]

Reports an error

erecord_cmn.utils.process module

erecord_cmn.utils.process

Subprocess methods

erecord_cmn.utils.process.call_subprocess(cmd, runvle_path, stderr_path, stdout_path)[source]

erecord_cmn.utils.urls module

erecord_cmn.utils.urls

Methods about urls

erecord_cmn.utils.urls.url_add_options(path, options)[source]

erecord_cmn.utils.vle module

erecord_cmn.utils.vle

Vle interface methods

Uses python os, os.path libraries.

Does not use pyvle anymore.

erecord_cmn.utils.vle.get_data_name()[source]
erecord_cmn.utils.vle.get_exp_name()[source]
erecord_cmn.utils.vle.get_output_name()[source]
erecord_cmn.utils.vle.get_pkg_output_path(pkg_path)[source]

returns the ‘output’ directory path of a vle package.

The vle package is located at pkg_path.

erecord_cmn.utils.vle.get_pkgs_name(vle_version)[source]
erecord_cmn.utils.vle.get_pkgs_suffix(version_name)[source]

returns suffix of pkgs name according to version_name

erecord_cmn.utils.vle.get_rep_pkg_data_path(rep_path, vle_version, pkgname)[source]

returns the ‘data’ directory path of a models repository vle package.

The models repository is located at rep_path, structured as a VLE_HOME directory. The vle package name is pkgname.

erecord_cmn.utils.vle.get_rep_pkg_exp_path(rep_path, vle_version, pkgname)[source]

returns the ‘exp’ directory path of a models repository vle package.

The models repository is located at rep_path, structured as a VLE_HOME directory. The vle package name is pkgname. The vpz files taken into account are those found (as vpz files of the pkgname vle package) under rep_path.

erecord_cmn.utils.vle.get_rep_pkg_output_path(rep_path, vle_version, pkgname)[source]

returns the ‘output’ directory path of a models repository vle package.

The models repository is located at rep_path, structured as a VLE_HOME directory. The vle package name is pkgname.

erecord_cmn.utils.vle.get_rep_pkg_path(rep_path, vle_version, pkgname)[source]

returns the path of a models repository vle package.

The models repository is located at rep_path, structured as a VLE_HOME directory. The vle package name is pkgname.

erecord_cmn.utils.vle.get_rep_pkgname_list(rep_path, vle_version)[source]

returns the list of the vle packages names of a models repository.

The models repository is located at rep_path, structured as a VLE_HOME directory.

The vle packages taken into account are those found (as vle packages) under rep_path.

erecord_cmn.utils.vle.get_rep_pkgs_path(rep_path, vle_version)[source]

returns the ‘pkgs’ directory path of a models repository

The models repository is located at rep_path, structured as a VLE_HOME directory.

erecord_cmn.utils.vle.get_vle_bin_path(usr_path)[source]
erecord_cmn.utils.vle.get_vle_lib_path(usr_path)[source]
erecord_cmn.utils.vle.get_vle_pkgconfig_path(usr_path)[source]
erecord_cmn.utils.vle.get_vlepath_pkg_name(vpzpath, limit)[source]

returns (vlepath, pkg, name) of a vpz file absolute path.

vpzpath is the vpz file absolute path.

vlepath is the vle path (models repository path), structured as a VLE_HOME directory. pkg is the vle package name. name is the vpz file name (path relative to ‘exp’ directory, with .vpz extension) (same as in vle) limit is the path not to reach (when searching ‘exp’ into vpzpath).

erecord_cmn.utils.vle.is_pkg_of_rep(rep_path, vle_version, pkgname)[source]

determines if a vle package exists (as a vle package) under a models repository path.

The vle package name is pkgname. The models repository path is rep_path.

Suppose that rep_path is a models repository path. Suppose that pkgname is a vle package.

erecord_cmn.utils.vle.is_structured_as_vle_home(path, vle_version=None)[source]

determines if the path directory is structured as a VLE_HOME directory.

Returns True if the path directory contains a pkgs subdirectory.

erecord_cmn.utils.vle.is_structured_as_vle_install(usr_path)[source]

determines if the usr_path is structured as a vle install directory.

Returns True if the usr_path directory contains directories : bin, lib and lib/pkgconfig.

erecord_cmn.utils.vle.is_structured_as_vle_version_name(version_name)[source]

returns True if version_name is structured as vle-V.rev and else False

(for example vle-1.1.3, vle-2.0.0)

erecord_cmn.utils.vle.is_vpz_of_pkg_of_rep(rep_path, vle_version, pkgname, vpzname)[source]

determines if a vpz file exists as a vpz file of vle package under a models repository path.

The vpz file name is vpzname. The vle package name is pkgname. The models repository path is rep_path.

Suppose that rep_path is a models repository path. Suppose that pkgname is a vle package of the models repository.

erecord_cmn.utils.vle.vle_bash_cmd(usr_path)[source]

builds and returns text bash commands to be run before calling vle

vle installed under usr_path

erecord_cmn.utils.vle.vle_identify(vlepath)[source]

returns (vle_version, vle_usr_path) of a models repository path.

vlepath is a models repository path.

vle_version is the vle version. vle_usr_path is the path of a vle install directory.

The method relies on the following rule :
  • vlepath contains a subdirectory named “erecord_conf” that contains : - a file named “VLE_VERSION” : containing the vle version name. - a file named “VLE_USR_PATH” : containing the vle install path name.

Note : not controlled : - vlepath is structured as a VLE_HOME (see is_structured_as_vle_home). - vle_version is structured as vle-V.rev

(see is_structured_as_vle_version_name).
  • vle_usr_path contains directories : bin, lib, lib/pkgconfig (see is_structured_as_vle_install).
erecord_cmn.utils.vle.vle_version_type(version_name)[source]

extracts and returns V from version name such as vle-V.rev

Module contents

erecord_cmn.utils

This package is part of erecord - Record platform web development

copyright:Copyright (C) 2014-2015 INRA http://www.inra.fr.
license:GPLv3, see License for more details.
authors:see Authors.

Python code of the erecord package

Python code, some of it is independant of django applications code

See erecord