Skip to main content

gcshelpers: a collection of helper classes and functions for the mozintermittent Google Cloud services.

Project description

About gcshelpers

The gcshelpers library provides helper functions and utility classes for the mozintermittent microservices to interact with the Google Cloud.


Class: Config

Config is a wrapper for JSON configuration files. Accessing CONFIG the first time leads to a lazy initialization of the configuration object. The name of the configuration file is derived from the calling instance, i.e. the package gcshelpers is called from. This means using gcshelpers.config.CONFIG from hgminer will load the hgminer.conf configuration file. The library will first look for a file in the current directory, then the user's home directory, and finally /etc.

If no configuration file can be found, the library attempts to create one from an example file in the calling project's asset directory. Assuming hgminer is executed and no configuration file is present, gcshelpers attempts to copy hgminer/assets/hgminer.conf.example to the user's home directory.

The JSON file is converted into an object and can be subscribed to via properties or dictionary access. This means that the following config will yield the below valid accesses:

    "contact": {
        "email": ""

If the local assets directory contains a grammar (ANTLR4), the configuration is checked against this grammar during construction, i.e. when the config is initially read during the first access.

Grammar example

The example below requires a configuration that consists of a contact entry having a name and email set, while the structure of those is defined in the terminal section.

doc {
  contact : {
    name: NAME,
    email: EMAIL

NAME : [A-Za-z].*;
EMAIL : [a-zA-Z0-9_\-\.\+]+ '@' [a-zA-Z0-9_\-\.]+ '.' [a-zA-Z]{2,};

Class: MozLogger

This class wraps the standard logger with a default configuration. This also provides means to log to Pub/Sub. It features eager initialization and can directly be used. If no log configuration is present, one is created on the fly.

LOGGER.debug('Persisting %s', taskid)

Function: pkgload

This function lets you load assets from the package. Make sure you specify any assets in the to make sure they are installed together with the package.

QUERY_INSERT = pkgload(__package__, 'assets/insert_job.sql')

The storage module

The module contains methods to interact with Google Cloud Storage.

The telemetry module

The module contains methods to interact with Google Pub/Sub.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gcshelpers-SaschaJust, version 0.1a1
Filename, size File type Python version Upload date Hashes
Filename, size gcshelpers_SaschaJust-0.1a1-py3-none-any.whl (12.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size gcshelpers-SaschaJust-0.1a1.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page