Exemplo n.º 1
0
    def __init__(
        self, screen, frame_rate=20, sensor=None, queue=None,
        group=None, name='ScreenClock', verbose=None
    ):
        super(ScreenClock, self).__init__(
            group=group, name=name, verbose=verbose
        )
        self.__spf = 1.0 / float(frame_rate)
        self.__sensor = sensor
        self.__queue = queue
        self.__stop = threading.Event()

        # Clock related config
        self.__c = Object({
            'bitmap': screen.Bitmap(128, 64),
            'font': input_mono_24,
            'font_small': tahoma_16,
            'timestring': None,
            'datestring': None,
            'sensorstring': None,
        })

        # sensor related config
        self.__sr = Object({
            'last_read': 0,
            'last_value': None,
            'interval': 15,
        })
Exemplo n.º 2
0
 def __init__(self, config_path='./'):
     Object.__init__(self)
     self.__config     = Config(config_path)
     self.__artwork    = database.Artwork(self)
     self.__lyrics     = database.Lyrics(self)
     self.__connection = Connection(self.config)
     self.__playback   = Playback(self.__connection, self.__config)
     args = [self.__connection, self.__playback, self.__config, self.__artwork, self.__lyrics]
     self.__library    = Library(*args)
     self.__playlist   = Playlist(*args)
Exemplo n.º 3
0
 def __init__(self, connection, playback, config, artwork, lyrics):
     Object.__init__(self)
     self.__connection = connection
     self.__playback = playback
     self.__config = config
     self.__artwork = artwork
     self.__lyrics = lyrics
     self.__data = []
     self.__connection.bind(self.__connection.CONNECT, self.__update_cache)
     self.__connection.bind(self.__connection.UPDATE_DATABASE, self.__update_cache)
Exemplo n.º 4
0
 def __init__(self, path='./'):
     """ initializes config by given path.
     
     Arguments:
         path -- string json config filepath.
     """
     self.path = path
     if not self.path[-1] == '/':
         self.path = self.path + '/'
     self.__config = {}
     Object.__init__(self)
     self.load()
Exemplo n.º 5
0
 def __init__(self, connection, playback, config, artwork, lyrics):
     Object.__init__(self)
     self.__connection = connection
     self.__playback = playback
     self.__config = config
     self.__artwork = artwork
     self.__lyrics = lyrics
     self.__data = []
     self.__selected = []
     self.__focused = None
     self.__current = None
     self.__connection.bind(self.__connection.CONNECT, self.__update_cache)
     self.__connection.bind(self.__connection.UPDATE_PLAYLIST, self.__update_cache)
     self.__connection.bind(self.__connection.UPDATE, self.__focus_playing)
Exemplo n.º 6
0
 def __init__(self, config):
     Object.__init__(self)
     threading.Thread.__init__(self)
     self.__running = False
     self.daemon = True
     self.__config = config
     self.__current = None
     self.__connection = None
     self.__lock = thread.allocate_lock()
     self.__status = ''
     # server status checker.
     self.__server_status = {}
     self.__check_playlist = None
     self.__check_library = None
     self.__server_status_song = None
     self.connected = False
Exemplo n.º 7
0
 def set(self, doc, fields_values):
     """
     sets a key/value pairs, and persists those changes to the datastore immediately
     """
     fields_values = Object.from_bson(fields_values)
     fields_values.make_safe()
     for k,v in fields_values.iteritems():
         self._set(doc, k.split('.'), v)
     impl = self._impl(doc)
     impl.update({'_id':doc._id}, {'$set':fields_values}, safe=True)
Exemplo n.º 8
0
    def __init__(self, client):
        """init values and database."""
        self.__cache = CacheDict()
        sql_init = '''
        CREATE TABLE IF NOT EXISTS lyrics
        (
            artist TEXT,
            title TEXT,
            album TEXT,
            lyric TEXT,
            UNIQUE(artist, title, album)
        );
        '''
        sql_search = '''
        SELECT lyric FROM lyrics WHERE
            artist=? and
            title=? and
            album=?
        '''
        sql_write = '''
        INSERT OR REPLACE INTO lyrics
        (artist, title, album, lyric)
        VALUES(?,  ?,  ?,  ?)
        '''

        def sql_arg_parser(song):
            return (song.format('%artist%'),
                    song.format('%title%'),
                    song.format('%album%'))

        self.__data = SqliteDict(environment.config_dir + u'/lyrics',
                                 sql_init,
                                 sql_search,
                                 sql_arg_parser,
                                 sql_write,
                                 sql_arg_parser)
        self.client = client
        self.__downloading = []
        self.download_auto = False
        self.download_background = False
        self.downloaders = {'geci_me': True}
        self.download_class = {'geci_me': rest.GeciMe}
        Object.__init__(self)
Exemplo n.º 9
0
    def __init__(self, client):
        """init values and database."""
        self.client = client
        self.__download_path = environment.config_dir + '/artwork'
        self.__downloading = []
        self.download_auto = False
        self.download_background = False
        self.downloaders = {'lastfm': True}
        self.download_class = {'lastfm': rest.ArtworkLastfm}

        sql_init = '''
        CREATE TABLE IF NOT EXISTS artwork
        (   artist TEXT,
            album TEXT,
            artwork TEXT,
            UNIQUE(artist, album)
        );
        '''
        sql_search = '''
        SELECT artwork FROM artwork WHERE
            artist=? and
            album=?
        '''
        sql_write = '''
        INSERT OR REPLACE INTO artwork
        (artist, album, artwork)
        VALUES(?,  ?,  ?)
        '''

        def sql_arg_parser(song):
            return (song.format('%albumartist%'),
                    song.format('%album%'))

        self.__data = SqliteDict(environment.config_dir + '/artworkdb',
                                 sql_init,
                                 sql_search,
                                 sql_arg_parser,
                                 sql_write,
                                 sql_arg_parser)
        self.__cache = CacheDict()
        Object.__init__(self)
Exemplo n.º 10
0
MAP_WIDTH = 80
MAP_HEIGHT = 45

#FPS = 30

lcod.console_set_custom_font('arial10x10.png' , lcod.FONT_LAYOUT_TCOD | lcod.FONT_TYPE_GREYSCALE)


lcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,'Rogue, more like Thief',False)
con = lcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
MAPcon = lcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

#prossima riga usata solo in real time 
#lcod.sys_set_fps(FPS)

player = Object(SCREEN_WIDTH/2,SCREEN_HEIGHT/2, '@', lcod.white)

npc = Object(SCREEN_WIDTH/2 - 5,SCREEN_HEIGHT/2, '@', lcod.white)

oggetti = [npc, player]

mappa = Mappa(MAP_HEIGHT, MAP_WIDTH)


def checkKeys():
    #key = lcod.console_check_for_keypress()
    key = lcod.console_wait_for_keypress(True)
    if key.vk == lcod.KEY_ENTER and key.lalt:
        # alt+enter to toggle fullscreen
        lcod.console_set_fullscreen(not lcod.console_is_fullscreen()) # console.is_fullscreen return true if fullscreen, false otherwise
    elif key.vk == lcod.KEY_ESCAPE:
Exemplo n.º 11
0
	def __init__(self, name='collider_manager'):
		Object.__init__(self, name)
		self._collidable_sprites = []
		self._collidable_ref_sprite = None
Exemplo n.º 12
0
	def __init__(self, name):
		Object.__init__(self, name)
		self._fsm = None
		self._assign_properties = []
		self._transitions = {}
Exemplo n.º 13
0
 def __init__(self, connection, config):
     Object.__init__(self)
     self.connection = connection
     self.config = config