Beispiel #1
0
    def __init__(self, **kwargs):
        super(LatestView, self).__init__(**kwargs)
        Logger.info('LatestView: Initialized {}'.format(self))

        Clock.schedule_once(self.pr, 9)

        self.connn = Connector()
Beispiel #2
0
    def build(self):
        Logger.info('Application : Initialized {}'.format(self))

        self.root = BoxLayout(orientation='vertical')
        # self.root.size = (1300,1000)
        # self.root.add_widget(Progression())
        return self.root
Beispiel #3
0
    def on_noticed(self, user, channel, action):
        user = user.split('!')[0]
        if user == 'ChanServ':
            content = MDLabel(font_style='Body1',
                              theme_text_color='Secondary',
                              text=action,
                              size_hint_y=None,
                              valign='top')
            content.bind(texture_size=content.setter('size'))
            self.dialog = MDDialog(title="Notice: {}".format(user),
                                   content=content,
                                   size_hint=(.8, None),
                                   height=dp(200),
                                   auto_dismiss=False)

            self.dialog.add_action_button(
                "Dismiss", action=lambda *x: self.dialog.dismiss())
            self.dialog.open()
        else:
            self.msg_list.add_widget(
                MultiLineListItem(
                    text="[b][color=F44336]" + user + "[/color][/b] " + action,
                    font_style='Subhead',
                ))
            self.msg_list.parent.scroll_to(self.msg_list.children[0])
        Logger.info("IRC NOTICED: <%s> %s %s" % (user, channel, action))
Beispiel #4
0
 def __init__(self, **kwargs):
     super(ScanView, self).__init__(**kwargs)
     Logger.info('ScanView: Initialized {}'.format(self))
     self.llist = self.urls_list
     for it in self.llist:
         self.ids.scan_view_container.add_widget(
             Button(text='{}  {}'.format(it, self.llist[it]),
                    on_release=self.set_as_host))
Beispiel #5
0
 def get_start(self):
     if len(self.queue) > 0:
         idx, track = self.set_current_track(0)
         Logger.info('Starting playlist')
         return track
     else:
         Logger.info("Couldn't play, add tracks to playlist")
         return None
Beispiel #6
0
    def execute(self, action: Action):
        if self.view is None:
            Logger.info("Trying to load view in {controller}".format(controller=self))
            self.view = Builder.load_string(self.__view_string)

        self.update(action)

        return self
 def on_privmsg(self, user, channel, msg):
     user = user.split('!', 1)[0]
     self.msg_list.add_widget(
         MultiLineListItem(
             text=("[b][color=F44336]@" + user + "[/color][/b] " + msg),
             font_style='Subhead',
         ))
     Logger.info("IRC: <%s> %s" % (user, msg))
Beispiel #8
0
 def set_current_track(self, new_index):
     for track in self.queue:
         if 'playing' in track and track['playing']:
             track['playing'] = False
             break
     self.queue[new_index]['playing'] = True
     Logger.debug('set_current_track: Current track index set to ' +
                  str(new_index))
     return new_index, self.queue[new_index]
Beispiel #9
0
 def open(self, *largs):
     self._window = self._search_window()
     if not self._window:
         Logger.warning('ModalView: cannot open view, no window found.')
         return
     try:
         self._window.remove_widget(self)
         self._window.add_widget(self)
     except:
         pass
Beispiel #10
0
    def who_callback(self, nick_data):
        self.nick_data = nick_data
        nick_list = nick_data.keys()
        nick_list.sort()
        self.nick_list.clear_widgets()
        for nick in nick_list:
            list_item = MultiLineListItem(text=nick)
            list_item.bind(on_press=self.nick_details)
            self.nick_list.add_widget(list_item)

        Logger.info("IRC: <%s> -> nicks -> %s" % (self.text, nick_list))
Beispiel #11
0
 def send_message(self):
     Clock.schedule_once(self.update_irc_message_text)
     self.app.connection.msg("#" + self.text, self.irc_message.text)
     self.msg_list.add_widget(
         MultiLineListItem(
             text=("[b][color=1A237E]@" +
                   self.app.config.get('irc', 'nickname') +
                   "[/color][/b] " + self.irc_message.text),
             font_style='Subhead',
         ))
     nick = self.app.config.get('irc', 'nickname')
     Logger.info("IRC: <%s> %s" % (nick, self.irc_message.text))
Beispiel #12
0
    def update(self, action: Action):
        Logger.info(
            "Update in RoundResult with action {action}".format(action=action))
        if action is Action.EMPTY:

            game = Storage.get('game')

            scores = {}
            for team in game.teams.values():
                self.view.ids.command_win.text = team.name
                scores[team.number] = RoundHelper.get_scores_for_team(
                    game, team)
Beispiel #13
0
    def update(self, action: Action):
        records = self.get_records()
        Logger.info(repr(records))
        for index in range(0, 5):
            score = getattr(self.view.ids['rec_grid'],
                            'rec_s_' + str(index + 1))

            if index < len(records):
                score.ids['score'].text = str(records[index]['score'])
                score.ids['name'].text = str(records[index]['player'])
            else:
                score.ids['score'].text = '---'
                score.ids['name'].text = '---'
Beispiel #14
0
    def update(self, action: Action):
        Logger.info("Update in RoundController with action {action}".format(action=action))
        if action is Action.EMPTY:
            with Storage.update('game') as game:
                round_ = RoundHelper.get_ready(game)
                round_.state = RoundState.IN_PROGRESS
                round_.start_time = time.time()  # Start round

            self.start_clock()
            self.render_new()
            return

        if action is Action.SKIP:
            with Storage.update('game') as game:
                val = self.view.ids.val.val
                identifier = self.view.ids.identifier.val
                word_name = self.view.ids.word.text
                round_ = RoundHelper.get_active_round(game)
                round_.items.append(
                    {
                        "identifier": identifier,
                        "word": word_name,
                        "val": val,
                        "val_received": 0
                    }
                )
            self.render_new(list(map(lambda item: item['identifier'], round_.items)))
            return

        if action is Action.ACCEPT:
            with Storage.update('game') as game:
                val = self.view.ids.val.val
                identifier = self.view.ids.identifier.val
                word_name = self.view.ids.word.text
                round_ = RoundHelper.get_active_round(game)
                round_.items.append(
                    {
                        "identifier": identifier,
                        "word": word_name,
                        "val": val,
                        "val_received": val
                    }
                )
            self.render_new(list(map(lambda item: item['identifier'], round_.items)))
            return

        Logger.error(
            "Action {action} is not implemented in controller {controller}"
                .format(action=action, controller=self)
        )
        raise NotImplemented
Beispiel #15
0
    def __init__(self, **kwargs):
        super(Connector, self).__init__(**kwargs)
        Logger.info('Connector: Initialized {}'.format(self))

        # self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if self.url:
            self.host = self.url
            print(self.host)
        else:
            self.host = '192.168.0.10'
        self.port = 8000
        self.server_state = True

        self.connects(self.host, self.port)
Beispiel #16
0
    def __init__(self, **kwargs):
        super(ViewControl, self).__init__(**kwargs)
        Logger.info('ViewControl: Initialized {}'.format(self))
        # self.add_widget(Progression(name='loading'))
        # self.add_widget(MainView(name='main'))

        self._url = []
        # self.start_loading_screen()
        self.t1 = threading.Thread(name="Hello1",
                                   target=self.start_loading_screen())
        self.t1.start()

        self.t2 = threading.Thread(target=self.scanner)
        self.t2.start()
Beispiel #17
0
    def scanner(self, *args):
        # Logger.info('entered scanner for {}'.format(threading.currentThread().getName()))
        for _subnet in range(1, 15):
            Logger.info('Scanner for {}'.format(_subnet))
            network = '192.168.0.{}'.format(_subnet)
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            socket.setdefaulttimeout(0.1)

            try:
                _socker = sock.connect_ex((network, 8000))

                if _socker == 0:
                    Logger.info('Found online at {}'.format(network))
                    responded_msgs = sock.recv(2048)
                    ScanView.urls_list[network] = str(responded_msgs.decode())
                else:
                    Logger.info('{} responded {}'.format(network, _socker))
            except PermissionError:
                print('permission')
            except ConnectionRefusedError:
                print('Refused')
            finally:
                sock.close()
                Logger.info('Current :{} Exiting'.format(
                    threading.currentThread().getName()))
Beispiel #18
0
    def get_previous_track(self):
        old_index, current_track = self.get_current_track()
        new_index = int(old_index) - 1

        if current_track:
            if new_index >= 0:
                idx, track = self.set_current_track(new_index)
                return track
            else:
                Logger.info(
                    'No previous track, playing first track of playlist')
                return None  # no previous tracks in playlist
        else:
            Logger.debug('Stopped playing because of error above')
Beispiel #19
0
 def send_action(self):
     Clock.schedule_once(self.update_irc_action_text)
     self.app.connection.sendLine(self.irc_action.text.strip('/'))
     self.msg_list.add_widget(
         MultiLineListItem(
             text="[b][color=1A237E]" +
             self.app.config.get('irc', 'nickname') + "[/color][/b] " +
             self.irc_action.text,
             font_style='Subhead',
         ))
     self.msg_list.parent.scroll_to(self.msg_list.children[0])
     Logger.info(
         "IRC: <%s> %s" %
         (self.app.config.get('irc', 'nickname'), self.irc_action.text))
    def on_fullscreen(self, instance, value):
        window = self.get_parent_window()
        if not window:
            Logger.warning('AliveVideoPlayer: Cannot switch to fullscreen, window not found.')
            if value:
                self.fullscreen = False
            return
        if not self.parent:
            Logger.warning('AliveVideoPlayer: Cannot switch to fullscreen, no parent.')
            if value:
                self.fullscreen = False
            return

        if value:
            self._fullscreen_state = state = {
                'parent': self.parent,
                'pos': self.pos,
                'size': self.size,
                'pos_hint': self.pos_hint,
                'size_hint': self.size_hint,
                'window_children': window.children[:]}

            # remove all window children
            for child in window.children[:]:
                window.remove_widget(child)

            # put the video in fullscreen
            if state['parent'] is not window:
                state['parent'].remove_widget(self)
            window.add_widget(self)

            # ensure the video widget is in 0, 0, and the size will be
            # reajusted
            self.pos = (0, 0)
            self.size = (100, 100)
            self.pos_hint = {}
            self.size_hint = (1, 1)
        else:
            state = self._fullscreen_state
            window.remove_widget(self)
            for child in state['window_children']:
                window.add_widget(child)
            self.pos_hint = state['pos_hint']
            self.size_hint = state['size_hint']
            self.pos = state['pos']
            self.size = state['size']
            if state['parent'] is not window:
                state['parent'].add_widget(self)
Beispiel #21
0
    def get_current_track(self):
        for index, track in enumerate(self.queue):
            if 'playing' in track and track['playing']:
                # if 'index' in track:
                #     Logger.debug('get_current_track: Current track index is ' + str(track['index']))
                #     return track['index'], track
                # else:
                #     Logger.error('get_current_track: Current track has no index property')
                #     # TODO: Why does the track have no index? ListView problem of kivy?
                #     return -1, None

                Logger.debug('get_current_track: Current track index is ' +
                             str(index))
                return index, track

        Logger.debug('No current track')
        return -1, None
Beispiel #22
0
    def progression_bar(self, *args):
        # Logger.info('Progression: Progress Bar progress {}'.format(self.ids.pb.value))

        # print(self.ids.zz.size_hint_x)
        if self.ids.pb.value < 100:
            self.ids.pb.value += 1
            # self.ids.dynamic_progress.size_hint_x += 0.01
            # self.ids.static_progress.size_hint_x -= 0.01
            # self.ids.dv.size_hint_x -= 0.01
            self.ids.dv.opacity -= 0.01
            self.ids.dd.opacity += 0.01
        else:
            Logger.info('Progression: Progress bar scheduler event stopped')

            self.sch_event.cancel()
            print('vsvdsvsvasvavasdv')
            print(self.parent)
            self.parent.children[0].size_hint_y = 1
            self.parent.children[0].opacity = 1
Beispiel #23
0
    def progression_bar(self, *args):
        # Logger.info('Progression: Progress Bar progress {}'.format(self.ids.pb.value))

        # print(self.ids.zz.size_hint_x)
        if self.ids.pb.value < 100:
            self.ids.pb.value += 1
            # self.ids.dynamic_progress.size_hint_x += 0.01
            # self.ids.static_progress.size_hint_x -= 0.01
            # self.ids.dv.size_hint_x -= 0.01
            self.ids.dv.opacity -= 0.01
            self.ids.dd.opacity += 0.01
        else:
            Logger.info('Progression: Progress bar scheduler event stopped')

            self.sch_event.cancel()

            self.manager.switch_to(ScanView(),
                                   transition=FadeTransition(),
                                   duration=1)
Beispiel #24
0
 def on_usr_action(self, user, channel, quit_message, action):
     if action == 0:
         self.msg_list.add_widget(
             MultiLineListItem(
                 text=("[color=9C27B0]" + user + "[/color] has joined #" +
                       self.text),
                 font_style='Subhead',
             ))
         Logger.info("IRC: %s -> %s" % (user, 'joined'))
     elif action == 1:
         self.msg_list.add_widget(
             MultiLineListItem(
                 text=("[color=9C27B0]" + user + "[/color] has left #" +
                       self.text),
                 font_style='Subhead',
             ))
         Logger.info("IRC: %s <- %s" % (user, 'left'))
     elif action == 2:
         self.msg_list.add_widget(
             MultiLineListItem(
                 text=("[color=9A2FB0]" + user + "[/color] has quit &bl;" +
                       quit_message + "&bt;"),
                 font_style='Subhead',
             ))
         Logger.info("IRC: %s <- %s" % (user, 'quit'))
     self.app.connection.who(self.text).addCallback(self.who_callback)
Beispiel #25
0
    def get_next_track(self):
        if self.shuffle:
            if len(self.queue) > 0:
                idx, track = self.set_current_track(
                    random.randrange(0,
                                     len(self.queue)))  # return random index
                return track
            else:
                return None  # no tracks in playlist
        else:
            old_index, current_track = self.get_current_track()

            if current_track and old_index >= 0:  # -1 if track had no index property (error)(should be fixed / No track was playing
                new_index = int(old_index) + 1
                if new_index < len(self.queue):
                    idx, track = self.set_current_track(new_index)
                    return track
                else:
                    Logger.info('Reached end of playlist')
                    return None  # no more tracks in playlist
            else:
                Logger.debug('Stopped playing because of error above')
                return None
Beispiel #26
0
    def add_track(self, track, position=False):
        Logger.info('Adding track to playlist: ' + track['title'])
        Logger.debug('Track type:' + str(type(track)))
        if position:
            self.queue.insert(position, track)
        else:
            self.queue.append(track)

        Logger.debug('Playlist length: ' + str(len(self.queue)))
Beispiel #27
0
    def configure_rounds(self):
        for r_number in range(0, self.rounds_count):
            for t_number, team in self.teams.items():
                for p_number in "12":
                    round_ = Round()
                    round_.duration = self.round_duration
                    round_.number = '{rounds}_{teams}_{players}'.format(
                        rounds=r_number, teams=t_number, players=p_number)
                    self.rounds[round_.number] = round_

        Logger.info("Game configured")
        Logger.info("   Rounds: {c}".format(c=len(self.rounds)))
        Logger.info("   Teams: {c}".format(c=len(self.teams)))
Beispiel #28
0
 def __init__(self, **kwargs):
     super(ViewControl, self).__init__(**kwargs)
     Logger.info('ViewControl: Initialized {}'.format(self))
     self.start_loading_screen()
Beispiel #29
0
 def peripheral_service_error(self, service, error):
     Logger.error('Peripheral: service error: {}: {}'.format(error, service))
Beispiel #30
0
    def __init__(self, **kwargs):
        super(Progression, self).__init__(**kwargs)
        Logger.info('Progression: Initialized {}'.format(self))

        self.sch_event = Clock.schedule_interval(self.progression_bar, 1 / 10)
Beispiel #31
0
 def discover(self, device):
     if device.age < 0.1:
         Logger.info('Central: {}'.format(device))
Beispiel #32
0
 def on_irc_connection(self, connection):
     Logger.info("IRC: connected successfully!")
     self.connection = connection
     for screen in self.scr_mngr.screens:
         screen.__post_connection__(self.connection)
Beispiel #33
0
 def handle_exception(self, inst):
     Logger.exception('Exception caught by ExceptionHandler')
     return ExceptionManager.PASS
Beispiel #34
0
 def char_write(self, service, characteristic):
     Logger.info('Peripheral: write to characteristic: {}'.format(characteristic.value))
Beispiel #35
0
 def peripheral_service_added(self, service):
     Logger.info('Peripheral: service added: {}'.format(service))
Beispiel #36
0
 def peripheral_adv(self, error=None):
     if error:
         Logger.error('Peripheral: advertisement failed: {}'.format(error))
     else:
         Logger.info('Peripheral: advertising started')
     self.advertising = ble_peripheral.is_advertising