Beispiel #1
0
 def __init__(self,
              arrmenu=[
                  "Menu:",
                  "Ipconfig",
                  "Set Date",
                  "Set Mask",
                  "set GateWay",
              ]):
     self.power = Power()
     self.screen = Screen()
     self.info = self.screen.get_info()
     self.keyboard = KeyBoard(5, 6, 26, 22)
     self.strmenu = arrmenu
     self.menu_index = 0
     self.state = 'FIRSTPAGE'
     self.list_gateway = []
     self.marker = 0
     self.list_mask = []
     self.list_addr = []
     self.x = []
     self.list_date = self.info[1]
     self.marker = 0
     self.cmd1 = ''
     self.cmd2 = ''
     self.cmd3 = ''
     self.cmd4 = ''
     self.cmd5 = ''
Beispiel #2
0
def start_keyboard(additional):
    KB = KeyBoard('false', 1)
    for n in ['Регистрация']:
        KB.add_button(n, 'green', '{}')
    for n in additional:
        KB.add_button(n[2], 'green', '{}')
    return KB.get_button()
Beispiel #3
0
    def step(self, action, window, reminisce=False, delay=0):

        delta = self.keyboard.getTransformation(action)
        tile = Tile(self.player.x + delta[0], self.player.y + delta[1],
                    self.seed)
        self.player.tile = tile
        walkable = self.world.walkable(tile)

        if KeyBoard.up(action) and walkable:
            self.player.moveNorth()

        elif KeyBoard.left(action) and walkable:
            self.player.moveWest()

        elif KeyBoard.down(action) and walkable:
            self.player.moveSouth()

        elif KeyBoard.right(action) and walkable:
            self.player.moveEast()

        elif not reminisce and KeyBoard.newGame(action):
            window.showLoading()
            self.new()

        elif not reminisce and KeyBoard.exit(action):
            window.close()
            sys.exit(0)

        time.sleep(delay)
Beispiel #4
0
def help(body, peer_id, from_id):
    message = vkMessage('')
    KB = KeyBoard()
    if body:
        for i in command_system.command_list:
            if re.match(i.keys,body):
                message.message, message.keyboard = i.deephelp()
    else:
        message.message = 'Привет, студент!\n\
        Я Ваня Формин, бот-справочник СПбГУТ, который поможет тебе ответить на многие вопросы.\n\n\
        Для того, чтобы я реагировал на твои команды, тебе потребуется обратиться ко мне как "Информ" или "Ваня".\n\n\
        Вот список моих команд:\n'
        for i in command_system.command_list:
            if i.description:
                message.message += ' • ' + i.description + '\n'
                label = re.match('.*?\s',i.description).group(0)
                KB.addButton(label,'white','{}')
        message.message +'\nТакже отвечаю на частозадаваемые вопросы (Ваня, помощь частозадаваемые)\n'
        message.message += '\nЧтобы вызвать подсказку по одной из этих команд, напиши "Ваня, помощь *команда*" или просто "Ваня, *команда*"'
    message.message += '\n\nУвидел ошибку, есть предложение, хочешь сказать спасибо разрабу?\nИспользуй команду "Ваня, репорт *текст сообщения*"'
    message.keyboard = KB.getButton()
    return message
Beispiel #5
0
from keyboard import KeyBoard
from observable import Observable
from observer import Observer
from actor import Actor

if __name__ == '__main__':
    observable = Observable()
    keyBoard = KeyBoard()
    actor = Actor()
    observable.register(actor)
    while 1:
        observable.update_observers(c=keyBoard.get_ch())
Beispiel #6
0
def cancel_keyboard():
    KB = KeyBoard('false', 1)
    KB.add_button('Отмена', 'red', '{}')
    return KB.get_button()
Beispiel #7
0
def main_menu_keyboard():
    KB = KeyBoard('true', 1)
    KB.add_button('Мероприятия', 'green', '{}')
    for n in ['Жалоба', 'Обратная связь', 'Коллективная жалоба']:
        KB.add_button(n, 'white', '{}')
    return KB.get_button()
Beispiel #8
0
def hostel_keyboard():
    KB = KeyBoard('false', 2)
    for n in hostels[1:]:
        KB.add_button(n, 'white', '{}')
    return KB.get_with_person_button('Другое')
Beispiel #9
0
def faculty_keyboard():
    KB = KeyBoard('false', 2)
    for n in faculties:
        KB.add_button(n, 'white', '{}')
    return KB.get_with_person_button('Отмена')
Beispiel #10
0
            y = "%02d/%02d/%02d" % (date[0], date[1], date[2])
            z = "%02d:%02d" % (date[3], date[4])
            datetime = y + ' ' + z
            setcursor = [0, 1, 3, 4, 6, 7, 9, 10, 12, 13]
            self.marker = setcursor[self.marker]
            setmenu.append(datetime)
            self.screen.display(setmenu, self.marker, 3)
            self.cmd1 = "sudo date -s %s" % y
            self.cmd2 = "sudo date -s %s" % z
        else:
            pass


if __name__ == "__main__":
    screen = Screen()
    keyboard = KeyBoard()
    power = Power()
    main = Main([
        "Ipconfig", "Set Date", "Set Mask", "set GateWay", "Save", "Save",
        "Save", "Save", "Save", "Save"
    ])
    info = screen.get_info()
    screen.display(info)
    ip_underline = 0
    try:
        while True:
            r = power.is_reset_still_down()
            if r is True:
                cmd6 = "sudo shutdown -h now"
                main.inip_os(cmd6)
            else:
Beispiel #11
0
 def __init__(self):
     super(Game, self).__init__()
     self.keyboard = KeyBoard()
     self.world = World()
     self.player = Player()
     self.seed = None
Beispiel #12
0
class Game(object):
    """docstring for Game"""
    def __init__(self):
        super(Game, self).__init__()
        self.keyboard = KeyBoard()
        self.world = World()
        self.player = Player()
        self.seed = None

    def new(self):

        self.seed = str(uuid.uuid4())
        moves = open('moves.json', 'w')
        moves.write(str(list()))  # Write an empty list to moves.json
        self.world.new(self.seed)
        self.player.new(self.seed)

    def load(self):

        try:
            state = defaultdict(dict, json.load(open('state.json', 'r')))
            self.seed = state['seed']
            self.world.load(state['world'], self.seed)
            self.player.load(state['player'], self.seed)
        except FileNotFoundError as e:  # On the game's first run, the state and moves json wont exist, so just generate a new world and player
            self.new()

    def save(self, move):
        save_state = {
            'seed': self.seed,
            'player': {
                'x': self.player.x,
                'y': self.player.y,
                'turns': self.player.turns,
                'days': self.player.days,
                'tiredness': self.player.tiredness,
                'inventory': self.player.inventory.inventory,
            },
            'world': {
                'rep': self.world.rep,
                'cities': self.world.cities,
            },
        }

        json.dump(save_state, open("state.json", "w"))

        # Get the moves list from moves.json, append the new move, and then save it to moves.json again.
        try:
            moves = json.load(open('moves.json', 'r'))
        except FileNotFoundError as e:
            moves = []

        moves.append(move)
        json.dump(moves, open("moves.json", "w"))

    def getMoves(self):

        try:
            moves = json.load(open('moves.json', 'r'))
        except FileNotFoundError as e:
            moves = []
        return moves

    def reminisce(self, window):

        moves = self.getMoves()
        world = self.world
        player = self.player
        player.x = 100
        player.y = 100
        for action in moves:

            view = world.getView(window.getMapRadius(), player)
            window.update(
                map_view=view,
                player=player,
                message=
                "You look back on your life and realise how little you have accomplished"
            )
            self.step(action, reminisce=True, delay=0.006)

    def step(self, action, window, reminisce=False, delay=0):

        delta = self.keyboard.getTransformation(action)
        tile = Tile(self.player.x + delta[0], self.player.y + delta[1],
                    self.seed)
        self.player.tile = tile
        walkable = self.world.walkable(tile)

        if KeyBoard.up(action) and walkable:
            self.player.moveNorth()

        elif KeyBoard.left(action) and walkable:
            self.player.moveWest()

        elif KeyBoard.down(action) and walkable:
            self.player.moveSouth()

        elif KeyBoard.right(action) and walkable:
            self.player.moveEast()

        elif not reminisce and KeyBoard.newGame(action):
            window.showLoading()
            self.new()

        elif not reminisce and KeyBoard.exit(action):
            window.close()
            sys.exit(0)

        time.sleep(delay)
Beispiel #13
0
            img_dirs.append(subpath)


if args.img is not None:
    if args.style == 'key':
        modelproduct = ModelProduct()
        input_imgs = []
        img = Image.open(args.img)
        input_imgs.append(img)
        if args.type == 'black':
            pred = modelproduct.detect_black_keys(input_imgs, debug=True)
        else:
            pred = modelproduct.detect_white_keys(input_imgs, debug=True)
        print(pred)
    else:
        keyboard = KeyBoard()
        img = Image.open(args.img)
        keyboard.detect_keyboard(img)

if args.img_dir is not None:
    if args.model_dir is not None:
        img_lists = []
        list_img_dir(args.img_dir, img_lists)
        model_files = list_models(args.model_dir)
        for model_file in model_files:
            if args.type == 'black':
                modelproduct = ModelProduct(black_model_file=model_file)
            else:
                modelproduct = ModelProduct(white_model_file=model_file)
            count = 0
            for img_path in tqdm(img_lists):
 def init_model_load(self, white_model=None, black_model=None):
     self.keyboard = KeyBoard()
     self.hand_seg = SegHand()
     self.modelproduct = ModelProduct(white_model, black_model)
     self.bwlabel = BwLabel()