Esempio n. 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))
Esempio n. 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())
Esempio n. 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)
Esempio n. 5
0
	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)
Esempio n. 6
0
	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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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, ))
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 15
0
	def run(self):
		utils.launch_commandline('claws-mail --receive-all')
Esempio n. 16
0
	def run(self):
		utils.launch_commandline('claws-mail --compose')
Esempio n. 17
0
	def activate(self, leaf):
		text = leaf.object
		utils.launch_commandline("devhelp --search='%s'" % text)
Esempio n. 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)
Esempio n. 19
0
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)
Esempio n. 21
0
	def activate(self, leaf):
		sudo_cmd = __kupfer_settings__["sudo_cmd"]
		utils.launch_commandline(sudo_cmd + " " + leaf.object + " " + self._command, \
				in_terminal=True)
Esempio n. 22
0
	def activate(self, leaf):
		session = leaf[PUTTY_SESSION_KEY]
		utils.launch_commandline("putty -load '%s'" % session)
Esempio n. 23
0
	def activate(self, leaf):
		utils.launch_commandline("tracker-search-tool %s" % leaf.object)
Esempio n. 24
0
	def activate(self, leaf, obj):
		lpath = leaf.object
		tag = obj.object
		utils.launch_commandline("tracker-tag --remove='%s' '%s'" % (obj, lpath))
Esempio n. 25
0
 def activate(self, leaf):
     pid = leaf.object
     action = "screen -x -R %s" % pid
     utils.launch_commandline(action, name=_("GNU Screen"), in_terminal=True)
Esempio n. 26
0
 def activate(self, leaf):
     text = leaf.object
     utils.launch_commandline("gnome-dictionary --look-up='%s'" % text, _("Look Up"))
Esempio n. 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)
Esempio n. 28
0
	def activate(self, leaf):
		utils.launch_commandline("file-roller --extract-here %s" % leaf.object)
Esempio n. 29
0
	def run(self):
		if not utils.launch_commandline('thunderbird --compose'):
			utils.launch_commandline('icedove --compose')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 33
0
	def activate(self, leaf):
		session = leaf[TSCLIENT_SESSION_KEY]
		utils.launch_commandline("tsclient -x '%s'" % session)
Esempio n. 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)