def load_credentials(self): if len(self._credentials) < 1: from restapi.services.detect import detector self._credentials = detector.load_group(label='resources') return self._credentials
""" close the rabbit connection when the HTTP API finish - catch the sigkill? - deconstructor in the flask ext? - check connection errors """ import json import pika from restapi.services.detect import detector from utilities.logs import get_logger log = get_logger(__name__) QUEUE_SERVICE = 'rabbit' QUEUE_VARS = detector.load_group(label=QUEUE_SERVICE) ''' :param instance: The Endpoint. :param params: The kv pairs to be in the log message. ''' def prepare_message(instance, user=None, isjson=False, **params): """ { # start "request_id": # build a hash for the current request "edmo_code": # which eudat centre is "json": "the json input file" # parameters maris "datetime":"20180328T10:08:30", # timestamp "ip_number":"544.544.544.544", # request.remote_addr
# -*- coding: utf-8 -*- from datetime import datetime from restapi.services.detect import detector from utilities import htmlcodes as hcodes from utilities import path from utilities.logs import get_logger log = get_logger(__name__) seadata_vars = detector.load_group(label='seadata') # SEADATA_ENABLED = seadata_vars.get('project') SEADATA_ENABLED = seadata_vars.get('project') == '1' ORDERS_ENDPOINT = 'orders' EDMO_CODE = seadata_vars.get('edmo_code') API_VERSION = seadata_vars.get('api_version') class ErrorCodes(object): PID_NOT_FOUND = ("41", "PID not found") INGESTION_FILE_NOT_FOUND = ("50", "File requested not found") # addzip_restricted_order MISSING_ZIPFILENAME_PARAM = ("4000", "Parameter zip_filename is missing") MISSING_FILENAME_PARAM = ("4001", "Parameter file_name is missing") MISSING_FILESIZE_PARAM = ("4002", "Parameter file_size is missing") INVALID_FILESIZE_PARAM = ("4003", "Invalid parameter file_size, integer expected") MISSING_FILECOUNT_PARAM = ("4004", "Parameter file_count is missing") INVALID_FILECOUNT_PARAM = ( "4005", "Invalid parameter file_count, integer expected")
''' These are how the paths to the data on the host are mounted into the containers. Prepended before this is the RESOURCES_LOCALPATH, defaulting to /usr/share. ''' # THIS CANNOT CHANGE, otherwise QC containers will not work anymore! FS_PATH_IN_CONTAINER = '/usr/share/batch' # At least, the 'batch' part has to be like this, I am quite sure. # About the '/usr/share', I am not sure, it might be read form some # environmental variable passed to the container. But it is safe # to leave it hard-coded like this. CONTAINERS_VARS = detector.load_group(label='containers') class ClusterContainerEndpoint(EndpointResource): """ Base to use rancher in many endpoints """ def custom_init(self): """ It gets called every time a new request is executed """ self._handle = None self._credentials = {} # self.load_credentials() # self.get_or_create_handle() def load_credentials(self):
import os import copy from restapi.confs import API_URL, BASE_URLS, ABS_RESTAPI_PATH, CONF_PATH from restapi.confs import BACKEND_PACKAGE, CUSTOM_PACKAGE from restapi.services.detect import detector from restapi.attributes import EndpointElements, ExtraAttributes from restapi.swagger import BeSwagger from restapi.utilities.meta import Meta from restapi.utilities.configuration import read_configuration from restapi.utilities.logs import log meta = Meta() CONF_FOLDERS = detector.load_group(label='project_confs') ######################## # Customization on the table ######################## class Customizer: """ Customize your BACKEND: Read all of available configurations and definitions. """ def __init__(self, testing=False, init=False): # Input self._testing = testing