示例#1
0
	def activate(self, leaf, iobj):
		archive_type = __kupfer_settings__["archive_type"]
		dirpath = iobj.object
		basename = os_path.basename(leaf.object)
		archive_path = \
			utils.get_destpath_in_directory(dirpath, basename, archive_type)
		utils.launch_commandline("file-roller --add-to='%s' '%s'" %
				(archive_path, leaf.object))
示例#2
0
	def run(self):
		#check if is not muted already
		#proc = subprocess.Popen('/usr/bin/amixer sget Master', shell=True, stdout=subprocess.PIPE)
		#result = str(proc.communicate())
		#if "off" not in result:
		utils.launch_commandline("amixer sset Master,0 mute", in_terminal=False)
		title, body = "Volume", "Muted"
		self.show_notification(title, body, icon_name=self.get_icon_name())
示例#3
0
def mount_volume_in_truecrypt(filepath):
	''' Mount file in Truecrypt. 
		Escape apostrophes - ie:
		"test'dk 'dlk' dsl''k '' sdkl.test" ->
		"'test'\''dk '\''dlk'\'' dsl'\'''\''k '\'''\'' sdkl.test'"
	'''
	# escape ' characters
	filepath = filepath.replace("'", "'\\''")
	utils.launch_commandline("truecrypt '%s'" % filepath)
def run_command(typ, action_data, leaf_data):
	"""Run command. Called from actions"""
	if typ == 'command':
		cmd = substitute(action_data['cmd'], leaf_data)
		env = action_data['env']
		utils.launch_commandline(cmd)
	elif typ == 'uri':
		uri = substitute(action_data['uri'], leaf_data)
		utils.show_url(uri)
示例#5
0
文件: image.py 项目: chmouel/kupfer
	def activate(self, leaf, obj=None):
		fpath = leaf.object
		dirname = os_path.dirname(fpath)
		head, ext = os_path.splitext(os_path.basename(fpath))
		filename = "%s_%s%s" % (head, self.rotation, ext)
		dpath = utils.get_destpath_in_directory(dirname, filename)
		cmdline = ("jpegtran -copy all -rotate '%s' -outfile '%s' '%s'" %
				(self.rotation, dpath, fpath))
		utils.launch_commandline(cmdline)
		return FileLeaf(dpath)
示例#6
0
文件: image.py 项目: chmouel/kupfer
	def activate(self, leaf, obj):
		size = self._make_size(obj.object)
		fpath = leaf.object
		dirname = os_path.dirname(fpath)
		head, ext = os_path.splitext(os_path.basename(fpath))
		filename = "%s_%s%s" % (head, size, ext)
		dpath = utils.get_destpath_in_directory(dirname, filename)
		cmdline = "convert -scale '%s' '%s' '%s'" % (size, fpath, dpath)
		utils.launch_commandline(cmdline)
		return FileLeaf(dpath)
示例#7
0
	def activate(self, leaf):
		if leaf.check_key(PUTTY_SESSION_KEY):
			session = leaf[PUTTY_SESSION_KEY]
			utils.launch_commandline("putty -load '%s'" % session)
		else:
			options = ['putty']
			if leaf.check_key(HOST_SERVICE_USER_KEY):
				options.append('-l ' + leaf[HOST_SERVICE_USER_KEY])
			if leaf.check_key(HOST_SERVICE_PORT_KEY):
				options.append('-P ' + leaf[HOST_SERVICE_PORT_KEY])
			options.append(leaf[HOST_ADDRESS_KEY])
			cmd = ' '.join(options)
			utils.launch_commandline(cmd)
示例#8
0
 def activate(self, leaf):
     if isinstance(leaf, UrlLeaf):
         utils.launch_commandline("vinagre %s" % leaf.object)
     else:
         service = leaf[HOST_SERVICE_NAME_KEY]
         host = leaf[HOST_ADDRESS_KEY]
         port = ""
         if leaf.check_key(HOST_SERVICE_PORT_KEY):
             port = ":" + leaf[HOST_SERVICE_PORT_KEY]
         user = ""
         if leaf.check_key(HOST_SERVICE_USER_KEY):
             user = leaf[HOST_SERVICE_USER_KEY] + "@"
         url = "%s://%s%s%s" % (service, user, host, port)
         utils.launch_commandline("vinagre %s" % url)
示例#9
0
 def activate(self, leaf, ctx=None):
     if type(leaf) == AppLeaf:
         cmd = "%s %s" % (__kupfer_settings__["sudo_command"],
                          leaf.object.get_commandline())
         ret = utils.launch_commandline(cmd)
         if ret: return ret
         pretty.print_error(__name__, "Unable to run command(s)", cmd)
     elif type(leaf) == FileLeaf:
         self.activate_multiple((leaf, ), ctx)
示例#10
0
	def activate(self, leaf):
		if type(leaf) == AppLeaf:
		    cmd = "%s %s" %(__kupfer_settings__["sudo_command"],
				leaf.object.get_commandline())
		    ret = launch_commandline(cmd)
		    if ret: return ret
		    pretty.print_error(__name__, "Unable to run command(s)", cmd)
		elif type(leaf) == FileLeaf:
			self.activate_multiple((leaf, ))
示例#11
0
def launch_commandline_with_fallbacks(commands, print_error=True):
	"""Try the sequence of @commands with utils.launch_commandline,
	and return with the first successful command.
	return False if no command is successful and log an error
	"""
	for command in commands:
		ret = utils.launch_commandline(command)
		if ret: return ret
	pretty.print_error(__name__, "Unable to run command(s)", commands)
	return False
示例#12
0
def vm_action(action, vm_uuid):
	''' change state of the virtual machine. Call VBoxManage.
		@param action - one of the const VM_*
		@param vm_uuid - virtual machine uuid
	'''
	if action == vbox_const.VM_START_NORMAL:
		utils.launch_commandline('VBoxManage startvm ' + vm_uuid + \
				' --type gui')
	elif action == vbox_const.VM_START_HEADLESS:
		utils.launch_commandline('VBoxManage startvm ' + vm_uuid + \
				' --type headless')
	else:
		command = _ACTIONS[action]
		utils.launch_commandline('VBoxManage controlvm ' + vm_uuid + ' ' + \
				command)
示例#13
0
	def activate_multiple(self, objects, iobjects=None):
		appmap = {}
		leafmap = {}
		for iobj_app in objects:
			if type(iobj_app) == AppLeaf:
			    self.activate(iobj_app)
			elif type(iobj_app) == FileLeaf:
				app = self.default_application_for_leaf(iobj_app)
				id_ = app.get_id()
				appmap[id_] = app
				leafmap.setdefault(id_, []).append(iobj_app)

		for id_, leaves in leafmap.iteritems():
			app = appmap[id_]
			cmd = "%s %s " %(__kupfer_settings__["sudo_command"],
					app.get_commandline())
			for l in leaves:
				cmd += "%s " %l.object
			ret = launch_commandline(cmd)
			if ret: return ret
			pretty.print_error(__name__, "Unable to run command(s)", cmd)
示例#14
0
    def activate_multiple(self, objects, ctx):
        appmap = {}
        leafmap = {}
        for iobj_app in objects:
            if type(iobj_app) == AppLeaf:
                self.activate(iobj_app)
            elif type(iobj_app) == FileLeaf:
                app = self.default_application_for_leaf(iobj_app)
                id_ = app.get_id()
                appmap[id_] = app
                leafmap.setdefault(id_, []).append(iobj_app)

        for id_, leaves in leafmap.items():
            app = appmap[id_]

            cmd = "%s %s " % (__kupfer_settings__["sudo_command"],
                              app.get_executable())
            for l in leaves:
                cmd += "%s " % l.object
            ret = utils.launch_commandline(cmd)
            if ret: return ret
            pretty.print_error(__name__, "Unable to run command(s)", cmd)
示例#15
0
	def run(self):
		utils.launch_commandline('claws-mail --receive-all')
示例#16
0
	def run(self):
		utils.launch_commandline('claws-mail --compose')
示例#17
0
文件: devhelp.py 项目: chmouel/kupfer
	def activate(self, leaf):
		text = leaf.object
		utils.launch_commandline("devhelp --search='%s'" % text)
示例#18
0
 def activate_multiple(self, objs):
     program = __kupfer_settings__["installation_method"]
     pkgs = " ".join(o.object.strip() for o in objs)
     utils.launch_commandline("%s %s" % (program, pkgs), in_terminal=True)
示例#19
0
文件: zim.py 项目: chmouel/kupfer
def _start_zim(notebook, page):
	''' Start zim and open given notebook and page. '''
	cli = "zim '%s' '%s'" % (notebook, page.replace("'", "_"))
	utils.launch_commandline(cli)
	def activate(self, leaf):
		cli = 'gpg --edit-key %s' % leaf.object
		utils.launch_commandline(cli, 'GnuPG', True)
示例#21
0
	def activate(self, leaf):
		sudo_cmd = __kupfer_settings__["sudo_cmd"]
		utils.launch_commandline(sudo_cmd + " " + leaf.object + " " + self._command, \
				in_terminal=True)
示例#22
0
文件: putty.py 项目: chmouel/kupfer
	def activate(self, leaf):
		session = leaf[PUTTY_SESSION_KEY]
		utils.launch_commandline("putty -load '%s'" % session)
示例#23
0
	def activate(self, leaf):
		utils.launch_commandline("tracker-search-tool %s" % leaf.object)
示例#24
0
	def activate(self, leaf, obj):
		lpath = leaf.object
		tag = obj.object
		utils.launch_commandline("tracker-tag --remove='%s' '%s'" % (obj, lpath))
示例#25
0
文件: screen.py 项目: chmouel/kupfer
 def activate(self, leaf):
     pid = leaf.object
     action = "screen -x -R %s" % pid
     utils.launch_commandline(action, name=_("GNU Screen"), in_terminal=True)
示例#26
0
 def activate(self, leaf):
     text = leaf.object
     utils.launch_commandline("gnome-dictionary --look-up='%s'" % text, _("Look Up"))
示例#27
0
 def activate_multiple(self, leaves):
     cli = ["gpg --search-keys"]
     cli.extend((contacts.email_from_leaf(leaf) for leaf in leaves))
     utils.launch_commandline(" ".join(cli), "GnuPG", True)
示例#28
0
	def activate(self, leaf):
		utils.launch_commandline("file-roller --extract-here %s" % leaf.object)
示例#29
0
	def run(self):
		if not utils.launch_commandline('thunderbird --compose'):
			utils.launch_commandline('icedove --compose')
示例#30
0
	def activate(self, leaf):
		pkg = leaf.object.strip()
		cli = "%s %s" % (__kupfer_settings__["installation_method"], pkg)
		utils.launch_commandline(cli, in_terminal=True)
示例#31
0
	def activate(self, leaf):
		email = email_from_leaf(leaf)

		if not utils.launch_commandline("thunderbird mailto:%s" % email):
			utils.launch_commandline("icedove mailto:%s" % email)
示例#32
0
	def activate(self, leaf):
		cmd = "'%s'" % leaf.object if self.quoted else leaf.object
		utils.launch_commandline(cmd, in_terminal=self.in_terminal)
示例#33
0
	def activate(self, leaf):
		session = leaf[TSCLIENT_SESSION_KEY]
		utils.launch_commandline("tsclient -x '%s'" % session)
示例#34
0
 def activate_multiple(self, leaves):
     cli = ['gpg --search-keys']
     cli.extend((contacts.email_from_leaf(leaf) for leaf in leaves))
     utils.launch_commandline(' '.join(cli), 'GnuPG', True)