def load(self): bench.step('Load apps') count = len(self.data) apps = self.load_pickle(APPS_MENU) apps_cmds = set() for item in self.iter_menu(apps): item['type'] = model.TYPE_APP item['mimetype'] = uxm.utils.mime.APP_EXE self.append_item(item, count, True) apps_cmds.add(item['command']) count += 1 bookmarks = self.load_pickle(BOOK_MENU) for item in self.iter_bookmarks(bookmarks): item['type'] = model.TYPE_DIR item['mimetype'] = uxm.utils.mime.INODE_DIR self.append_item(item, count, False) count += 1 recent_files = self.load_pickle(RECENT_MENU) for item in self.iter_recent_files(recent_files): item['type'] = model.TYPE_FILE item['url'] = item['id'] self.append_item(item, count, False) count += 1 # Fetching mimetype for all files in PATH can take quite a long time, # especially if the disk cache is empty, eg on a fresh start. # So we just get basic info and fetch the real mimetype later path_cmds = [] for app_path in self.iter_path(): name = os.path.basename(app_path) # don't index executables found in desktop apps if name in apps_cmds or app_path in apps_cmds: continue if name.startswith('less'): print name, app_path self.index.add(name, {'id': count}) is_link = os.path.islink(app_path) if os.path.isdir(app_path): icon = self.dir_link_icon if is_link else self.dir_icon type = model.TYPE_DIR mt = uxm.utils.mime.INODE_DIR if os.path.isfile(app_path): type = model.TYPE_CMD icon = self.exe_link_icon if is_link else self.exe_icon mt = uxm.utils.mime.APP_EXE path_cmds.append((app_path, name, is_link, count)) else: continue self.data[count] = { 'id': count, 'type': type, 'label': name, 'command': name, 'icon': icon, 'mimetype': mt } count += 1 # now reload mimetypes asynchronously self.reload_path_info_async(path_cmds) bench.endstep('Load apps')
def load_directory(self, directory): #{{{ bench.step('Load dir %s' % directory) r = self.fs_model.browse(directory) bench.endstep('Load dir %s' % directory) if r: self.treeview.set_model(self.fs_model.get_model()) self.show_popup()
def run(self): if self.queue is None: raise RuntimeError('Listener must be associated with a Queue') bench.step('Load path') while not self.stopevent.isSet(): # Listen for results on the queue and process them accordingly data = self.queue.get() # Check if finished self.num_results += 1 if self.num_results == self.max_results: bench.endstep('Load path') self.emit("finished") self.stop() elif data[0] == "error": self.emit('error', data[1]) self.stop() else: self.emit('updated', data)
#! /usr/bin/env python import sys import os.path as path import logging sys.path.insert(0, path.abspath(path.dirname(path.abspath(__file__)))) import uxm.bench as bench import uxm.config from uxm.dialogs.launcher.dialog import LauncherDialog if __name__ == "__main__": logger = logging.getLogger('uxm-run') logger.addHandler(uxm.config.make_log_handler('uxm-run')) logger.setLevel(logging.ERROR) try: bench.step('dialog init') launcher = LauncherDialog() bench.endstep('dialog init') launcher.start() except Exception, e: logger.exception(e) raise bench.stop() bench.results()