Script Reference

The scripts Module

Console scripts.

class chrysalio.scripts.ScriptRegistry(settings)[source]

Class to simulate Application Registry.

class chrysalio.scripts.Script(args, create_all, includes=None, dbsession_factory=None)[source]

Base class for a script which reads the INI file and interacts with the database.

Parameters:
  • args (argparse.Namespace) – Command line arguments.

  • create_all (bool) – If True, it creates all the tables, otherwise, it checks if the table users exists with at least one user.

  • includes (list) – (optional) List of hard coding includes.

  • dbsession_factory (sqlalchemy.orm.session.sessionmaker) – (optional) Function to create session.

classmethod argument_parser(description)[source]

Create an argument parser object to parse command line arguments.

Parameters:

description (str) – Description of the script.

Return type:

argparse.ArgumentParser

classmethod arguments(parser, args=None, filemode='w')[source]

Retrieve arguments from parser, check them and setup logging.

Parameters:
  • parser (argparse.ArgumentParser) – Configuration parser object.

  • args (list) – (optional) Command line arguments (for testing).

  • filemode (str) – File mode for logging ('w' or 'a').

Return type:

argparse.Namespace

The scripts.ciopopulate Script

Populate the database and the attachment directory.

chrysalio.scripts.ciopopulate.main(args=None)[source]

Main function.

class chrysalio.scripts.ciopopulate.Populate(args, dbuser_class, _xml2db, relaxng, includes=None, dbsession_factory=None)[source]

Class to populate database.

Parameters:
  • args (argparse.Namespace) – Command line arguments.

  • dbuser_class – Class to manage user SQL table.

  • _xml2db (function) – Function to load XML configuration files. See xml2db().

  • relaxng (dict) – A dictionary describing the main Relax NG with the following keys: 'root', 'version' and 'file'.

  • includes (list) – (optional) List of hard coding includes.

  • dbsession_factory (sqlalchemy.orm.session.sessionmaker) – (optional) Function to create session.

classmethod argument_parser(description='Populate database.')[source]

Create an argument parser object to parse command line arguments.

Parameters:

description (str) – (optional) Description of the script populating the database.

Return type:

argparse.ArgumentParser

run(files=None)[source]

Check settings and initialize database.

Parameters:

files (list) – (optional) List of files on command-line.

Return type:

int

Returns:

Exit code.

The scripts.ciobackup Script

Backup database into an XML file.

chrysalio.scripts.ciobackup.main(args=None)[source]

Main function.

class chrysalio.scripts.ciobackup.Backup(args, _db2xml, relaxng, includes=None, dbsession_factory=None)[source]

Class to backup database.

Parameters:
  • args (argparse.Namespace) – Command line arguments.

  • _db2xml (function) – Function to save database fields into XML elements. See db2xml().

  • relaxng (dict) – A dictionary describing the main Relax NG with the following keys: 'root', 'version' and 'file'.

  • includes (list) – (optional) List of hard coding includes.

  • dbsession_factory (sqlalchemy.orm.session.sessionmaker) – (optional) Function to create session.

classmethod argument_parser(description='Backup database.')[source]

Create an argument parser object to parse command line arguments.

Parameters:

description (str) – (optional) Description of the script saving the database.

Return type:

argparse.ArgumentParser

run(directory)[source]

Save asked elements.

Parameters:

directory (str) – Path to the backup directory.

Return type:

int

Returns:

Exit code.

The scripts.cioupdate Script

Console script to backup and update Chrysalio sites.

chrysalio.scripts.cioupdate.main(args=None)[source]

Main function.

class chrysalio.scripts.cioupdate.CioUpdate(args, conf_file)[source]

Class to backup and update Chrysalio sites.

start(sites=None)[source]

Start backup and update.

Parameters:

sites (list) – (optional) Chrysalio sites to backup and update. If empty, this method processes all Chrysalio sites defined in configuration file.

Return type:

bool