=== modified file 'src/unity_guayadeque_daemon.py' --- src/unity_guayadeque_daemon.py 2013-03-29 20:26:01 +0000 +++ src/unity_guayadeque_daemon.py 2015-11-16 09:14:03 +0000 @@ -24,6 +24,7 @@ import os import shutil import sqlite3 +import subprocess APP_NAME = 'unity-scope-guayadeque' LOCAL_PATH = '/usr/share/locale/' @@ -79,17 +80,17 @@ SEARCH_SQL = '''SELECT songs.song_name, songs.song_path, songs.song_filename, songs.song_artist, songs.song_album, songs.song_albumartist, covers.cover_path, songs.song_year, songs.song_genre, songs.song_number, songs.song_length FROM songs, covers WHERE songs.song_coverid = covers.cover_id - AND (songs.song_name LIKE '%%%s%%' OR songs.song_album like '%%%s%%' OR songs.song_artist LIKE '%%%s%%') + AND (songs.song_name LIKE ? OR songs.song_album like ? OR songs.song_artist LIKE ?) ORDER BY song_number''' ALBUM_SQL = '''SELECT songs.song_name, songs.song_path, songs.song_filename, songs.song_artist, songs.song_album, songs.song_albumartist, covers.cover_path, songs.song_year, songs.song_genre, songs.song_number, songs.song_length FROM songs, covers WHERE songs.song_coverid = covers.cover_id - AND (songs.song_album like '%%%s%%' AND songs.song_artist LIKE '%%%s%%') + AND (songs.song_album like ? AND songs.song_artist LIKE ?) ORDER BY song_number''' -def get_music_from_guayadeque(query): +def get_music_from_guayadeque(query, search=None, album=None, artist=None): """Parses Guayadeque's collections into a form we can use""" tracks = [] # Copy guayadeque's database to a backup so we can run searches on that rather than the main database @@ -111,7 +112,10 @@ # Grab all the data we need from the backup conn = sqlite3.connect(guayadeque_backupfile) cursor = conn.cursor() - cursor.execute(query) + if album: + cursor.execute(query, ("%"+album+"%", "%"+artist+"%",)) + else: + cursor.execute(query, ("%"+search+"%", "%"+search+"%", "%"+search+"%",)) collection_tracks = cursor.fetchall() cursor.close() for track in collection_tracks: @@ -154,7 +158,7 @@ Search for help documents matching the search string ''' results = [] - tracks = get_music_from_guayadeque(SEARCH_SQL % (search, search, search)) + tracks = get_music_from_guayadeque(SEARCH_SQL, search=search) albumresults = [] for track in tracks: title = "" if track[0] is None else track[0] @@ -206,7 +210,7 @@ preview.props.image_source_uri = 'file://%s' % self.result.icon_hint preview.props.subtitle = self.result.metadata['artist'].get_string() if self.result.uri.startswith("album://"): - tracks = get_music_from_guayadeque(ALBUM_SQL % (album, artist)) + tracks = get_music_from_guayadeque(ALBUM_SQL, album=album, artist=artist) for track in tracks: track = Unity.TrackMetadata.full('file://%s%s' % (track[1], track[2]), track[9], @@ -332,7 +336,7 @@ else: filename = result.uri dirname = os.path.dirname(filename) - os.system("xdg-open '%s'" % str(dirname)) + subprocess.call(["xdg-open", str(dirname)]) else: albumtracks = '' if result.uri.startswith('album://'): @@ -342,7 +346,7 @@ else: albumtracks = '\'%s\'' % result.uri print(albumtracks) - os.system('guayadeque %s' % albumtracks) + subprocess.call(['guayadeque', albumtracks]) try: session_bus = dbus.SessionBus()