Beispiel #1
0
def start_scoreboard_client(api_port=DEFAULT_PORT,
                            api_ip=DEFAULT_IP,
                            server_port=DEFAULT_PORT + 1,
                            server_ip=DEFAULT_IP,
                            debug_mode=True):
    """
        Starts an wrapped Scoreboard acting as a client, connected with an HTTP API and with the server.

        If debug_mode returns an initialized HTTP API, but not started, connected with the wrapped Scoreboard acting
            as a client.

    :param api_port: (int) The port to use to expose the HTTP REST API.
    :param api_ip: (str) The IPv4 address to expose the HTTP REST API.
    :param server_port: (int) The port to use to communicate with the clients.
    :param server_ip: (str) The IPv4 address to use to communicate with the clients.
    :param debug_mode: (bool) True if in debug mode. False otherwise.
    :return: (None/Flask) According to debug_mode.

    """
    client = ScoreboardWrapper(server_port, server_ip)
    client.start(CLIENT_MODE)

    api = get_api(client)

    if not debug_mode:
        print("Starting API in {}:{}".format(api_ip, api_port))  #DEBUGGING
        api.run(host=api_ip, port=api_port)
    else:
        return api
Beispiel #2
0
def index():
    names, nums, ranks = get_api()
    n = len(names)
    return render_template('index.html',
                           ranks=ranks,
                           names=names,
                           nums=nums,
                           n=n)
Beispiel #3
0
 def get(self, path, *, headers, body, cookies):
     # for our friends
     if path == '/🙃':
         return self.send_text_content(
             'Hello friend, here is the list of sessions:\n' +
             json.dumps(dict(os.environ)) + '\n', 'text/plain')
     path, query = parse_path(path)
     if not path.startswith('/'):
         return self.send_error(404, 'Not Found')
     if path.startswith('/static'):
         subpath = path[7:]
         return self.get_static(subpath)
     if path == '/':
         return self.get_static('/home.html')
     else:
         return get_api(path,
                        query,
                        self.session,
                        send_json=self.send_json_content,
                        send_error=self.send_error)
Beispiel #4
0
def wallet_total():
    eveapi = api.get_api();

    corpDetails = eveapi.corp.CorporationSheet()
    walletNames = {}

    for accountKey,description in corpDetails.walletDivisions.Select("accountKey", "description"):
        walletNames[accountKey] = description

    logging.info(walletNames)

    wallet = eveapi.corp.AccountBalance(characterID=settings.API_CHARACTERID)
    walletBalances = {}

    for accountKey,balance in wallet.accounts.Select("accountKey", "balance"):
        walletBalances[accountKey] = balance

    logging.info(walletBalances)

    return render_template('wallets.html', walletNames=walletNames, walletBalances=walletBalances)
Beispiel #5
0
    def configure(self, config, scene_specs):
        TaskWorld = get_task_world(config['task_name'], real=False)
        self.task_name = config['task_name']
        interface = BulletInterface(self.sim)
        self.world = TaskWorld(interface,
                               scene_specs,
                               random_task=config['random_task'])

        self.api = get_api(config['api'])(self.world, config['full_demo'])
        print('API: %s' % config['api'])

        for act in self.api.ACT:
            assert (act in self.program_names)

        for adp in self.api.ADAPTIVE:
            assert (adp in self.program_names)

        try:
            self.world.start_world()
        except ValueError:
            print('setup scene failed, retry')
            self.world.reset_world()
Beispiel #6
0
import requests
import api

api_key = api.get_api()
weather_url = "https://api.openweathermap.org/data/2.5/onecall"

weather_params = {"lat": 51.496979, "lon": 11.968803, "appid": api_key}

response = requests.get(weather_url, params=weather_params)
response.raise_for_status()
data = response.json()
data_slice = data["hourly"][:12]

need_umbrella = False
for hour_data in data_slice:
    condition_code = hour_data["weather"][0]["id"]
    if int(condition_code) < 700:
        need_umbrella = True

if need_umbrella:
    print("You'll need an umbrella today ☔️")
else:
    print("You won't need an umbrella today ☀️")
Beispiel #7
0
def main():
    stream_listener = TweetListener()
    stream = tweepy.Stream(auth=api.get_api().auth, listener=stream_listener)
    stream.filter(track=['Accenture', '$ACN', '#ACN'])
Beispiel #8
0
try:
    from .api import load_posts, process_posts, get_api
except Exception as e:
    from api import load_posts, process_posts, get_api

from pprint import pprint
import vk

api = get_api()

community_id = 126622648

posts = load_posts(api, community_id, 1000)
print('posts loaded!')

for post in posts:
    pass
# pprint(post)
# print('-----------------')

processed_posts = process_posts(posts)
print(len(processed_posts))
exit(0)
for post in processed_posts:
    pprint(post)
    print('-----------------')
def use_api(api_url):
    data2 = api.get_api(api_url)
    return data2
Beispiel #10
0
def api_test():
    eveapi = api.get_api();

    result = eveapi.eve.AllianceList()

    return render_template('list_alliances.html', alliances=result.alliances)
Beispiel #11
0
 def setUp(self):
     self.api = get_api()
     self.cache = self.api._root._handler
Beispiel #12
0
 def __init__(self):
     self.api = get_api()
     _, _, self.width, self.height = self.api.get_desktop()
Beispiel #13
0
 def __init__(self, api_credentials, refresh_time=3600):
     super(VKEventHandler, self).__init__()
     self.api = get_api(**api_credentials)
     self.refresh_time = refresh_time
     log.info('vk event handler started')
Beispiel #14
0
 def __init__(self, api_credentials=None, db_credentials=None, api=None, db=None, near_date=None):
     super(NotificatonIniter, self).__init__()
     self.api = api or get_api(**api_credentials)
     self.db = db or DataBaseHandler(**db_credentials)
     self.near_date = near_date
Beispiel #15
0
 def __init__(self, api_credentials=None, db_credentials=None, api=None, db=None):
     super(TalkHandler, self).__init__()
     self.api = api or get_api(**api_credentials)
     self.db = db or DataBaseHandler(**db_credentials)
     self.states = StateHandler()
Beispiel #16
0
#!/usr/bin python3

import time
# from sensor import read_data
from api import get_api
from predictive import predict

if __name__ == "__main__":

    print('\n--- INICIO DE EJECUCCIÓN ---')
    # 1º llamamos a la Weather API
    get_api()
    # 2º llamar al read_data del sensor
    # read_data()
    # 3º llamar a la clase predictive para realizar la predicción del modelo
    predict()
 def setUp(self):
     self.scoreboard_wrapper = ScoreboardWrapper()
     self.app = get_api(self.scoreboard_wrapper)
     self.client = self.app.test_client()
     self.maxDiff = None
Beispiel #18
0
 def test_api(self, *args):
     get_api(MockApp)