示例#1
0
def songdbMain():
	# Import modules, which will have the side-effect to
	# init/load the songdb (lazily) and register the GUI.
	import songdb
	import Search

	# This is heavy, ugly, etc...
	# But it's simple nice hack for now to index everything.
	import TaskSystem
	def indexAll():
		import appinfo
		for dir in appinfo.musicdirs:
			TaskSystem.asyncCall(lambda: songdb.indexSearchDir(dir), name="create search index", mustExec=True)
	TaskSystem.daemonThreadCall(indexAll, name="create search index")

	# Reindex played songs.
	from State import state
	from Player import PlayerEventCallbacks
	for ev,args,kwargs in state.updates.read():
		try:
			if ev is PlayerEventCallbacks.onSongChange:
				newSong = kwargs["newSong"]
				songdb.insertSearchEntry(newSong)
		except Exception:
			import sys
			sys.excepthook(*sys.exc_info())
	songdb.flush()
示例#2
0
	def _startSearch(self, txt):
		def search():
			with self._lock:
				if self._searchText != txt: return
			res = songdb.search(txt)
			with self._lock:
				if self._searchText == txt:
					self._searchResults = res
					self.__class__.searchResults.updateEvent(self).push()
		with self._lock:
			self._searchText = txt
			TaskSystem.daemonThreadCall(search, name="Song DB search")
示例#3
0
    def _startSearch(self, txt):
        def search():
            with self._lock:
                if self._searchText != txt: return
            res = songdb.search(txt)
            with self._lock:
                if self._searchText == txt:
                    self._searchResults = res
                    self.__class__.searchResults.updateEvent(self).push()

        with self._lock:
            self._searchText = txt
            TaskSystem.daemonThreadCall(search, name="Song DB search")
示例#4
0
	def __set__(self, inst, value):
		if inst is None: # access through class
			self.value = value
			return
		if hasattr(self.value, "__set__"):
			self.value.__set__(inst, value)
		else:
			self.set(inst, value)
		if self.hasUpdateEvent():
			# Do it in a separate thread because we don't expect that some __set__
			# could perform badly or even result in some recursive call.
			import TaskSystem
			TaskSystem.daemonThreadCall(self.updateEvent, args=(inst,), name="%r update event callback" % self)
示例#5
0
	def __set__(self, inst, value):
		if inst is None: # access through class
			self.value = value
			return
		if hasattr(self.value, "__set__"):
			self.value.__set__(inst, value)
		else:
			self.set(inst, value)
		if self.hasUpdateEvent():
			# Do it in a separate thread because we don't expect that some __set__
			# could perform badly or even result in some recursive call.
			import TaskSystem
			TaskSystem.daemonThreadCall(self.updateEvent, args=(inst,), name="%r update event callback" % self)