Example #1
0
    def __init__(self, expression, s_symbols):
        """
            BRIEF  Cache the expression and sentence symbols
        """
        self.expression = expression
        self.s_symbols = s_symbols

        # TODO - Maybe we can statically initialize these
        globals()["T"] = boolean.boolean(boolean.boolean.TRUE)
        globals()["F"] = boolean.boolean(boolean.boolean.FALSE)
Example #2
0
    def testTrue(self):
        """Test all true cases"""

        self.assertTrue(boolean('True'))
        self.assertTrue(boolean('true'))
        self.assertTrue(boolean('yes'))
        self.assertTrue(boolean('y'))
        self.assertTrue(boolean('1'))
        self.assertTrue(boolean('t'))
Example #3
0
    def testFalse(self):
        """Test all true cases"""

        self.assertFalse(boolean('False'))
        self.assertFalse(boolean('false'))
        self.assertFalse(boolean('no'))
        self.assertFalse(boolean('n'))
        self.assertFalse(boolean('0'))
        self.assertFalse(boolean('f'))
Example #4
0
import jsonschema
from slackclient import SlackClient
from tenacity import retry, retry_if_exception_type, stop_after_delay, wait_exponential

log_level = os.environ.get('LOG_LEVEL', 'INFO')
logging.root.setLevel(logging.getLevelName(log_level))  # type: ignore
_logger = logging.getLogger(__name__)

SLACK_API_TOKEN = os.environ.get('SLACK_API_TOKEN')
SLACK_DEFAULT_CHANNEL = os.environ.get('SLACK_DEFAULT_CHANNEL')
SLACK = SlackClient(SLACK_API_TOKEN)
SLACK_SCHEMA_FILE_PATH = os.path.join(os.path.dirname(__file__), '../slack-message-schema.json')
with open(SLACK_SCHEMA_FILE_PATH) as f:
    SLACK_MESSAGE_SCHEMA = json.load(f)

SNS_PUBLISH_RESPONSE = boolean(os.environ.get('SNS_PUBLISH_RESPONSE', 'false'))
RESPONSE_SNS_TOPIC_ARN = os.environ.get('RESPONSE_SNS_TOPIC_ARN')
SNS = boto3.client('sns')


class HandlerBaseError(Exception):
    '''Base error class'''


class SlackBaseError(HandlerBaseError):
    '''Base Slack Error'''

class SlackApiError(SlackBaseError):
    '''Slack API error class'''
    def __init__(self, response: dict):
        self.msg = 'Slack error - {}'.format(response.get('error'))
Example #5
0
 def _MakeAssignments(self, *values):
     """
         BRIEF  Assign variables in the global namespace
     """
     for i, s in enumerate(self.s_symbols):
         globals()[s] = boolean.boolean(values[i])