Example #1
0
    def draw(self):
        """The OpenGL draw routine."""

        # sys.stderr.write("Start GLUTContext.draw\n")
        GL.glClearColor(self.background_color[0], self.background_color[1],
                        self.background_color[2], self.background_color[3])
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glEnable(GL.GL_DEPTH_TEST)

        # sys.stderr.write("About to draw collections\n")
        for collection in self.object_collections:
            collection.draw()

            err = GL.glGetError()
            if err != GL.GL_NO_ERROR:
                sys.stderr.write("Error {} drawing: {}\n".format(
                    err, gluErrorString(err)))
                sys.exit(-1)

        GLUT.glutSwapBuffers()
        # sys.stderr.write("Done drawing collections.\n")

        Rater.get().set()
        # sys.stderr.write("End GLUTContext.draw\n")

        self.framecount += 1
Example #2
0
def parse_file(filename, mode="text", player_name=None):
    out = []
    
    try:
        with file(filename) as f:
            parser = GamesParser(f, filename)
            games = parser.parse_file()
            for error in parser.errors:
                print error

        rater = Rater(games)
        ratings = rater.rate_games(parser.score_type)
        

        if mode == "gnuplot":
            commands = 'set key left\n'
            plot_command = 'plot "%s" with lines lw 2 title "%s"\n'
            
            for name in rater.players:
                player = rater.players[name]
                if player.get_game_count() > 0:
                    player_file_name = "plot_rating_%s.data" % player.name
                    commands += plot_command % (player_file_name, player.name)
                    if plot_command.startswith('plot'):
                        plot_command = 're' + plot_command
                    player_file = open(player_file_name, "w")  
                    for game_num in range(player.get_first_game() - 1, len(games) + 1):
                        rating = player.get_rating(game_num)
                        print >> player_file, "%d %d" % (game_num, rating)
    
            commands += 'pause mouse\n'
            command_file_name = "plot_commands.gnuplot"
            command_file = open(command_file_name, "w")
            print >> command_file, commands
            out.append("Run 'gnuplot %s' to plot all ratings." % command_file_name)
        elif mode == "json":
            rating_dict = {}
            for rating in ratings:
                r = {"name":rating[0], "matches":rating[1], "rating":rating[2], "delta":rating[3]}
                rating_dict[rating[0]] = r
            out.append(json.dumps(rating_dict))
        elif player_name is not None:
            player = rater.players[player_name]
            if player:
                for game_num in sorted(player.rating_history.keys()):
                    rating = player.rating_history[game_num]
                    out.append("%d %d" % (game_num, rating))
        else:
            out.append("Game: %s" % parser.game_name)
            out.append("Total number of games: %s" % len(games))
            hformat = "%-15s%-10s%-10s%-10s"
            rformat = "%-15s%7d%9d%9d"
            out.append(hformat % ("Name", "Games", "Rating", "Delta"))
            for rating in ratings:
                out.append(rformat % rating)
    except IOError as ioe:
        out.append(str(ioe))
    
    return "\n".join(out)
Example #3
0
import telebot
import logging
from rater import Rater
from typing import Dict, Union, List, Optional
from postgres_storage import PostgresStorage
from functions import get_str_env, get_int_env

rater = Rater()
postgres_storage = PostgresStorage()
bot = telebot.TeleBot(get_str_env('TOKEN'))

bot.send_message(
    get_int_env('ADMIN_ID'),
    'Бот запущен.',
)


@bot.message_handler(commands=['start'])
def start_message(message):
    def get_greeting(chat):
        name_parts: List[str] = []

        first_name: Optional[str] = chat.first_name
        if first_name is not None:
            name_parts.append(first_name)

        last_name: Optional[str] = chat.last_name
        if last_name is not None:
            name_parts.append(last_name)

        return ' '.join(name_parts)
Example #4
0
 def cleanup(self):
     # sys.stderr.write("cleanup called in thread {}\n".format(threading.get_ident()))
     Rater.exit_whole_program()
from pymetawear.client import MetaWearClient
from housepy import config, log
from rater import Rater
from monitor import MonitorSender

try:
    adapter = sys.argv[1]
    device_key = sys.argv[2]
    address = config['devices'][device_key]
except Exception as e:
    print(e)
    print("[ADAPTER#] [DEVICE#] --via config.yaml")
    exit()

monitor = MonitorSender(adapter, device_key)
rater = Rater(monitor)
log.info("Using %s to connect to %s..." % (adapter, address))

while True:
    try:
        c = MetaWearClient(address, 'pygatt', debug=False, adapter=adapter)
        log.info("--> MetaWear initialized: {0}".format(c))
        log.info(c.accelerometer)
        ## setup
        # c.accelerometer.set_settings(data_rate=100.0, data_range=2.0)
        # c.soft_reset()
        # c.disconnect()
        # time.sleep(4)
        # exit()
    except Exception as e:
        log.error(log.exc(e))
Example #6
0
# coding: utf-8
'''
Created on 27. apr. 2013

@author: H�kon
'''
from rater import  Rater

r = Rater();
r.add("TIØ4120 Operasjonsanalyse, grunnkurs")
r.add("TIØ4230 Entreprenørskap og markedsorientert produktutvikling")
r.add("TIØ5200 Prosjektorganisasjoner")
r.add("TIØ4146 Finans for teknisk-naturvitenskapelige studenter")
r.add("TMM4225 Ingeniørrettet samhandling i distribuerte team: Ledelse og smart bruk")
r.add("TPD4142 Design Thinking")
r.add("TTM4165 IKT, organisasjon og marked")
r.add("TDT4125 Algoritmekonstruksjon, videregående kurs")
r.add("TDT4171 Metoder i kunstig intelligens")
r.add("TDT4175 Informasjonssystemer")
r.add("TDT4190 Distribuerte systemer")
r.add("TDT4220 Ytelsesvurdering av datasystemer")
r.add("TDT4242 Kravspesifikasjon og testing")
r.add("TDT4300 Datavarehus og datagruvedrift")
r.add("TIØ4258 Teknologiledelse")
r.add("TDT4117 Informasjonsgjenfinning")
r.add("TDT4136 Logikk og resonnerende systemer")
r.add("TDT4186 Operativsystemer")
r.add("TDT4125 Algoritmekonstruksjon, videregående kurs")
r.add("TDT4171 Metoder i kunstig intelligens")
r.add("TDT4175 Informasjonssystemer")
r.add("TDT4190 Distribuerte systemer")