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.
Contents
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": "sascha.just@own-hero.net"
}
}
CONFIG['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
}
}
@terminals
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
Manifest.in 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gcshelpers-SaschaJust-0.1a1.tar.gz.
File metadata
- Download URL: gcshelpers-SaschaJust-0.1a1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4d523ca08afbc890e60a90a5cb083ec35eae426e77e51db842042f5e79cf55
|
|
| MD5 |
4e99c402b8b593638746d71e13d57f82
|
|
| BLAKE2b-256 |
43fd09945cf19aed959b67d5b39d5df60e00eee2241078cec9bb275d11e2beed
|
File details
Details for the file gcshelpers_SaschaJust-0.1a1-py3-none-any.whl.
File metadata
- Download URL: gcshelpers_SaschaJust-0.1a1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e4356637ca2a34b3bdadcc8a3f6b0809c1b1f6937f20642fca1ae404a3a44d6
|
|
| MD5 |
fb224a5612c430cd1f0cef126a97d0f9
|
|
| BLAKE2b-256 |
de93ea7b05b471cfc6aa5a74fbddcae7dd153a1edc7e541b2482fb717cb4d273
|