예제 #1
0
def remove_recent_play(appid, conf_db):
    if os.path.exists(conf_db):
        data = utils.load_db(conf_db)
        recent_list = data.get('recent')
        if recent_list and appid in recent_list:
            data['recent'].remove(appid)
            utils.save_db(data, conf_db)
 def save(self):                    
     if not self.collect_view.items:
         return
     items = []
     for item in self.collect_view.items:
         items.append(item.get_tags())
     utils.save_db(items, get_config_file("favorite_webcasts.db"))    
예제 #3
0
def remove_favorite(appid, conf_db):
    if os.path.exists(conf_db):
        data = utils.load_db(conf_db)
        favorite_list = data.get('favorite')
        if favorite_list and appid in favorite_list:
            data['favorite'].remove(appid)
            utils.save_db(data, conf_db)
    def load(self):
        try:
            objs = utils.load_db(self.listen_db_file)
            (current_playing_item,
                (playing_list_song, playing_list_songs),
                (personal_fm_song, personal_fm_songs)) = objs
            if current_playing_item == 'playing_list':
                self.current_playing_item = self.playing_list_item
                self.last_song = Song(playing_list_song)
            elif current_playing_item == 'personal_fm':
                self.current_playing_item = self.personal_fm_item
                self.last_song = Song(personal_fm_song)
            else:
                self.current_playing_item = None
                self.last_song = None
            self.playing_list_item.add_songs([Song(song) for song in
                playing_list_songs])
            if nplayer.is_login:
                self.personal_fm_item.add_songs([Song(song) for song in
                    personal_fm_songs])

        except:
            self.last_song = None
            utils.save_db(None, self.listen_db_file)
            return
 def save(self):
     obj = dict(bduss=self.bduss,
                username=self.username,
                uid=self.uid,
                flag=self.flag,
                level=self.level)
     utils.save_db(obj, self.config_db)
 def save(self):
     local_lists = filter(
         lambda item: item.list_type == MusicListItem.LOCAL_TYPE,
         self.items)
     if len(local_lists) > 0:
         objs = [item.dump_list() for item in local_lists]
         utils.save_db(objs, self.listen_db_file)
예제 #7
0
 async def reset(self, ctx):
     data = utils.read_db()
     reset_value = data['start-money']
     for key in data['users'].keys():
         data['users'][key] = reset_value
     utils.save_db(data)
     await ctx.send(f'Všem hráčům byly resetovány peníze na {reset_value}.')
예제 #8
0
    async def platba(self, ctx, user: discord.User = None, value: int = 0):
        user1_id = str(ctx.message.author)
        user2_id = str(user)
        data = utils.read_db()
        channel = self.bot.get_channel(int(Config.LOG_CHANNEL))
        if user == ctx.message.author:
            await ctx.send('Nemůžeš poslat peníze sám sobě.')
        elif value < 0:
            await ctx.send(f'Hráč {ctx.message.author.mention} se pokusil \
okrást hráče {user.mention}!')
            await channel.send(f'{ctx.message.author.mention} se pokusil při \
platbě zadat zápornou částku.')
        elif value > data['users'][user1_id]:
            await ctx.send(
                f'Hráč {ctx.message.author.mention} nemá dostatečný \
počet peněz, aktuálně má {data["users"][user1_id]} peněz.')
            await channel.send(f'{ctx.message.author.mention} se pokusil při \
platbě zadat vyšší částku, než má.')
        else:
            data['users'][user1_id] -= value
            new_value1 = data['users'][user1_id]
            data['users'][user2_id] += value
            new_value2 = data['users'][user2_id]
            utils.save_db(data)
            await ctx.send(f'Hráči {user.mention} bylo posláno {value} peněz, \
hráč {ctx.message.author.mention} má nyní {new_value1} peněz a hráč \
{user.mention} má nyní {new_value2} peněz.')
            await channel.send(f'Úspěšně provedena platba hráčem \
{ctx.message.author.mention} hráči {user.mention}.')
예제 #9
0
 def save(self):
     if not self.collect_view.items:
         return
     items = []
     for item in self.collect_view.items:
         items.append(item.get_tags())
     utils.save_db(items, get_config_file("favorite_webcasts.db"))
 def save(self):
     obj = dict(bduss=self.bduss,
                username=self.username,
                uid=self.uid,
                flag=self.flag,
                level=self.level)
     utils.save_db(obj, self.config_db)
예제 #11
0
 def save(self):    
     if not self.__dirty:
         return True
     
     songs = []
     with self.keep_operation():
         songs = self.__songs.values()
         
     objs = [ song.get_dict() for song in songs if song not in self.__hiddens ]    
     utils.save_db(objs, get_config_file(self.__user_save_db))
     self.__dirty = False
 def save(self, *args):
     songs = self.playing_list_item.song_view.dump_songs()
     song = self.current_item.current_song
     if song:
         utils.save_db((song.get_dict(),
             songs, self.playing_list_item.song_view.playback_mode),
             self.listen_db_file)
     else:
         utils.save_db((None, songs,
             self.playing_list_item.song_view.playback_mode),
             self.listen_db_file)
예제 #13
0
    async def pripsat(self, ctx, user: discord.User = None, value: int = 0):
        user_id = str(user)
        data = utils.read_db()
        if user_id in data['users'].keys():
            data['users'][user_id] += value
        else:
            data['users'][user_id] = data['start-money'] + value
        new_value = data['users'][user_id]
        utils.save_db(data)
        await ctx.send(f'Hráči {user.mention} bylo připsáno {value} peněz, \
nyní má {new_value} peněz.')
예제 #14
0
    async def penize(self, ctx):
        user_id = str(ctx.message.author)
        data = utils.read_db()
        if user_id in data['users'].keys():
            value = data['users'][user_id]
        else:
            value = data['start-money']
            data['users'][user_id] = value
            utils.save_db(data)

        await ctx.send(f'Hráč {ctx.message.author.mention} má {value} peněz.')
예제 #15
0
    async def kontrola(self, ctx, user: discord.User = None):
        user_id = str(user)
        data = utils.read_db()
        if user_id in data['users'].keys():
            value = data['users'][user_id]
        else:
            value = data['start-money']
            data['users'][user_id] = value
            utils.save_db(data)

        await ctx.send(f'Hráč {user.mention} má {value} peněz.')
 def save(self):    
     if not self.__dirty:
         return True
     
     songs = []
     with self.keep_operation():
         songs = self.__songs.values()
         
     objs = [ song.get_dict() for song in songs if song not in self.__hiddens ]    
     utils.save_db(objs, get_config_file(self.__user_save_db))
     self.__dirty = False
    def save_status(self, *args):
        index = 0
        player_source = Player.get_source()
        for i, item in enumerate(self.category_list.get_items()):
            if item.song_view == player_source:
                index = i

        try:
            song = self.current_item.current_song
            utils.save_db((index, song.get_dict()), self.status_db_file)
        except:
            pass
    def save_status(self, *args):
        index = 0
        player_source = Player.get_source()
        for i, item in enumerate(self.category_list.get_items()):
            if item.song_view == player_source:
                index = i

        try:
            song = self.current_item.current_song
            utils.save_db((index, song.get_dict()), self.status_db_file)
        except:
            pass
예제 #19
0
    async def odebrat(self, ctx, user: discord.User = None, value: int = 0):
        user_id = str(user)
        data = utils.read_db()
        if user_id in data['users'].keys():
            new_value = data['users'][user_id] - value
        else:
            new_value = data['start-money'] - value
        if new_value < 0:
            new_value = 0
        data['users'][user_id] = new_value
        utils.save_db(data)
        await ctx.send(f'Hráči {user.mention} bylo odebráno {value} peněz, \
nyní má {new_value} peněz.')
예제 #20
0
def record_favorite(appid, conf_db):
    if os.path.exists(conf_db):
        data = utils.load_db(conf_db)
        favorite_list = data.get('favorite')
        if favorite_list:
            if appid in favorite_list:
                data['favorite'].remove(appid)
            data['favorite'].insert(0, appid)
        else:
            data['favorite'] = [appid]
    else:
        data = dict(recent=[appid])

    utils.save_db(data, conf_db)
예제 #21
0
def record_recent_play(appid, conf_db):
    if os.path.exists(conf_db):
        data = utils.load_db(conf_db)
        recent_list = data.get('recent')
        if recent_list:
            if appid in recent_list:
                data['recent'].remove(appid)
            data['recent'].insert(0, appid)
        else:
            data['recent'] = [appid]
    else:
        data = dict(recent=[appid])

    utils.save_db(data, conf_db)
    utils.ThreadMethod(utils.send_analytics, ('play', appid)).start()
예제 #22
0
 def save(self):    
     if not self.__dirty:
         return True
     
     # Quickly copy obj before pickle it
     self.__db_operation_lock.acquire()
     songs = self.__songs.values()
     playlists = self.__playlists["local"][:]
     self.__db_operation_lock.release()
     objs = [ song.get_dict() for song in songs if song.get_type() in self.__save_song_type ]
     
     # save
     utils.save_db(objs, get_config_file("songs.db"))
     utils.save_db([pl.get_pickle_obj() for pl in playlists ], get_config_file("playlists.db"))
     self.logdebug("%d songs saved and %d playlists saved", len(objs), len(playlists))
     self.__dirty = False
예제 #23
0
    def save(self):
        if not self.__dirty:
            return True

        # Quickly copy obj before pickle it
        self.__db_operation_lock.acquire()
        songs = self.__songs.values()
        playlists = self.__playlists["local"][:]
        self.__db_operation_lock.release()
        objs = [
            song.get_dict() for song in songs
            if song.get_type() in self.__save_song_type
        ]

        # save
        utils.save_db(objs, get_config_file("songs.db"))
        utils.save_db([pl.get_pickle_obj() for pl in playlists],
                      get_config_file("playlists.db"))
        self.logdebug("%d songs saved and %d playlists saved", len(objs),
                      len(playlists))
        self.__dirty = False
    def save(self, *args):
        if Player.get_source() == self.playing_list_item.song_view:
            current_playing_item = 'playing_list'
        elif Player.get_source() == self.personal_fm_item.song_view:
            current_playing_item = 'personal_fm'
        else:
            current_playing_item = None

        playing_list_songs = self.playing_list_item.song_view.dump_songs()
        try:
            playing_list_song = self.playing_list_item.song_view.current_song.get_dict()
        except:
            playing_list_song = None

        personal_fm_songs = self.personal_fm_item.song_view.dump_songs()
        try:
            personal_fm_song = self.personal_fm_item.song_view.current_song.get_dict()
        except:
            personal_fm_song = None

        utils.save_db((current_playing_item,
            (playing_list_song, playing_list_songs),
            (personal_fm_song, personal_fm_songs)),
            self.listen_db_file)
 def save_uid_and_cookies(self, not_empty=True):
     if not_empty:
         utils.save_db([self.uid, self.cookies], self.cookie_db_file)
     else:
         utils.save_db(None, self.cookie_db_file)
 def save_cookie(self, cookie=None):
     utils.save_db(cookie, self.cookie_db_file)
 def save(self):
     local_lists = filter(lambda item: item.list_type == MusicListItem.LOCAL_TYPE, self.items)
     if len(local_lists) > 0:
         objs = [item.dump_list() for item in local_lists]
         utils.save_db(objs, self.listen_db_file)
예제 #28
0
 def save(self):
     objs = self.playing_list_item.song_view.dump_songs()
     utils.save_db(objs, self.listen_db_file)
예제 #29
0
 def save(self):
     objs = self.dump_songs()
     utils.save_db(objs, self.db_file)
 def save(self):
     obj = dict(cookie=self.cookie,
             username=self.username,
             uid=self.uid)
     utils.save_db(obj, self.config_db)
예제 #31
0
 def save(self):
     if self._data:
         utils.save_db(self._data, self._db)
예제 #32
0
 async def pripsatstart(self, ctx, value: int = 0):
     data = utils.read_db()
     data['start-money'] = value
     utils.save_db(data)
     await ctx.send(f'Hodnota startovních peněz změněna na {value}.')
 def save(self):
     obj = dict(cookie=self.cookie,
             username=self.username,
             uid=self.uid)
     utils.save_db(obj, self.config_db)
예제 #34
0
 def save_uid_and_cookies(self, not_empty=True):
     if not_empty:
         utils.save_db([self.uid, self.cookies], self.cookie_db_file)
     else:
         utils.save_db(None, self.cookie_db_file)
예제 #35
0
 def save(self):
     if self._all_data:
         utils.save_db(self._all_data, self._db)
 def save(self):
     songs = self.collected_view.get_webcasts()
     uris = [ song.get("uri") for song in songs if song.get("uri")]
     utils.save_db(uris, self.collected_db_file)
예제 #37
0
 def save(self):
     channel_infos = [ item.channel_info for item in self.get_items() ]
     utils.save_db(channel_infos, self.preview_db_file)
 def save(self):
     objs = self.playing_list_item.song_view.dump_songs()
     utils.save_db(objs, self.listen_db_file)
예제 #39
0
 def save(self):        
     songs = self.get_webcasts()
     uris = [ song.get("uri") for song in songs if song.get("uri")]
     utils.save_db(uris, self.preview_db_file)
 def save(self):
     objs = [ song.get_dict() for song in self.get_songs() ]
     utils.save_db(objs, self.db_file)
 def save(self):
     songs = self.collected_view.get_webcasts()
     uris = [song.get("uri") for song in songs if song.get("uri")]
     utils.save_db(uris, self.collected_db_file)
예제 #42
0
 def save(self):
     channel_infos = [item.channel_info for item in self.get_items()]
     utils.save_db(channel_infos, self.preview_db_file)
예제 #43
0
 def save_status(self):
     if self.highlight_item:
         channel_info = self.highlight_item.channel_info
         utils.save_db(channel_info, self.status_db_file)
 def save_cookie(self, cookie=None):
     utils.save_db(cookie, self.cookie_db_file)
예제 #45
0
        frame_orig = list(
            map(lambda x: ut.rescale(x, size_ini, size_end), frame))

        # Save data to export
        frames.append([ut.rad2deg(angles[-1]), frame_orig])

    # Save the data in a pickle file
    ut.bbox_to_pkl(frames, fname='frames', folder='pkl')
    """
    ##################################  TASK 3: Filter keypoints  ####################################
    """
    # Check for training database file
    if not os.path.exists(PICKLE_MUSEUM_DATASET):
        logger.info("Creating pickle database for museum dataset...")
        db_museum = ut.create_db(TRAIN_MUSEUM_DIR, FEATURES, candidates)
        ut.save_db(db_museum, PICKLE_MUSEUM_DATASET)
    else:
        logger.info("Reading pickle database for museum dataset...")
        db_museum = ut.get_db(PICKLE_MUSEUM_DATASET)

    logger.info("Loaded data")
    """
    ##################################  TASK 4: Retrieval system and evaluation  ####################################
    ############################### WARNING: Don't touch below this sign. Ask Pablo #################################
    """

    # Check for query database file
    if not os.path.exists(PICKLE_QUERY_DATASET):
        logger.info("Creating pickle database for query dataset...")
        db_query = ut.create_db(TRAIN_QUERY_DIR, FEATURES, query=True)
        ut.save_db(db_query, PICKLE_QUERY_DATASET)
예제 #46
0
 def save_status(self):        
     if self.highlight_item:
         channel_info = self.highlight_item.channel_info
         utils.save_db(channel_info, self.status_db_file)
예제 #47
0
 def save(self):
     songs = self.get_webcasts()
     uris = [song.get("uri") for song in songs if song.get("uri")]
     utils.save_db(uris, self.preview_db_file)