Пример #1
0
import gzip
import zlib
import base64
import sqs
import enum_type

def checksum(data):
    return zlib.crc32(data)

def b64encode(data):
    return base64.b64encode(data)

def b64decode(data):
    return base64.b64decode(data)

COMPRESSION_MODE = enum_type.create(NONE="NoCompression", COMPRESS="Compress")

class CompressionClassFactory():
    @staticmethod
    def instance(name):
        #done this way for performance
        if name.lower() == COMPRESSION_MODE.NONE.lower():
            return NoCompression()
        if name.lower() == COMPRESSION_MODE.COMPRESS.lower():
            return Compress()
        

class AbstractCompression:
    __metaclass__ = ABCMeta
    @abstractmethod
    def compress(self, data, compressionlevel=None):
Пример #2
0
import gzip
import zlib
import base64
import re
import time
import json
import compression
import errors
import metric_schema as schema
import metric_error_code as code
import collections
import timeit
import enum_type
import uuid

PAYLOAD_TYPE = enum_type.create(CSV="CSV", JSON="JSON")


class PayloadClassFactory():
    @staticmethod
    def instance(context,
                 name,
                 compression_mode,
                 sensitivity_type,
                 source_IP=None):
        #done this way for performance
        if name.lower() == PAYLOAD_TYPE.CSV.lower():
            return CSV(context, compression_mode, sensitivity_type, source_IP)
        if name.lower() == PAYLOAD_TYPE.JSON.lower():
            return JSON(context, compression_mode, sensitivity_type, source_IP)
Пример #3
0
import math
import uuid
import sys
import time
import os
import math
import csv
import util
import sensitivity
import retry
import enum_type
import boto3_util
from s3 import S3
from six import StringIO

DEFAULT_EVENTS = enum_type.create(CLIENTINITCOMPLETE="clientinitcomplete",
                                  SESSIONSTART="sessionstart")


class Athena(object):
    def __init__(self, db_name, context={}):
        self.__context = context
        self.__client = boto3_util.client('athena', api_version='2017-05-18')
        self.__db_name = db_name
        self.__bucket = os.environ[c.ENV_S3_STORAGE]
        self.__s3 = S3(bucket=self.__bucket)

    @property
    def query_results_path(self):
        return "results"

    def query(self, sql, result_as_list=True, sync=True):
Пример #4
0
import gzip
import zlib
import base64
import sqs
import enum_type

def checksum(data):
    return zlib.crc32(data)

def b64encode(data):
    return base64.b64encode(data)

def b64decode(data):
    return base64.b64decode(data)

SENSITIVITY_TYPE = enum_type.create(NONE="Insensitive", ENCRYPT="Sensitive")

class SensitivityClassFactory():
    @staticmethod
    def instance(name):
        #done this way for performance
        if name.lower() == SENSITIVITY_TYPE.NONE.lower():
            return Unencrypted()
        if name.lower() == SENSITIVITY_TYPE.ENCRYPT.lower():
            return Encrypted()
        

class AbstractSensitivity:
    __metaclass__ = ABCMeta

class Unencrypted(AbstractSensitivity):