concurrent.core.environment package

Submodules

concurrent.core.environment.api module

Environment related in interfaces

class concurrent.core.environment.api.IEnvUpgrader[source]

Bases: concurrent.core.components.component.Interface

Extension point that defines component which needs to perform any upgrade actions

TODO: @Joze: Integrate database manager, needs to be passed to the component

env_created()[source]

Called when a new env has been created

env_do_upgrade(dbManager)[source]

This will perform the actual upgrade process. Be careful on using db transactions

env_need_upgrade(dbManager)[source]

Called when we start an environment, if this call returns true the env will not able to load until we force an upgrade.

class concurrent.core.environment.api.IEnvBackup[source]

Bases: concurrent.core.components.component.Interface

Extension point that defines a component which will be able to act when a backup will be performed.

env_backup()[source]

Called when the current env get’s backedup

env_restore()[source]

Called when we restored the current env from a backup

class concurrent.core.environment.api.IEnvDelete[source]

Bases: concurrent.core.components.component.Interface

Extension point that defines a component which will be able to act when an environment gets deleted

env_delete()[source]

Called when the current env get’s backedup

concurrent.core.environment.envadmin module

Basic command line application

class concurrent.core.environment.envadmin.EnvAdmin(envdir=None)[source]

Bases: concurrent.tools.console.CMD

Bash application that helps us with our env’s.

classmethod all_docs()[source]

Add specifc help content

ceck_env(print_error=False)[source]

Will return true if the environment can be opened and false otherwise

complete_plugin(text, line, begidx, endidx)[source]
do_backup(line)[source]

backup the current env

do_createenv(line)[source]

Create environment by passed arguments or interactively

do_delete(line)[source]
do_launchenv(line)[source]

launch the current app or a different one in the env. Different apps are usful to testing reasons!

do_plugin(line)[source]
do_quit(line)[source]

Exit app

do_recover(line)[source]

backup the current env

do_setdefault(line)[source]
do_update(line)[source]
doc_header = 'Concurrent Admin Console 0.1.2\nAvailable Commands:\n'
get_backup_data()[source]
get_createenv_data()[source]
get_delete_data()[source]
get_recover_data()[source]
open_env()[source]

Opens the currently selected environment

print_help_header()[source]
print_interactive_header()[source]
print_usage_help()[source]
print_version()[source]

Print version of app

prompt = 'Con> '
recover_env(backupfile, dest_env=None)[source]

recreate an env from a backup file

set_env(name, env=None)[source]

Set a new env to be used

exception concurrent.core.environment.envadmin.RecoverBackupFileError(message, title=None, show_traceback=False)[source]

Bases: concurrent.core.exceptions.baseerror.BaseError

Simple error used when trying to recover an env from a backup file

title = '[Recover Backup Error]'
concurrent.core.environment.envadmin.main(args=None)[source]

concurrent.core.environment.environment module

Basic Concurrent environment

class concurrent.core.environment.environment.Environment(basepath, create=False, args=None)[source]

Bases: concurrent.core.components.component.Component, concurrent.core.components.component.ComponentManager

This is our environment, it represents a real physical structure in disc where a aplications life’s in.

The env is a like:

BasePath/
  • logs/
  • configs/
  • plugins/
  • backups/

Every folder in our environment needs a dummy file, this file is used in env checks! The name of the dummy file is espected to be equal the name of the direct parent folder.

activate_component(component)[source]

Initialize member vasr of the component. Concurrent will initialize the environment (env) the config handle (config) and the logger (log)

backup(source=None, dest=None)[source]

backup the whole environment to a zip file

backup_components

List of components that implement IEnvBackup

backup_get_default_file_name()[source]

get default backup file name

check()[source]

Check if the current basepath is a valid environment. It just checks if all directories and needed files are in here.

classmethod check_dir(dirname)[source]

Check if the dir has a file with the same name as it’s children

check_version()[source]

Checks current installed framework version

conditional_create_env_dirs()[source]

Create all dirs the environment needs

create(args=None)[source]

Will try to create a new environment. Our basepath has already been set in the constructor.

If args contains (‘baseon’, ‘file’), default values will not be loaded; they are expected to be provided by that file or other options.

@param args: List of tuples used to setup the env. The tuples are styled like:
(section, name, value)
delete()[source]

Delete an environment is like uninstalling it

delete_components

List of components that implement IEnvDelete

extra_plugins_dir

Path from where we load additional plugins. Apart from those we’ll load all those located in the path pointed out plugins env var.

get_app_name()[source]

Return name of currently running application

get_backups_dir()[source]

Absulute path where our backups are

classmethod get_backups_dir_name()[source]

Return the name of the backups folder

get_configs_dir()[source]

Absulute path where our configs are

classmethod get_configs_dir_name()[source]

Return the name of the configs folder

classmethod get_ini_filename()[source]

get the filename we use for our main ini

get_logs_dir()[source]

Absulute path where our logs are

classmethod get_logs_dir_name()[source]

Return the name of the logs folder

get_plugins_dir()[source]

Absulute path where our plugins are

classmethod get_plugins_dir_name()[source]

Return the name of the plugins folder

get_readme_file_path()[source]

Absolute path to the readme file

get_sql_dir()[source]

Absulute path where our sql schemas are

classmethod get_sql_dir_name()[source]

Return the name of the sql folder

get_templates_dir()[source]

Absulute path where our templates are

classmethod get_templates_dir_name()[source]

Return the name of the templates folder

get_version_file_path()[source]

Absolute path to the version file

get_version_from_file()[source]

Return the version saved in the ‘VERSION’ file of the env

is_component_enabled(cls)[source]
If a compoent is not enabled but it should be (always enabled
componentsor such) return true. Otherwise return false and prevent

enabling.

launch_main_app()[source]

Method that will launch the registered main app for this environment

log_file

If your log type is file this will be the target file

log_format

Custom logging format.

If nothing is set, the following will be used:

[$(project_name)s][$(app)s][$(module)s] $(levelname)s: $(message)s

Format can include regular log tags:
Concurrent addes several new tags’:
  • $(app)s - application that is running in this environment
  • $(path)s - full environmnet path
  • $(basename)s - basename of the environmnet path
  • $(project_name)s - current project name that lifes in the env
log_level

Python logger Level: (CRITICAL, ERROR, WARN, INFO, DEBUG)

log_type

type of log we’ll use: (none, file, stderr, syslog, winlog)

needs_upgrade()[source]

Return whether the environment needs to be upgraded.

project_app

Application that will run in this environment.

project_desc

Short description of the project.

project_name

Name of the project.

restored()[source]

Called when this env has been restored

setup_config(use_defaults=False)[source]

Will try to load the environment config file using our config reader. If we need to use the defaults we’ll also regenerate the config file.

setup_log()[source]

Setup our logger

shutdown(tid=None, except_logging=False)[source]

Shutdown the environment.

upgrade(backup=False, backup_dest=None)[source]

Upgrade database.

@param backup: whether or not to backup before upgrading @param backup_dest: name of the backup file @return: whether the upgrade was performed

upgrade_components

List of components that implement IEnvUpgrader

exception concurrent.core.environment.environment.EnvFolderCheckError(message, title=None, show_traceback=False)[source]

Bases: concurrent.core.exceptions.baseerror.BaseError

Error raised when the env got bad folders

title = '[Environment Error]'
exception concurrent.core.environment.environment.EnvWrongVersionError(message, title=None, show_traceback=False)[source]

Bases: concurrent.core.exceptions.baseerror.BaseError

Error raised when the env saved was build with a different version

title = '[Environment Error]'
class concurrent.core.environment.environment.EnvSetup(compmgr, init=None, cls=<class 'concurrent.core.environment.environment.EnvSetup'>)[source]

Bases: concurrent.core.components.component.Component

Component which will act as the setup manager for the environment. Also handles main backup/restore procedures if something hapens to the environment

env_backup()[source]

Called when we make a backup

env_created()[source]

Called when a new env has been created

env_delete()[source]

Called when an env get’s deleted, env is still valid

env_do_upgrade(dbManager)[source]

This will perform the actual upgrade process. Be careful on using db transactions

env_need_upgrade(dbManager)[source]

Called when we start an environment, if this call returns true the env will not able to load until we force an upgrade.

TODO: This needs to be done!

env_restore()[source]

Called when we make a restore

Module contents