Beispiel #1
0
        pass

    def endDialog(self, accept):
        """
        Informs the plugin that it should close its dialog.

        @accept <bool>: whether the plugin should accept changes made by the
                        user while the dialog was open
        """
        pass

    def launchyShow(self):
        """
        This message informs the plugin that Launchy is now
        visible on the screen.
        """
        pass

    def launchyHide(self):
        """
        This message informs the plugin that Launchy is no
        longer visible on the screen.

        Note: this function will not be called if another
        plugin function has not returned yet (e.g. Launchy
        is hidden in the middle of launchItem()).
        """
        pass

launchy.registerPlugin(Thruster)
Beispiel #2
0
		
	def getIcon(self):
		return self.icon
		
	def getLabels(self, inputDataList):
		pass
		
	def getResults(self, inputDataList, resultsList):
		if len(inputDataList) > 1:
			return
			
		text = inputDataList[0].getText()
		if not Calculator.isValidExpression(text):
			return
		
		try:
			result = Calculator.calc(text, advanced=True)
		except:
			pass
		else:
			resultsList.append( launchy.CatItem(str(result), str(result), self.getID(), self.getIcon() ))
		
	def getCatalog(self, resultsList):
		pass
		
	def launchItem(self, inputDataList, catItemOrig):
		pass
	

launchy.registerPlugin(PyCalc)
    def init(self):
        pass

    def getID(self):
        return self.hash

    def getName(self):
        return self.name

    def getIcon(self):
        return self.icon

    def getLabels(self, inputDataList):
        pass

    def getResults(self, inputDataList, resultsList):
        text = inputDataList[0].getText()
        resultsList.push_back(
            launchy.CatItem(text, "pyEverything: " + text, self.getID(),
                            self.getIcon()))

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        catItem = inputDataList[-1].getTopResult()
        call([everythingPath, "-search", catItem.fullPath])


launchy.registerPlugin(pyEverything)
Beispiel #4
0
			settings.setValue("PyWebIndex/pagesHash", QVariant(""))
		
		# Remove all empty rows
		itemsToRemove = []
		for i in range(0, table.rowCount()):
			nameItem = table.item(i,0)
			urlItem = table.item(i,1)
			if nameItem == None or urlItem == None:
				itemsToRemove.append(i)
			elif nameItem.text() == "" or urlItem == "":
				itemsToRemove.append(i)
		
		for item in itemsToRemove:
			table.removeRow(i)
		
		# Add all rows to the masterPages array
		settings.remove("PyWebIndex/masterPages")
		settings.beginWriteArray("PyWebIndex/masterPages")
		for i in range(0, table.rowCount()):
			settings.setArrayIndex(i)
			settings.setValue("name", QVariant(table.item(i,0).text()))
			settings.setValue("url", QVariant(table.item(i,1).text()))
		settings.endArray()
		
debugOn = False
def print_debug(*args):
	if debugOn:
		print args

launchy.registerPlugin(PyWebIndex)
Beispiel #5
0
	def getID(self):
		return self.hash
	
	def getName(self):
		return "SkeletonPlugin"
		
	def getIcon(self):
		return self.icon
		
	def getLabels(self, inputDataList):
		for inputData in inputDataList:
			print inputData.getText()
		
	def getResults(self, inputDataList, resultsList):
		text = inputDataList[0].getText()
		resultsList.append( launchy.CatItem(text, "From python: " + text, self.hash, self.icon) )
		
	def getCatalog(self, resultsList):
		pass
		
	def launchItem(self, inputDataList, catItem):
		print "You have chosen to launch " + catItem.fullPath
			
	def launchyShow(self):
		pass
			
	def launchyHide(self):
		pass

launchy.registerPlugin(SkeletonPlugin)
Beispiel #6
0
                launchy.CatItem(text, commandToExec, self.getID(),
                                self.getIcon()))

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        catItem = inputDataList[-1].getTopResult()
        print catItem.fullPath, catItem.shortName
        runmenuApp = 'C:\\Program Files\\Launchy\\plugins\\python\\runmenu\\runmenu.exe'
        runmenu = Popen(
            [runmenuApp,
             '/exec:%s' % catItem.shortName, catItem.fullPath],
            stdout=PIPE,
            startupinfo=self.__startupinfo)

        print runmenu.stdout.read()

    def launchyShow(self):
        pass

    def launchyHide(self):
        pass

    __startupinfo = subprocess.STARTUPINFO()
    __startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    __startupinfo.wShowWindow = subprocess.SW_HIDE


launchy.registerPlugin(PyVerby)
Beispiel #7
0
        for i in range(0, table.rowCount()):
            nameItem = table.item(i, 0)
            urlItem = table.item(i, 1)
            if nameItem == None or urlItem == None:
                itemsToRemove.append(i)
            elif nameItem.text() == "" or urlItem == "":
                itemsToRemove.append(i)

        for item in itemsToRemove:
            table.removeRow(i)

        # Add all rows to the masterPages array
        settings.remove("PyWebIndex/masterPages")
        settings.beginWriteArray("PyWebIndex/masterPages")
        for i in range(0, table.rowCount()):
            settings.setArrayIndex(i)
            settings.setValue("name", QVariant(table.item(i, 0).text()))
            settings.setValue("url", QVariant(table.item(i, 1).text()))
        settings.endArray()


debugOn = False


def print_debug(*args):
    if debugOn:
        print args


launchy.registerPlugin(PyWebIndex)
Beispiel #8
0
		
		
	def _goToWindow(self, hwnd):
		# Bascially copied from old Go-Y plugin
		
		windowPlacement = win32gui.GetWindowPlacement(hwnd)
		showCmd = windowPlacement[1]
		
		if showCmd == SW_RESTORE:
			win32gui.ShowWindow(hwnd, SW_RESTORE)
		else:
			win32gui.BringWindowToTop(hwnd)
		win32gui.SetForegroundWindow(hwnd)
		win32gui.SetActiveWindow(hwnd)
		
	def _getTopLevelWindows(self):
		""" Returns the top level windows in a list of tuples defined (HWND, title) """
		windows = []
		win32gui.EnumWindows(self._windowEnumTopLevel, windows)
		return windows
		
	def _windowEnumTopLevel(hwnd, windowsList):
		""" Window Enum function for getTopLevelWindows """
		title = win32gui.GetWindowText(hwnd)
		if win32gui.GetParent(hwnd) == 0 and title != '':
			windowsList.append( (hwnd,unicode(title, errors='ignore' ) ) )
				
	_windowEnumTopLevel = staticmethod(_windowEnumTopLevel)

launchy.registerPlugin(PyGoY)
Beispiel #9
0
            region = '[REGION]'
            access_key_id = '[ACCES_KEY_ID]'
            secret_access_key = '[SECRET_ACCES_KEY]'

            if not (region and access_key_id and secret_access_key):
                continue

            ec2_connection = self.get_ec2_connection(region, access_key_id,
                secret_access_key)

            tags = collections.defaultdict(list)
            for reservation in ec2_connection.get_all_instances():
                for instance in reservation.instances:
                    for tag in instance.tags.itervalues():
                        if instance.public_dns_name:
                            tags[tag].append(instance.public_dns_name)

            self.tags[name] = dict(tags)
        settings.endArray()

    @classmethod
    def get_ec2_connection(cls, region, access_key_id, secret_access_key):
        return ec2.connect_to_region(
            region,
            aws_access_key_id=access_key_id,
            aws_secret_access_key=secret_access_key,
        )

launchy.registerPlugin(PyEC2)

        pass

    def getID(self):
        return self.hash

    def getName(self):
        return self.name

    def getIcon(self):
        return self.icon

    def getLabels(self, inputDataList):
        pass

    def getResults(self, inputDataList, resultsList):
        text = inputDataList[0].getText()
        resultsList.push_back( launchy.CatItem(text,
                                               "Play Song: " + text,
                                                self.getID(), self.getIcon()) )

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        catItem = inputDataList[-1].getTopResult()
        mbIPC = MusicBeeIPC()
        mbIPC.search_and_play_first(catItem.fullPath)


launchy.registerPlugin(PyMusicbeeQueue)
Beispiel #11
0
			if verbIdx > -1:
				commandToExec = command[:verbIdx]
			else:
				commandToExec = command
				
			resultsList.append( launchy.CatItem(text, commandToExec, self.getID(), self.getIcon() ))
		
	def getCatalog(self, resultsList):
		pass
		
	def launchItem(self, inputDataList, catItemOrig):
		catItem = inputDataList[-1].getTopResult()
		print catItem.fullPath, catItem.shortName
		runmenuApp = 'C:\\Program Files\\Launchy\\plugins\\python\\runmenu\\runmenu.exe'
		runmenu = Popen([runmenuApp, '/exec:%s' % catItem.shortName, catItem.fullPath], stdout=PIPE, startupinfo=self.__startupinfo)
		
		print runmenu.stdout.read()
		
	def launchyShow(self):
		pass
			
	def launchyHide(self):
		pass
	
	__startupinfo = subprocess.STARTUPINFO()
	__startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
	__startupinfo.wShowWindow = subprocess.SW_HIDE


launchy.registerPlugin(PyVerby)
Beispiel #12
0
    def endDialog(self, accept):
        """
        Informs the plugin that it should close its dialog.

        @accept <bool>: whether the plugin should accept changes made by the
                        user while the dialog was open
        """
        pass

    def launchyShow(self):
        """
        This message informs the plugin that Launchy is now
        visible on the screen.
        """
        pass

    def launchyHide(self):
        """
        This message informs the plugin that Launchy is no
        longer visible on the screen.

        Note: this function will not be called if another
        plugin function has not returned yet (e.g. Launchy
        is hidden in the middle of launchItem()).
        """
        pass


launchy.registerPlugin(Thruster)
Beispiel #13
0
    def __listOpenExplorerDirectories(self):
        dirs = []
        for explorer in self.shellWindows:
            locationUrl = explorer.LocationURL
            if locationUrl.startswith(fileUrlPrefix):
                path = locationUrl[len(fileUrlPrefix):]
                dirs.append(urllib.unquote(path))

        return dirs

    def __cacheFilesFromOpenDirs(self):
        currentTime = time.time()
        if currentTime - self.lastCacheUpdate < self.cacheTimeThreshold:
            return

        self.lastCacheUpdate = currentTime

        self.fileCache = []
        openDirectories = self.__listOpenExplorerDirectories()
        for dir in openDirectories:
            for entry in os.listdir(dir):
                #if not path.isfile(entry): continue
                splitext = path.splitext(entry)
                if len(splitext) <= 1: continue

                #if splitext[1] in ['.bat', '.lnk']:
                self.fileCache.append((entry, dir))


launchy.registerPlugin(PyExplorey)
Beispiel #14
0
        """Callback function to ask the plugin for a static catalog 
        to be added to the primary catalog. 
        
        It will be called when the primary catalog is rebuilt.
        """
        bookmarkFile = os.path.join(os.environ["localappdata"], "Google/Chrome/User Data/Default/Bookmarks")
        bookmarkManager = eval(open(bookmarkFile, 'r').read())
        bookmarkBar = bookmarkManager.get("roots", None).get("bookmark_bar", None).get("children", None)
        if bookmarkBar:
            for folder in bookmarkBar:
                for bm in folder.get("children", None):
                    self.bookmarks.update({bm.get("name", None): bm.get("url", None)})

        for key in self.bookmarks.keys():
            resultsList.append(launchy.CatItem(self.bookmarks.get(key), key, self.getID(), self.getIcon()))
            BOOKKEEPPER_DEBUG("%-20s: %s" % (key, self.bookmarks.get(key)))
        BOOKKEEPPER_DEBUG("getCatalog() is executed successfully.\n")

    def launchItem(self, inputDataList, catItemOrig):
        """Instructs the plugin that one of its own catalog items 
        was selected by the user and should now be executed.

        If the plugin adds items to the catalog via getResults() 
        or getCatalog() and one of those items is selected by the 
        user, then it is up to the plugin to execute it when the 
        user presses “enter”. This is where you perform the action.
        """
        subprocess.call('start chrome "%s"' % catItemOrig.fullPath, shell=True)

launchy.registerPlugin(pybookkeeper)
Beispiel #15
0
		version = settings.value("PyDiry/version", QVariant("0.0")).toString()
		print_debug("PyDiry version: " + version)
		if version == "0.0":
			settings.beginWriteArray("PyDiry/dirs")
			settings.setArrayIndex(0)
			settings.setValue("name", QVariant("My Documents"))
			settings.setValue("path", QVariant("%USERPROFILE%\\My Documents"))
			settings.endArray()
		
		# Set our version
		settings.setValue("PyDiry/version", QVariant(self.__version__))
		
		self.dirs.clear()
		
		# Read directories from the settings file
		size = settings.beginReadArray("PyDiry/dirs")
		for i in range(0, size):
			settings.setArrayIndex(i);
			name = unicode(settings.value("name").toString())
			path = unicode(settings.value("path").toString())
			self.dirs[name] = expandvars(path)
		settings.endArray()
		
	def __makeShortName(self, itemPath):
		try:
			return os.path.split(itemPath)[1]
		except:
			return itemPath

launchy.registerPlugin(PyDiry)
Beispiel #16
0
    def _goToWindow(self, hwnd):
        # Bascially copied from old Go-Y plugin

        windowPlacement = win32gui.GetWindowPlacement(hwnd)
        showCmd = windowPlacement[1]

        if showCmd == SW_RESTORE:
            win32gui.ShowWindow(hwnd, SW_RESTORE)
        else:
            win32gui.BringWindowToTop(hwnd)
        win32gui.SetForegroundWindow(hwnd)
        win32gui.SetActiveWindow(hwnd)

    def _getTopLevelWindows(self):
        """ Returns the top level windows in a list of tuples defined (HWND, title) """
        windows = []
        win32gui.EnumWindows(self._windowEnumTopLevel, windows)
        return windows

    def _windowEnumTopLevel(hwnd, windowsList):
        """ Window Enum function for getTopLevelWindows """
        title = win32gui.GetWindowText(hwnd)
        if win32gui.GetParent(hwnd) == 0 and title != '':
            windowsList.append((hwnd, unicode(title, errors='ignore')))

    _windowEnumTopLevel = staticmethod(_windowEnumTopLevel)


launchy.registerPlugin(PyGoY)
Beispiel #17
0
	# Returns a list of the current directories opened by Explorer
	def __listOpenExplorerDirectories(self):
		dirs = []
		for explorer in self.shellWindows:
			locationUrl = explorer.LocationURL
			if locationUrl.startswith(fileUrlPrefix):
				path = locationUrl[len(fileUrlPrefix):]
				dirs.append( urllib.unquote(path) )
				
		return dirs
		
	def __cacheFilesFromOpenDirs(self):
		currentTime = time.time()
		if currentTime - self.lastCacheUpdate < self.cacheTimeThreshold:
			return
			
		self.lastCacheUpdate = currentTime
		
		self.fileCache = []
		openDirectories = self.__listOpenExplorerDirectories()
		for dir in openDirectories:
			for entry in os.listdir(dir):
				#if not path.isfile(entry): continue
				splitext = path.splitext(entry)
				if len(splitext) <= 1: continue
				
				#if splitext[1] in ['.bat', '.lnk']:
				self.fileCache.append( (entry, dir) )

launchy.registerPlugin(PyExplorey)
Beispiel #18
0
    # noinspection PyPep8Naming
    def launchItem(self, inputDataList, catItemOrig):
        # The user chose our catalog item, print it
        cat_item = inputDataList[-1].getTopResult()
        full_path = cat_item.fullPath
        print "I was asked to launch: ", full_path

        assert full_path.startswith(PRE_TAG)
        full_path = full_path[len(PRE_TAG):]

        action = json.loads(full_path)

        field_name = action["field"]
        field_value = action["value"]
        field_def_number = action["field_def_number"]

        for table_entry in self.config["tables"]:
            table_name = table_entry["name"]
            if table_name == action["table"]:
                field_defs = table_entry["fields"]
                field_defs_entry = self.field_defs_entry_proper(
                    field_defs[field_name])
                field_def = field_defs_entry[field_def_number]
                self.do_action(field_def, field_value)
                break
        else:
            assert False


launchy.registerPlugin(LaunchySQLite)
        pass

    def getID(self):
        return self.hash

    def getName(self):
        return self.name

    def getIcon(self):
        return self.icon

    def getLabels(self, inputDataList):
        pass

    def getResults(self, inputDataList, resultsList):
        text = inputDataList[0].getText()
        resultsList.push_back(
            launchy.CatItem(text, "Play Song: " + text, self.getID(),
                            self.getIcon()))

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        catItem = inputDataList[-1].getTopResult()
        mbIPC = MusicBeeIPC()
        mbIPC.search_and_play_first(catItem.fullPath)


launchy.registerPlugin(PyMusicbeeQueue)
Beispiel #20
0
        
    def getID(self):
        return self.hash

    def getName(self):
        return self.name

    def getIcon(self):
         return self.icon
        
    def getLabels(self, inputDataList):
        pass    
        
    def getResults(self, inputDataList, resultsList):
        # Take the text from the first input item and add a new
        # Catalog item with our plugin id
        text = inputDataList[0].getText()   ### 4
        resultsList.push_back( launchy.CatItem(text,
            "PySimple: " + text,
            self.getID(), self.getIcon()) )   ### 5
        
    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        # The user chose our catalog item, print it      
        catItem = inputDataList[-1].getTopResult()  ### 6
        print "I was asked to launch: ", catItem.fullPath   ### 7
        
launchy.registerPlugin(PySimple)   ### 8
Beispiel #21
0
    def getID(self):
        return self.hash

    def getName(self):
        return self.name

    def getIcon(self):
        return self.icon

    def getLabels(self, inputDataList):
        pass

    def getResults(self, inputDataList, resultsList):
        # Take the text from the first input item and add a new
        # Catalog item with our plugin id
        text = inputDataList[0].getText()  ### 4
        resultsList.push_back(
            launchy.CatItem(text, "PySimple: " + text, self.getID(),
                            self.getIcon()))  ### 5

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItemOrig):
        # The user chose our catalog item, print it
        catItem = inputDataList[-1].getTopResult()  ### 6
        print "I was asked to launch: ", catItem.fullPath  ### 7


launchy.registerPlugin(PySimple)  ### 8
Beispiel #22
0
    def getName(self):
        return "SkeletonPlugin"

    def getIcon(self):
        return self.icon

    def getLabels(self, inputDataList):
        for inputData in inputDataList:
            print inputData.getText()

    def getResults(self, inputDataList, resultsList):
        text = inputDataList[0].getText()
        resultsList.append(
            launchy.CatItem(text, "From python: " + text, self.hash,
                            self.icon))

    def getCatalog(self, resultsList):
        pass

    def launchItem(self, inputDataList, catItem):
        print "You have chosen to launch " + catItem.fullPath

    def launchyShow(self):
        pass

    def launchyHide(self):
        pass


launchy.registerPlugin(SkeletonPlugin)
Beispiel #23
0
                volMin = volumeData[self.BEEFWEB_PARAM_MIN]
                volNew = max(volLevel - self.VOLUME_STEP, volMin)
                params = {self.BEEFWEB_PARAM_VOLUME: volNew}
            elif apiKey == 'mute':
                volumeData = self.getPlayerVolumeData()
                isMuted = volumeData[self.BEEFWEB_PARAM_IS_MUTED]
                params = {
                    self.BEEFWEB_PARAM_IS_MUTED: str(not isMuted).lower()
                }

            if apiKey in self.REST_MAPPING:
                self.postFooBarAPICommand(self.REST_MAPPING[apiKey], params)

    def postFooBarAPICommand(self, apiCommand, params):
        conn = httplib.HTTPConnection(self.BEEFWEB_HOST, self.BEEFWEB_PORT)
        requestURL = apiCommand + '?' + urllib.urlencode(
            params) if params else apiCommand
        req = conn.request('POST', requestURL)
        conn.close()

    def getPlayerVolumeData(self):
        conn = httplib.HTTPConnection(self.BEEFWEB_HOST, self.BEEFWEB_PORT)
        req = conn.request('GET', self.BEEFWEB_PLAYER_API_ROOT)
        resp = conn.getresponse()
        volumeData = json.loads(resp.read())
        conn.close()
        return volumeData[self.BEEFWEB_PARAM_PLAYER][self.BEEFWEB_PARAM_VOLUME]


launchy.registerPlugin(FooLaunchy)
Beispiel #24
0
        print_debug("PyDiry version: " + version)
        if version == "0.0":
            settings.beginWriteArray("PyDiry/dirs")
            settings.setArrayIndex(0)
            settings.setValue("name", QVariant("My Documents"))
            settings.setValue("path", QVariant("%USERPROFILE%\\My Documents"))
            settings.endArray()

        # Set our version
        settings.setValue("PyDiry/version", QVariant(self.__version__))

        self.dirs.clear()

        # Read directories from the settings file
        size = settings.beginReadArray("PyDiry/dirs")
        for i in range(0, size):
            settings.setArrayIndex(i)
            name = unicode(settings.value("name").toString())
            path = unicode(settings.value("path").toString())
            self.dirs[name] = expandvars(path)
        settings.endArray()

    def __makeShortName(self, itemPath):
        try:
            return os.path.split(itemPath)[1]
        except:
            return itemPath


launchy.registerPlugin(PyDiry)