Exemplo n.º 1
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "pydiry.ico")
		self.hash = launchy.hash(self.getName())
		self.labelHash = launchy.hash("pydiry")
		
		self.dirs = CaselessDict()
Exemplo n.º 2
0
    def __init__(self):
        launchy.Plugin.__init__(self)
        self.icon = os.path.join(launchy.getIconsPath(), "pydiry.ico")
        self.hash = launchy.hash(self.getName())
        self.labelHash = launchy.hash("pydiry")

        self.dirs = CaselessDict()
Exemplo n.º 3
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "weby.png")
		self.hash = launchy.hash(self.getName())
		self.labelHash = launchy.hash("pywebindex")
		
		self.widget = None
		self.masterPages = []
		self.db = LinksDB()
Exemplo n.º 4
0
    def __init__(self):
        launchy.Plugin.__init__(self)
        self.icon = os.path.join(launchy.getIconsPath(), "weby.png")
        self.hash = launchy.hash(self.getName())
        self.labelHash = launchy.hash("pywebindex")

        self.widget = None
        self.masterPages = []
        self.db = LinksDB()
Exemplo n.º 5
0
    def __init__(self):
        """
        Every plugin should have the following __init__ function.
        """
        launchy.Plugin.__init__(self)

        self.addons = []
        self.name = "Thruster"
        self.id = launchy.hash(self.name)
        self.icon = os.path.join(launchy.getIconsPath(), "%s.png" % self.name)
Exemplo n.º 6
0
    def __init__(self):
        """
        Every plugin should have the following __init__ function.
        """
        launchy.Plugin.__init__(self)

        self.addons = []
        self.name = "Thruster"
        self.id = launchy.hash(self.name)
        self.icon = os.path.join(launchy.getIconsPath(), "%s.png" % self.name)
Exemplo n.º 7
0
    def __init__(self):
        launchy.Plugin.__init__(self)
        self.name = "pybookkeeper"
        self.hash = launchy.hash(self.name)
        self.icon = os.path.join(launchy.getIconsPath(), "pybookkeeper.png")
        self.bookmarks = {}

        BOOKKEEPPER_DEBUG("instance created: %s" % self)
        BOOKKEEPPER_DEBUG("name: %s" % self.name)
        BOOKKEEPPER_DEBUG("hash: %s" % self.hash)
        BOOKKEEPPER_DEBUG("icon: %s" % self.icon)
Exemplo n.º 8
0
    def __init__(self):
        super(LaunchySQLite, self).__init__()
        self.name = "SQLite"
        self.hash = launchy.hash(self.name)
        self.icon = os.path.join(launchy.getIconsPath(), "pysimple.png")

        script_path = launchy.getScriptsPath()
        config_filename = os.path.join(script_path, "sqlite_config.json")

        self.config = read_json(config_filename)
        self.database_filename = self.config["database"]

        self.conn = None
Exemplo n.º 9
0
    def setAddonIcon(self, filename):
        retVal = True

        if os.path.exists(filename):
            self.icon = filename
        else:
            self.icon = os.path.join(launchy.getIconsPath(), filename)

            if not os.path.exists(self.icon):
                retVal = False
                seif.icon = None
                self.logger(LOG_LEVEL_ERR, "Icon not exist: '%s'." % self.icon)

        return retVal
Exemplo n.º 10
0
    def setAddonIcon(self, filename):
        retVal = True

        if os.path.exists(filename):
            self.icon = filename
        else:
            self.icon = os.path.join(launchy.getIconsPath(), filename)

            if not os.path.exists(self.icon):
                retVal = False
                seif.icon = None
                self.logger(LOG_LEVEL_ERR, "Icon not exist: '%s'." % self.icon)

        return retVal
Exemplo n.º 11
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "python.ico")
		self.hash = launchy.hash(self.getName())
		self.fileCache = []
		self.lastCacheUpdate = 0 # Should cause cache on first time
Exemplo n.º 12
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.icon = os.path.join(launchy.getIconsPath(), "python.ico")
     self.hash = launchy.hash(self.getName())
     self.fileCache = []
     self.lastCacheUpdate = 0  # Should cause cache on first time
Exemplo n.º 13
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.name = "pyEverything"
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), "everything.png")
Exemplo n.º 14
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "python.ico")
		self.hash = launchy.hash(self.getName())
Exemplo n.º 15
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.name = "PyMusicbeeQueue"
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), "musicbee.png")
Exemplo n.º 16
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "pysimple.png")
		self.hash = launchy.hash(self.getName())
		self.labelHash = launchy.hash("pyverby")
Exemplo n.º 17
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.icon = os.path.join(launchy.getIconsPath(), "pysimple.png")
     self.hash = launchy.hash(self.getName())
     self.labelHash = launchy.hash("pyverby")
Exemplo n.º 18
0
    def getResults(self, inputDataList, resultsList):
        # Take the text from the first input item and add a new
        # Catalog item with our plugin id

        # print len(inputDataList)
        inputData = inputDataList[0]

        first_result = True

        all_text = inputData.getText()

        all_text_parts = all_text.split(" ")

        if DO_TIMING:
            start_time = time.time()

        # print inputDataList

        for table_entry in self.config["tables"]:
            # go through the tables to use from this sqlite database according to the config
            table_name = table_entry["name"]
            display_name_field = table_entry.get("display_name_field")
            search_fields = table_entry["search_fields"]

            # 1. build the list of fields we want for this table
            output_fields = []

            # the fields definitions for this table from our config file
            field_defs = table_entry["fields"]

            for field_name, field_def in field_defs.iteritems():
                if self.has_valid_action(field_def):
                    output_fields.append(field_name)
                else:
                    print "field %s has no valid action; skipping" % field_name

            icon_url_field = table_entry.get("icon_url_field")
            if icon_url_field and icon_url_field not in output_fields:
                output_fields.append(icon_url_field)
            if display_name_field and display_name_field not in output_fields:
                output_fields.append(display_name_field)

            # What we want
            # - the rows where all the words are in any of the fields
            # - for any combination of the words that are in an action, the rows where all the other words are in any of the fields
            #   (we will show just certain actions for these)
            #
            # For a simple first cut of this, let's just narrow the actions to any word that is part of an action
            # rather than doing the full union.

            # 2. figure out what action names the search terms match and what other actions to exclude

            action_names = []
            action_entries = []

            for output_column_name in output_fields:
                field_defs_entry = self.field_defs_entry_proper(
                    field_defs.get(output_column_name))
                if field_defs_entry is None:
                    continue
                for field_def_num, field_def in enumerate(field_defs_entry):
                    action_name = self.get_action_name(field_def,
                                                       output_column_name)
                    action_names.append(action_name)
                    action_entries.append(
                        (output_column_name, field_def_num, action_name))

            exclude_output_fields = set()

            text_parts = []
            for text_part in all_text_parts:
                if any(
                        self.action_name_match(text_part, action_name)
                        for action_name in action_names):
                    # text is in any action name; treat as a search for those specific actions

                    # we only want actions that have all of these action words
                    for output_field, field_def_num, action_name in action_entries:
                        if action_name is None:
                            continue
                        if not self.action_name_match(text_part, action_name):
                            key = (output_field, field_def_num)
                            if key not in exclude_output_fields:
                                exclude_output_fields.add(key)
                else:
                    # text is not in any action name; treat as ordinary search text
                    text_parts.append(text_part)

            if DEBUG_OUTPUT:
                print ""
                print "QUERY %r" % all_text_parts
                print "exclude output fields %r" % exclude_output_fields
                print "text parts %r" % text_parts

            # 3. build database query to do for this table to match on those fields

            output_clause = ", ".join(sqlite_escape(x) for x in output_fields)
            if len(text_parts) == 0:
                search_clause = "1"
            else:
                search_clause = " OR ".join("%s LIKE ?" % sqlite_escape(x)
                                            for x in search_fields)
                search_clause = " AND ".join(["(" + search_clause + ")"] *
                                             len(text_parts))

            query = "SELECT %s FROM %s WHERE %s" % (
                output_clause, sqlite_escape(table_name), search_clause)

            args = []
            for text_part in text_parts:
                args += ["%" + text_part.replace("%", "%%") + "%"
                         ] * len(search_fields)

            if DEBUG_OUTPUT:
                print query

            # print "running query: " + query
            # print "with args: " + repr(args)

            # 4. Use the database query results to create the action items, respecting the action filters

            c = self.conn.cursor()
            assert isinstance(c, sqlite3.Cursor)
            try:
                try:
                    c.execute(query, args)
                except sqlite3.OperationalError:
                    print "failing query was %r args %r" % (query, args)
                    raise
                result_rows = c.fetchall()
                if DEBUG_OUTPUT:
                    print "got %d rows" % len(result_rows)
                for result_row in result_rows:

                    column_pairs = zip(output_fields, result_row)
                    column_dict = dict(column_pairs)

                    icon = self.getIcon()
                    # noinspection PyBroadException
                    try:
                        if icon_url_field:
                            icon_url = column_dict[icon_url_field]
                            if icon_url:
                                assert isinstance(icon_url, basestring)
                                icon_filename = os.path.join(
                                    launchy.getIconsPath(),
                                    url_hash(icon_url) + ".png")
                                if not os.path.exists(icon_filename):
                                    self.download(icon_url, icon_filename)
                                icon = icon_filename
                    except Exception:
                        print "error getting icon"
                        traceback.print_exc()
                    # print "icon is " + icon

                    for output_column_name, output_value in column_pairs:
                        if not output_value:
                            continue

                        field_defs_entry = self.field_defs_entry_proper(
                            field_defs.get(output_column_name))
                        if field_defs_entry is None:
                            continue

                        for field_def_number, field_def in enumerate(
                                field_defs_entry):
                            if (output_column_name,
                                    field_def_number) in exclude_output_fields:
                                continue

                            if not self.has_valid_action(field_def):
                                continue

                            action_name = self.get_action_name(
                                field_def, output_column_name)

                            action = {
                                "table": table_name,
                                "field": output_column_name,
                                "value": output_value,
                                "field_def_number": field_def_number
                            }
                            action_json = json.dumps(action)

                            if display_name_field and column_dict[
                                    display_name_field]:
                                entry_display_text = "%s: %s (%s)" % (
                                    column_dict[display_name_field],
                                    action_name, output_value)
                            else:
                                entry_display_text = "%s: %s" % (output_value,
                                                                 action_name)

                            if DEBUG_OUTPUT:
                                print "ENTRY: " + entry_display_text

                            cat_item = launchy.CatItem(PRE_TAG + action_json,
                                                       entry_display_text,
                                                       self.getID(), icon)

                            resultsList.push_back(cat_item)
                            if first_result:
                                first_result = False
                                inputData.setTopResult(cat_item)

            finally:
                c.close()

        if DO_TIMING:
            end_time = time.time()

            # noinspection PyUnboundLocalVariable
            print "elapsed time %0.0f ms" % ((end_time - start_time) * 1000)
Exemplo n.º 19
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.name = "PyMusicbeeQueue"
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), "musicbee.png")
Exemplo n.º 20
0
 def __init__(self):
     launchy.Plugin.__init__(self)  ### 2
     self.name = "PySimple"  ### 3
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), "pysimple.png")
Exemplo n.º 21
0
 def __init__(self):
     launchy.Plugin.__init__(self)  ### 2
     self.name = "PySimple"  ### 3
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), "pysimple.png")
Exemplo n.º 22
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.icon = os.path.join(launchy.getIconsPath(), "python.ico")
     self.hash = launchy.hash(self.getName())
Exemplo n.º 23
0
 def __init__(self):
     launchy.Plugin.__init__(self)
     self.name = 'FooLaunchy'
     self.hash = launchy.hash(self.name)
     self.icon = os.path.join(launchy.getIconsPath(), 'foobar2000_64.png')
Exemplo n.º 24
0
	def __init__(self):
		launchy.Plugin.__init__(self)
		self.icon = os.path.join(launchy.getIconsPath(), "pycalc.ico")
		self.hash = launchy.hash(self.getName())
		self.labelHash = launchy.hash("pycalc")