示例#1
0
 def test_bad_separators_line_2(self):
     services_manager = services.ServiceManager(
         "resources/bad_separators_2.storage")
     try:
         result = services_manager.update_services(
             "resources/config_bad_separators_line_2.txt")
     except custom_exceptions.BadConfigException as e:
         self.assertEqual(
             str(e),
             "[ERROR] Line 2 of config file does not have required format: identifier|name|url"
         )
示例#2
0
 def test_two_unknown_service(self):
     services_manager = services.ServiceManager(
         "resources/unknown_one_service.storage")
     try:
         result = services_manager.update_services(
             "resources/config_two_unknown.txt")
     except custom_exceptions.UnrecognizedServiceException as e:
         self.assertEqual(
             str(e),
             "[ERROR] Service with identifier \"slack\" unrecognized. Supported services are: ['bitbucket', 'gitlab']"
         )
示例#3
0
    def __init__(self, endpoint=None, **kwargs):
        """ Initialize a new client for the Keystone v2.0 API. """
        super(Client, self).__init__(endpoint=endpoint, **kwargs)
        self.endpoints = endpoints.EndpointManager(self)
        self.roles = roles.RoleManager(self)
        self.services = services.ServiceManager(self)
        self.tenants = tenants.TenantManager(self)
        self.tokens = tokens.TokenManager(self)
        self.users = users.UserManager(self)
        # NOTE(gabriel): If we have a pre-defined endpoint then we can
        #                get away with lazy auth. Otherwise auth immediately.

        # extensions
        self.ec2 = ec2.CredentialsManager(self)

        if endpoint is None:
            self.authenticate()
        else:
            self.management_url = endpoint
示例#4
0
 def initialize(self):
     self.manager = services.ServiceManager().instance()
示例#5
0
from flask import request
from flask import jsonify

from app import app
from config import TG_BOT_TOKEN
from config import OWNER
import services

### Service manager init ###
manager = services.ServiceManager()
manager.send_message(OWNER, '<System>: Bot is running')


@app.route(f'/{TG_BOT_TOKEN}', methods=['POST', 'GET'])
def index():
    if request.method == 'POST':
        r = request.get_json()
        pr = services.ParsedRequest(r)
        manager.set_attrs(pr)
        manager.use_service()

        return jsonify(r)
    return '<h1>Bot welcomes you.</h1>'
示例#6
0
def load_service_manager(path):
    if os.path.isfile(path):
        with open(path, "rb") as sm:
            return pickle.load(sm)
    else:
        return serv.ServiceManager(path)
示例#7
0
 def test_two_services_normal(self):
     services_manager = services.ServiceManager(
         "resources/two_services_normal.storage")
     result = services_manager.update_services(
         "resources/config_two_normal.txt")
     self.assertIsNone(result)