jerrycan package¶
Subpackages¶
- jerrycan.background package
- jerrycan.db package
- jerrycan.routes package
- jerrycan.test package
- Subpackages
- jerrycan.test.db package
- jerrycan.test.misc package
- jerrycan.test.routes package
- Subpackages
- Submodules
- jerrycan.test.routes.TestForgotRoute module
- jerrycan.test.routes.TestLoginRoute module
- jerrycan.test.routes.TestProfileRoute module
- jerrycan.test.routes.TestRegisterRoute module
- jerrycan.test.routes.TestRegisterTelegramRoute module
- jerrycan.test.routes.TestStaticRoutes module
- Module contents
- Submodules
- jerrycan.test.TestFramework module
- jerrycan.test.mocks module
- Module contents
- Subpackages
Submodules¶
jerrycan.Config module¶
- class jerrycan.Config.Config¶
Bases:
object
Class that keeps track of configuration data The class attributes should only be called after running load_config
- API_VERSION: str = '1'¶
The API Version
- BEHIND_PROXY: bool¶
Whether or not the site is being served by a reverse proxy like nginx.
- DB_MODE: str¶
The database mode (for example ‘sqlite’ or ‘mysql’)
- DB_URI: str¶
The database URI to use for database operations
- DEBUG_LOGGING_PATH: str¶
The path to the debug logging path
- DOMAIN_NAME: str¶
The domain name of the website
- FLASK_SECRET: str¶
The flask secret key
- HTTP_PORT: int¶
The port to use when serving the flask application
- LOGGING_PATH: str¶
The path to the logging file
- MAX_API_KEY_AGE: int = 2592000¶
The maximum age for API keys
- MAX_USERNAME_LENGTH: int = 12¶
The maximum length of usernames
- MIN_USERNAME_LENGTH: int = 1¶
The Minimum length for usernames
- RECAPTCHA_SECRET_KEY: str¶
Google ReCaptcha secret key for bot detection
- RECAPTCHA_SITE_KEY: str¶
Google ReCaptcha site key for bot detection
- REQUIRED_TEMPLATES: Dict[str, str] = {'about': 'static/about.html', 'error_page': 'static/error_page.html', 'forgot': 'user_management/forgot.html', 'forgot_password_email': 'email/forgot_password.html', 'index': 'static/index.html', 'login': 'user_management/login.html', 'privacy': 'static/privacy.html', 'profile': 'user_management/profile.html', 'register': 'user_management/register.html', 'registration_email': 'email/registration.html'}¶
Specifies required template files
- SENTRY_DSN: str¶
The sentry DSN used for error logging
- SESSION_PROTECTION: str = 'basic'¶
The flask_login session protection value With ‘basic’, the remember me functionality will function, with ‘strong’, a browser restart will log the user out.
- SMTP_ADDRESS: str¶
The SMPT Address used for sending emails
- SMTP_HOST: str¶
The SMPT Host used for sending emails
- SMTP_PASSWORD: str¶
The SMPT Password used for sending emails
- SMTP_PORT: int¶
The SMPT Port used for sending emails
- STRINGS: Dict[str, str] = {'401_message': 'You are not logged in', '500_message': 'The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.', 'confirmation_key_invalid': 'Confirmation key invalid', 'email_already_in_use': 'Email already in use', 'invalid_password': 'Invalid Password', 'logged_in': 'Logged in successfully', 'logged_out': 'Logged out', 'password_changed': 'Password changed successfully', 'password_reset_email_title': 'Password Reset', 'password_was_reset': 'Password was reset successfully', 'passwords_do_not_match': 'Passwords do not match', 'recaptcha_incorrect': 'ReCaptcha not solved correctly', 'registration_email_title': 'Registration', 'registration_successful': 'Registered Successfully. Check your email inbox for confirmation', 'telegram_chat_id_set': 'Telegram Chat ID was set', 'user_already_confirmed': 'User already confirmed', 'user_already_logged_in': 'User already logged in', 'user_confirmed_successfully': 'User confirmed successfully', 'user_does_not_exist': 'User does not exist', 'user_is_not_confirmed': 'User is not confirmed', 'user_was_deleted': 'User was deleted', 'username_already_exists': 'Username already exists', 'username_length': 'Username must be between {} and {} characters long'}¶
Dictionary that defines various strings used in the application. Makes it easier to use custom phrases.
- TELEGRAM_API_KEY: str¶
API key for a telegram bot
- TELEGRAM_BOT_CONNECTION: bokkichat.connection.impl.TelegramBotConnection.TelegramBotConnection¶
Telegram bot connection
- TELEGRAM_WHOAMI: bool¶
Whether or not the telegram WHOAMI background thread will be started
- TEMPLATE_EXTRAS: Dict[str, Callable[[], Dict[str, Any]]] = {'about': <function Config.<lambda>>, 'forgot': <function Config.<lambda>>, 'forgot_email': <function Config.<lambda>>, 'index': <function Config.<lambda>>, 'login': <function Config.<lambda>>, 'privacy': <function Config.<lambda>>, 'profile': <function Config.<lambda>>, 'register': <function Config.<lambda>>, 'registration_email': <function Config.<lambda>>}¶
This can be used to provide the template rendering engine additional parameters, which may be necessary when adding UI elements. This is done with functions that don’t expect any input and return a dictionary of keys and values to be passed to the template rendering engine
- TESTING: bool¶
Whether or not testing is enabled
- VERBOSITY: int¶
The verbosity level of the logging when printing to the console
- VERSION: str¶
The current version of the application
- WARNING_LOGGING_PATH: str¶
The path to the logging path for WARNING messages
- classmethod base_url() str ¶
- Returns
The base URL of the website
- classmethod dump_env_variables(path: Optional[str] = None)¶
Dumps all environment variables used by this application to a file :param path: The path to the file to which to dump the content.
If this is None, the file contents will be printed.
- Returns
None
- classmethod ensure_environment_variables_present()¶
Makes sure that all required environment variables have been set. If this is not the case, the app will exit. :return: None
- classmethod environment_variables() Dict[str, List[str]] ¶
Specifies required and optional environment variables :return: The specified environment variables in two lists in
a dictionary, grouped by whether the variables are required or optional
- classmethod initialize_telegram()¶
Initializes the telegram bot connection :return: None
- classmethod load_config(root_path: str, module_name: str, sentry_dsn: str)¶
Loads the configuration from environment variables :param root_path: The root path of the application :param module_name: The name of the project’s module :param sentry_dsn: The sentry DSN used for error logging :return: None
jerrycan.base module¶
- jerrycan.base.app = <Flask 'jerrycan.base'>¶
The Flask App
- jerrycan.base.db = <SQLAlchemy engine=None>¶
The SQLAlchemy database connection
- jerrycan.base.login_manager = <flask_login.login_manager.LoginManager object>¶
The Flask-Login Login Manager
jerrycan.enums module¶
- class jerrycan.enums.AlertSeverity(value)¶
Bases:
enum.Enum
Enumeration that defines the various levels of severity an alert can have
- DANGER = 'danger'¶
Translates to a red alert
- INFO = 'info'¶
Translates to a blue alert
- SUCCESS = 'success'¶
Translates to a green alert
- WARNING = 'warning'¶
Translates to a yellow alert
jerrycan.exceptions module¶
- exception jerrycan.exceptions.ApiException(reason: str, status_code: int)¶
Bases:
Exception
Api raised when an API-related exception occurs
- __init__(reason: str, status_code: int)¶
Initializes the exception :param reason: The reason the API Exception was raised :param status_code: The status code associated with the exception
jerrycan.initialize module¶
- jerrycan.initialize.CREATED_BLUEPRINTS = []¶
Keeps track of created blueprint names. This is necessary for unit testing with nose, because duplicate blueprint names will cause errors.
- jerrycan.initialize.init_flask(module_name: str, sentry_dsn: str, root_path: str, config: Type[jerrycan.Config.Config], models: List[Type[sqlalchemy.orm.decl_api.Model]], blueprint_generators: List[Tuple[Callable[[str], flask.blueprints.Blueprint], str]], extra_jinja_vars: Optional[Dict[str, Any]] = None)¶
Initializes the flask application :param module_name: The name of the module :param sentry_dsn: The sentry DSN used for error logging :param root_path: The root path of the flask application :param config: The Config class to use for configuration :param models: The database models to create :param blueprint_generators: Tuples that contain a function that generates
a blueprint and the name of the blueprint
- Parameters
extra_jinja_vars – Any extra variables to pass to jinja
- Returns
None
jerrycan.wsgi module¶
- jerrycan.wsgi.start_server(config: Type[jerrycan.Config.Config], task_definitions: Dict[str, Tuple[int, Callable]])¶
Starts the flask application using a cheroot WSGI server :param config: The configuration to use :param task_definitions: The background tasks, consisting of:
the name of the task
the time to wait before running the task again
a function that takes no arguments that executes the task
- Returns
None