Exemple #1
0
 def Enable(self) -> None:
     self.PushObject(self._current_area_label)
     self.PushObject(self._current_player_label)
     self.PushObject(self._send_button)
     self.PushObject(self._settings_button)
     self.PushObject(self._quit_button)
     self._client = Client()
 def __init__(self):
     """
     In constructor program arguments are parsed and client is prepared
     """
     arguments = self.parseArgs()
     self.client = Client(configFile=arguments.config,
                          limit=arguments.limit,
                          register=arguments.register)
class Application(object):
    """
    Main application class. It parses parameters and run client
    """
    version = '1.0'

    def __init__(self):
        """
        In constructor program arguments are parsed and client is prepared
        """
        arguments = self.parseArgs()
        self.client = Client(configFile=arguments.config,
                             limit=arguments.limit,
                             register=arguments.register)

    def parseArgs(self):
        """
        Parses all parameters given to the application during running it

        :return: returns data of all parsed parameters
        """
        parser = argparse.ArgumentParser(prog='resmon-client')
        parser.add_argument(
            '-c',
            '--config',
            type=str,
            default='./data/config.json',
            help='Location where is stored JSON configuration file')
        parser.add_argument(
            '-l',
            '--limit',
            type=int,
            default=10,
            help='Maximal limit of displayed hosts for every metric')
        parser.add_argument('--register',
                            action='store_true',
                            help='If it\'s set, then user can be registered \
            at start of the application. \
            In other case user has to be logged before using this.')
        parser.add_argument('-v',
                            '--version',
                            action='version',
                            version=('ResMon client ' + Application.version))
        return parser.parse_args()

    def run(self):
        """
        Client is started

        :return: returns None
        """
        self.client.run()
Exemple #4
0
def get_stats(usernames, playlist, platform = 'pc'):

    if not isinstance(usernames, list):
        usernames = [usernames]

    client = Client()
    stats_friends = []
    try:
        for x in usernames:
            response = client.send_request(platform, x.lower())
            stats_friends.append(response[0][playlist])
    except Exception as e:
        print(e)
    return stats_friends
Exemple #5
0
def get_squad_stats(usernames, platform='psn'):

    if not isinstance(usernames, list):
        usernames = [usernames]

    client = Client()
    stats_friends = []
    try:
        for x in usernames:
            response = client.send_request(platform, x.lower())
            stats_friends.append(response[0]['p9'])
    except Exception:
        ''

    return stats_friends
Exemple #6
0
def main():
    client = Client()
    wrangler = Wrangler()
    wrangler.start()

    ui = UI(
    )  # Start all threads before here (since UI is an infinite loop run on this thread)
Exemple #7
0
def get_all_stats(usernames, platform = 'pc'):
    all_stats = []
    playlist = ['p2','p10','p9']

    if not isinstance(usernames, list):
        usernames = [usernames]
    client = Client()
    stats_friends = []
    try:
        for i in range(3):
            for x in usernames:
                response = client.send_request(platform, x.lower())
                all_stats.append(response[0][playlist[i]])
    except Exception:
        ''
    return all_stats
Exemple #8
0
from src.Client import Client
import json

with open('data/config.json') as json_data_file:
    data = json.load(json_data_file)
    token = data['discord']['token']

client = Client()
client.run(token)
 def __build_client(self, transport):
     return Client(transport)
Exemple #10
0
import os
import time

from src.Client import Client
import functions as fun

cliente = Client()


def principal_cli():
    func = fun.functionsADM()
    trigger = 0

    while trigger == 0:
        login = func.open()

        if login == "open":
            trigger = 1
            print('\033[32m' + "=========Bem-Vindo=========== " + '\033[0;0m')
        else:
            print('\033[31m' + "Login inválido" + '\033[0;0m')

    while True:
        time.sleep(2)
        os.system("cls")
        print(" === MÓDULO CLIENTE === ")
        print("1 - Cadastrar Banco ou Fintech")
        print("2 - Editar Cadastro")
        print("3 - Listar Banco ou Fintech")
        print("4 - Voltar para o menu principal")
        opcao = int(input("Digite o Opção Desejada:"))
Exemple #11
0
"""
Written by
Noam Solan - 204484703
Yarin Kimhi - 308337641
"""

from options.ClientOptions import client_params, logging_level
from src.Client import Client
from src.Logger import Logger

Client(Logger(logging_level), **client_params).init_game()
Exemple #12
0
class Game(engine.Scene):
    def __init__(self):
        super().__init__()
        self._cols = 20
        self._rows = 20
        self._scale = 20
        self._matrix = engine.Matrix(self._cols, self._rows)
        self._matrix[0] = 1
        self._matrix[len(self._matrix) - 1] = 2

        self._was_cut = False
        self._is_cutting = False
        self._start_cut_pos = [0, 0]
        self._end_cut_pos = [0, 0]
        self._mesh = Mesh(self._cols, self._rows, self._scale)

        self._matrix_copy = [0] * len(self._matrix)

        self._current_player = 1
        self._current_area = randint(1, 10)
        self._count_of_turns = 2

        self._current_area_label = engine.Label(
            x=650, y=200, text=f"Current area is {self._current_area}.")

        self._current_player_label = engine.Label(
            x=650, y=100, text=f"{self._current_player}'s player turn.")

        self._send_button = engine.Button(x=650,
                                          y=300,
                                          text="Send",
                                          width=150,
                                          height=50)
        self._send_button.BindCallback(self.SendMessage)

        self._settings_button = engine.Button(x=650,
                                              y=400,
                                              width=150,
                                              height=50,
                                              text="Settings")
        self._settings_button.BindCallback(
            engine._scene_factory.SetCurrentScene, ["settings_menu"])

        self._quit_button = engine.Button(x=650,
                                          y=500,
                                          width=150,
                                          height=50,
                                          text="Quit")
        self._quit_button.BindCallback(self.Quit)

    def Enable(self) -> None:
        self.PushObject(self._current_area_label)
        self.PushObject(self._current_player_label)
        self.PushObject(self._send_button)
        self.PushObject(self._settings_button)
        self.PushObject(self._quit_button)
        self._client = Client()

    def Update(self) -> None:
        super().Update()
        self.Cut()
        self._mesh.Update()
        self.CutTerritory()

        self._current_player_label._text = f"{self._current_player}'s player turn."
        self._current_player_label.SetTextStyle()

        self._current_area_label._text = f"Current area is {self._current_area}."
        self._current_area_label.SetTextStyle()

        if (self._matrix.count(0) == 0):
            self.GameOver()

    def Render(self) -> None:
        self._mesh.RenderMatrix(self._matrix)
        self._mesh.Render()
        super().Render()

    def Disable(self) -> None:
        del self

    def Cut(self) -> None:
        self._was_cut = self._is_cutting
        self._is_cutting = pygame.mouse.get_pressed()[0]

        if (not self._was_cut and self._is_cutting):
            self._start_cut_pos = pygame.mouse.get_pos()
        elif (self._was_cut and not self._is_cutting):
            self._end_cut_pos = pygame.mouse.get_pos()

    def CutTerritory(self) -> None:
        if (self._count_of_turns > 0):
            if (self._was_cut and not self._is_cutting and \
            self._mesh._in_rect and self._current_player == 1):

                mpos = self._mesh.GetMatrixPos(self._start_cut_pos,
                                               self._end_cut_pos)
                code = self._matrix.FillRect(*mpos, self._current_area)
                print(code)
                if (code == 1): self._count_of_turns -= 1

    def GameOver(self) -> None:
        # TODO: Подвести итоги
        engine._server = None
        engine._player = None
        _max = max(self._matrix.count(1), self._matrix.count(2))
        if (_max == 2):
            print("Player 2 win. You ЛОХ!")
        else:
            print("НИХЕРАСИБЕ. Ты победил.")
        engine._scene_factory.SetCurrentScene("start_menu")

    def SendMessage(self) -> None:
        if (self._current_player == 1):
            self._current_player = 2
            self._count_of_turns = 0
            self._current_player_label._text = f"{self._current_player}'s player turn."
            self._current_player_label.SetTextStyle()
            self._client.SendMessage([self._matrix, randint(1, 10)])

    def Quit(self) -> None:
        self.__init__()
        if (engine._server != None):
            engine._server._sock.close()
        engine._scene_factory.SetCurrentScene("start_menu")
Exemple #13
0
def main():
    header_program()
    client = Client()
    client.start()
Exemple #14
0
import sys
from src.Server import Server
from src.Client import Client

if len(sys.argv) > 1:
    client = Client(sys.argv[1], sys.argv[2])
    client.run()
else:
    server = Server()
    server.run()
Exemple #15
0
from src.Client import Client

Client().run()