Exemple #1
0
    def __init__(self):
        global USE_THREADS
        ttk.Frame.__init__(self, name='application', width=300, height=500)
        self.pack(expand='yes', fill='both')
        self.master.title('pjsua2 Demo')
        self.master.geometry('500x500+100+100')

        # Accounts
        self.accList = []

        self.quitting = False

        # Construct GUI
        self.initGui()

        # Instantiate endpoint
        self.ep = endpoint.Endpoint()
        self.ep.libCreate()

        # Default config
        self.appConfig = settings.AppConfig()
        if USE_THREADS:
            self.appConfig.epConfig.uaConfig.threadCnt = 1
            self.appConfig.epConfig.uaConfig.mainThreadOnly = False
        else:
            self.appConfig.epConfig.uaConfig.threadCnt = 0
            self.appConfig.epConfig.uaConfig.mainThreadOnly = True
Exemple #2
0
    def __init__(self,
                 url,
                 version=1.1,
                 auth_token=None,
                 http_keep_alive=True):
        self.version = version
        self.base_uri = '%s/api/v%s' % (url.rstrip('/'), self.version)
        self.auth_token = auth_token
        self.http_keep_alive = http_keep_alive

        self._http_handler = http.get_handler(http_keep_alive=http_keep_alive)

        # api endpoints
        self.schemas = endpoint.Endpoint('schemas', self)
        self.hooks = endpoint.Endpoint('hooks', self)
        self.hiera = endpoint.Endpoint('hiera', self)
        self.users = endpoint.Endpoint('users', self)
Exemple #3
0
    def __init__(self, link_id, link_info, guests, guest_checker, bridge_name):
        self.id = link_id

        if 'settings' in link_info:
            self.settings = link_info['settings']
        else:
            self.settings = {}

        self.endpoints = []

        for end in link_info['endpoints']:
            self.endpoints.append(endpoint.Endpoint(end, guests, guest_checker))

        self.bridge = br.LinuxBridge(bridge_name)
        self.initialize_parameters()
    def __init__(self):
        global USE_THREADS
        ttk.Frame.__init__(self, name='application', width=300, height=500)
        self.pack(expand='yes', fill='both')
        self.master.title('pjsua2 Demo')
        self.master.geometry('500x500+100+100')

        # Logger
        self.logger = log.Logger()

        # Accounts
        self.accList = []

        # GUI variables
        self.showLogWindow = tk.IntVar(value=0)
        self.quitting = False

        # Construct GUI
        self._createWidgets()

        # Log window
        self.logWindow = log.LogWindow(self)
        self._onMenuShowHideLogWindow()

        # Instantiate endpoint
        self.ep = endpoint.Endpoint()
        self.ep.libCreate()

        # Default config
        self.appConfig = settings.AppConfig()
        if USE_THREADS:
            self.appConfig.epConfig.uaConfig.threadCnt = 1
            self.appConfig.epConfig.uaConfig.mainThreadOnly = False
        else:
            self.appConfig.epConfig.uaConfig.threadCnt = 0
            self.appConfig.epConfig.uaConfig.mainThreadOnly = True
        self.appConfig.epConfig.logConfig.writer = self.logger
        self.appConfig.epConfig.logConfig.filename = "pygui.log"
        self.appConfig.epConfig.logConfig.fileFlags = pj.PJ_O_APPEND
        self.appConfig.epConfig.logConfig.level = 5
        self.appConfig.epConfig.logConfig.consoleLevel = 5
Exemple #5
0
 def tokens(self, username):
     return endpoint.Endpoint('users/%s/tokens' % username, self)
Exemple #6
0
 def entities(self, schema_name):
     return endpoint.Endpoint('entities/%s' % schema_name, self)
Exemple #7
0
    for message_type in message_objects_dict:
        for message_object in message_objects_dict:
            # print(message_object.focus)
            for endP in message_object.endpoints:
                if endP in endpoints:
                    continue
                else:
                    endpoints.append(endP)

    #list to hold thread objects
    endpoint_threads = []
    for section in config_parser.sections():
        try:
            print section
            thread = endpoint.Endpoint(config_parser.get(section, "host"),
                                       config_parser.get(section, "port"),
                                       section)
            endpoint_threads.append(thread)
            thread.daemon = True
            thread.name = section
            thread.start()
        except:
            print(
                "Invalid section configuration in endpoints.ini. Check format."
            )

    i = 0

    #AFTER MESSAGE IS SET UP CAST IT BACK TO CHILD CLASS OF MONITOREDMESSAGE
    while True:
        for message_type in message_objects_dict:
    def run(self, api_endpoint=None, api_includes=[], db_tbl=None):
        if (api_endpoint == None or db_tbl == None):
            return False

        # Set initializing values of the app object
        self.current_ep = api_endpoint
        self.current_db_tbl = db_tbl

        with endpoint.Endpoint() as ep:

            if (api_endpoint == 'teams'):
                for country_id in constants.ACTIVE_COUNTRIES:

                    temp_ep = f"countries/{country_id}/teams"
                    # https://soccer.sportmonks.com/api/v2.0/countries/{ID}/teams
                    ep.query(temp_ep, api_includes)

                    if (ep.error != None or len(ep.data) == 0): continue

                    self.insert(ep.data)
                    ep.data = []

            if (api_endpoint == "players"):
                # https://soccer.sportmonks.com/api/v2.0/squad/season/{season_ID}/team/{team_ID}
                with db.Db() as d:
                    s = d.session(d.engine)
                    with s.begin() as sess:
                        for country_id in constants.ACTIVE_COUNTRIES:
                            if (country_id == 41): continue

                            leagues = d.get_all_filter(sess, 'leagues',
                                                       'country_id',
                                                       country_id)

                            for league_obj in leagues:
                                league = league_obj.__dict__
                                if (league['name']
                                        not in constants.LEAGUE_NAMES_LIST):
                                    continue

                                teams = d.get_all_filter(
                                    sess, 'teams', 'current_season_id',
                                    league['current_season_id'])

                                for team_obj in teams:
                                    team = team_obj.__dict__
                                    temp_ep = f"squad/season/{league['current_season_id']}/team/{team['id']}"
                                    self.logger.info(
                                        f"Working on {league['name']} - {team['name']} players"
                                    )
                                    ep.query(temp_ep, api_includes)

                                    if (ep.error != None or len(ep.data) == 0):
                                        continue

                                    self.insert(ep.data)
                                    ep.data = []

            if (api_endpoint == "standings"):
                # Endpoint:	https://soccer.sportmonks.com/api/v2.0/standings/season/__ID__
                with db.Db() as d:
                    s = d.session(d.engine)
                    with s.begin() as sess:
                        for country_id in constants.ACTIVE_COUNTRIES:
                            if (country_id == 41): continue

                            leagues = d.get_all_filter(sess, 'leagues',
                                                       'country_id',
                                                       country_id)

                            for league_obj in leagues:
                                league = league_obj.__dict__
                                if (league['name']
                                        not in constants.LEAGUE_NAMES_LIST):
                                    continue

                                temp_ep = f"standings/season/{league['current_season_id']}"
                                self.logger.info(
                                    f"Working on {league['name']} standings")
                                ep.query(temp_ep, api_includes)

                                if (ep.error != None or len(ep.data) == 0):
                                    continue

                                self.insert(ep.data)
                                ep.data = []

            else:
                ep.query(self.current_ep, api_includes)

                if (ep.error != None): return False

                self.insert(ep.data)
                if (api_endpoint == 'livescores'):
                    self.extra_insert(ep.data, 'lineups', 'lineups')
        sleep(constants.DEFAULT_SLEEP_INTERVAL)
        # Heartbeat
        self.heartbeat()