示例#1
0
def get_user_leaf(gd_client, user_name):
	''' Create PicasaUser obj for given @user_name. '''
	leaf = None
	try:
		user_info = gd_client.GetContacts(user_name)
	except gdata.photos.service.GooglePhotosException, err:
		pretty.print_info(__name__, 'get_uers_leaf', err)
示例#2
0
	def _setup_plugins(self):
		"""
		@S_sources are to be included directly in the catalog,
		@s_souces as just as subitems
		"""
		from kupfer.core import plugins

		s_sources = []
		S_sources = []

		setctl = settings.GetSettingsController()
		setctl.connect("plugin-enabled-changed", self._plugin_enabled)

		for item in plugins.get_plugin_ids():
			if not setctl.get_plugin_enabled(item):
				continue
			sources = self._load_plugin(item)
			if setctl.get_plugin_is_toplevel(item):
				S_sources.extend(sources)
			else:
				s_sources.extend(sources)

		D_dirs, d_dirs = self._get_directory_sources()
		S_sources.extend(D_dirs)
		s_sources.extend(d_dirs)

		if not S_sources and not s_sources:
			pretty.print_info(__name__, "No sources found!")
		return S_sources, s_sources
示例#3
0
	def _connect(self):
		self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
		self._socket.settimeout(3)
		try:
			self._socket.connect(_SOCKET_COMMAND)
		except socket.error, err:
			pretty.print_info(err)
			raise NoDropboxRunning()
示例#4
0
 def clean_up_unarchived_files(cls):
     if not cls.unarchived_files:
         return
     pretty.print_info(__name__, "Removing extracted archives..")
     for filetree in set(cls.unarchived_files):
         pretty.print_debug(__name__, "Removing", os.path.basename(filetree))
         shutil.rmtree(filetree, onerror=cls._clean_up_error_handler)
     cls.unarchived_files = []
示例#5
0
 def clean_up_unarchived_files(cls):
     if not cls.unarchived_files:
         return
     pretty.print_info(__name__, "Removing extracted archives..")
     for filetree in set(cls.unarchived_files):
         pretty.print_debug(__name__, "Removing",
                            os.path.basename(filetree))
         shutil.rmtree(filetree, onerror=cls._clean_up_error_handler)
     cls.unarchived_files = []
示例#6
0
def load_plugin_sources(plugin_name, attr=sources_attribute, instantiate=True):
	sources = get_plugin_attribute(plugin_name, attr)
	if not sources:
		return
	for source in get_plugin_attributes(plugin_name, sources, warn=True):
		if source:
			if instantiate:
				yield source()
			else:
				yield source
		else:
			pretty.print_info(__name__, "Source not found for %s" % plugin_name)
示例#7
0
def load_plugin_sources(plugin_name, attr=sources_attribute, instantiate=True):
	sources = get_plugin_attribute(plugin_name, attr)
	if not sources:
		return
	for source in get_plugin_attributes(plugin_name, sources, warn=True):
		if source:
			if instantiate:
				yield source()
			else:
				yield source
		else:
			pretty.print_info(__name__, "Source not found for %s" % plugin_name)
示例#8
0
def get_plugin_attributes(plugin_name, attrs, warn=False):
	"""Generator of the attributes named @attrs
	to be found in plugin @plugin_name
	if the plugin is not found, we write an error
	and yield nothing.

	if @warn, we print a warning if a plugin does not have
	a requested attribute
	"""
	try:
		plugin = import_plugin(plugin_name)
	except ImportError, e:
		pretty.print_info(__name__, "Skipping plugin %s: %s" % (plugin_name, e))
		return
示例#9
0
 def get_items(self):
     try:
         import dbus
     except ImportError:
         pretty.print_info(__name__, "Dbus not available!")
         return
     bus = dbus.SessionBus()
     try:
         tobj = bus.get_object(SERVICE_NAME, SEARCH_OBJECT_PATH)
         searchobj = dbus.Interface(tobj, SEARCH_INTERFACE)
     except dbus.DBusException, exc:
         pretty.print_error(__name__, exc)
         pretty.print_error(__name__, "Could not connect to Tracker")
         return
示例#10
0
文件: plugins.py 项目: chmouel/kupfer
def get_plugin_attributes(plugin_name, attrs, warn=False):
	"""Generator of the attributes named @attrs
	to be found in plugin @plugin_name
	if the plugin is not found, we write an error
	and yield nothing.

	if @warn, we print a warning if a plugin does not have
	a requested attribute
	"""
	try:
		plugin = import_plugin(plugin_name)
	except ImportError, e:
		pretty.print_info(__name__, "Skipping plugin %s: %s" % (plugin_name, e))
		return
示例#11
0
	def get_items(self):
		try:
			import dbus
		except ImportError:
			pretty.print_info(__name__, "Dbus not available!")
			return
		bus = dbus.SessionBus()
		try:
			tobj = bus.get_object(SERVICE_NAME, SEARCH_OBJECT_PATH)
			searchobj = dbus.Interface(tobj, SEARCH_INTERFACE)
		except dbus.DBusException, exc:
			pretty.print_error(__name__, exc)
			pretty.print_error(__name__, "Could not connect to Tracker")
			return
示例#12
0
文件: launch.py 项目: chmouel/kupfer
def launch_application(app_info, files=(), uris=(), paths=(), track=True, activate=True):
	"""
	Launch @app_info correctly, using a startup notification

	you may pass in either a list of gio.Files in @files, or 
	a list of @uris or @paths

	if @track, it is a user-level application
	if @activate, activate rather than start a new version
	"""
	assert app_info

	from gtk.gdk import AppLaunchContext
	from gio import File
	from glib import GError

	ctx = AppLaunchContext()
	if paths:
		files = [File(p) for p in paths]

	if wnck:
		# launch on current workspace
		workspace = wnck.screen_get_default().get_active_workspace()
		nbr = workspace.get_number() if workspace else -1
		ctx.set_desktop(nbr)
	ctx.set_timestamp(_current_event_time())

	if track:
		app_id = application_id(app_info)
		os.putenv(kupfer_env, app_id)
	else:
		app_id = ""
	svc = GetApplicationsMatcherService()
	try:
		if activate and svc.application_is_running(app_id):
			svc.application_to_front(app_id)
			return True

		try:
			if uris:
				ret = app_info.launch_uris(uris, ctx)
			else:
				ret = app_info.launch(files, ctx)
			if not ret:
				pretty.print_info(__name__, "Error launching", app_info)
		except GError, e:
			pretty.print_info(__name__, "Error:", e)
			return False
		else:
示例#13
0
文件: multihead.py 项目: pbx/kupfer
def initialize_plugin(name):
    global pid
    ## check for multihead
    display = gtk.gdk.display_get_default()
    screen = display.get_default_screen()
    if display.get_n_screens() > 1:
        pretty.print_info(__name__, "Starting Multi X screen support")
        for idx in xrange(display.get_n_screens()):
            if idx != screen.get_number():
                pretty.print_info(__name__, "Launching keyrelay for screen", idx)
                screen_x = display.get_screen(idx)
                # run helper without respawning it
                pid = utils.start_plugin_helper("kupfer.keyrelay",
                        False, screen_x.make_display_name())
                child_pids.append(pid)
示例#14
0
def initialize_plugin(name):
	global pid
	## check for multihead
	display = gtk.gdk.display_get_default()
	screen = display.get_default_screen()
	if display.get_n_screens() > 1:
		pretty.print_info(__name__, "Starting Multi X screen support")
		for idx in xrange(display.get_n_screens()):
			if idx != screen.get_number():
				pretty.print_info(__name__, "Launching keyrelay for screen", idx)
				screen_x = display.get_screen(idx)
				# run helper without respawning it
				pid = utils.start_plugin_helper("kupfer.keyrelay",
						False, screen_x.make_display_name())
				child_pids.append(pid)
示例#15
0
文件: data.py 项目: chmouel/kupfer
	def _setup_plugins(self):
		"""
		@S_sources are to be included directly in the catalog,
		@s_souces as just as subitems
		"""
		from kupfer.core import plugins
		from kupfer.core.plugins import (load_plugin_sources, sources_attribute,
				action_decorators_attribute, text_sources_attribute,
				content_decorators_attribute,
				initialize_plugin)

		s_sources = []
		S_sources = []

		setctl = settings.GetSettingsController()

		text_sources = []
		action_decorators = []
		content_decorators = []

		for item in plugins.get_plugin_ids():
			if not setctl.get_plugin_enabled(item):
				continue
			initialize_plugin(item)
			text_sources.extend(load_plugin_sources(item, text_sources_attribute))
			action_decorators.extend(load_plugin_sources(item,
				action_decorators_attribute))
			# Register all Sources as (potential) content decorators
			content_decorators.extend(load_plugin_sources(item,
				sources_attribute, instantiate=False))
			content_decorators.extend(load_plugin_sources(item,
				content_decorators_attribute, instantiate=False))
			if setctl.get_plugin_is_toplevel(item):
				S_sources.extend(load_plugin_sources(item))
			else:
				s_sources.extend(load_plugin_sources(item))

		D_dirs, d_dirs = self._get_directory_sources()
		S_sources.extend(D_dirs)
		s_sources.extend(d_dirs)

		if not S_sources and not s_sources:
			pretty.print_info(__name__, "No sources found!")

		self.register_text_sources(text_sources)
		self.register_action_decorators(action_decorators)
		self.register_content_decorators(content_decorators)
		return S_sources, s_sources
示例#16
0
def load_kupfer_icons(scheduler):
    """Load in kupfer icons from installed files"""
    ilist = "art/icon-list"
    ilist_file_path = config.get_data_file(ilist)
    # parse icon list file
    ifile = open(ilist_file_path, "r")
    for line in ifile:
        # ignore '#'-comments
        if line.startswith("#"):
            continue
        icon_name, basename, size = (i.strip() for i in line.split("\t", 2))
        size = int(size)
        icon_path = config.get_data_file(os.path.join("art", basename))
        if not icon_path:
            pretty.print_info(__name__, "Icon", basename, icon_path, "not found")
            continue
        pixbuf = pixbuf_new_from_file_at_size(icon_path, size, size)
        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size, "from", icon_path)
示例#17
0
def _get_vbox():
	if __kupfer_settings__['force_cli']:
		pretty.print_info(__name__, 'Using cli...')
		return ose_support
	try:
		from kupfer.plugin.virtualbox import vboxapi4_support
		pretty.print_info(__name__, 'Using vboxapi4...')
		return vboxapi4_support
	except ImportError:
		pass
	try:
		from kupfer.plugin.virtualbox import vboxapi_support
		pretty.print_info(__name__, 'Using vboxapi...')
		return vboxapi_support
	except ImportError:
		pass
	pretty.print_info(__name__, 'Using cli...')
	return ose_support
示例#18
0
def _get_vbox():
    if __kupfer_settings__['force_cli']:
        pretty.print_info(__name__, 'Using cli...')
        return ose_support
    try:
        from kupfer.plugin.virtualbox import vboxapi4_support
        pretty.print_info(__name__, 'Using vboxapi4...')
        return vboxapi4_support
    except ImportError:
        pass
    try:
        from kupfer.plugin.virtualbox import vboxapi_support
        pretty.print_info(__name__, 'Using vboxapi...')
        return vboxapi_support
    except ImportError:
        pass
    pretty.print_info(__name__, 'Using cli...')
    return ose_support
示例#19
0
def _icon_theme_changed(theme):
    pretty.print_info(__name__, "Icon theme changed, clearing cache")
    global icon_cache
    icon_cache = {}
示例#20
0
文件: launch.py 项目: chmouel/kupfer
from time import time
import os
import cPickle as pickle

import gtk
import gobject

from kupfer import pretty, config
from kupfer import scheduler
from kupfer.ui import keybindings

try:
	import wnck
except ImportError, e:
	pretty.print_info(__name__, "Disabling launch module:", e)
	wnck = None

kupfer_env = "KUPFER_APP_ID"

default_associations = {
	"evince" : "Document Viewer",
	"file-roller" : "File Roller",
	#"gedit" : "Text Editor",
	"gnome-keyring-manager" : "Keyring Manager",
	"nautilus-browser" : "File Manager",
	"rhythmbox" : "Rhythmbox Music Player",
}


def _read_environ(pid, envcache=None):
	"""Read the environment for application with @pid
示例#21
0
	and yield nothing.

	if @warn, we print a warning if a plugin does not have
	a requested attribute
	"""
	try:
		plugin = import_plugin(plugin_name)
	except ImportError, e:
		pretty.print_info(__name__, "Skipping plugin %s: %s" % (plugin_name, e))
		return
	for attr in attrs:
		try:
			obj = getattr(plugin, attr)
		except AttributeError, e:
			if warn:
				pretty.print_info(__name__, "Plugin %s: %s" % (plugin_name, e))
			yield None
		else:
			yield obj

def get_plugin_attribute(plugin_name, attr):
	"""Get single plugin attribute"""
	attrs = tuple(get_plugin_attributes(plugin_name, (attr,)))
	obj, = (attrs if attrs else (None, ))
	return obj

def load_plugin_sources(plugin_name, attr=sources_attribute, instantiate=True):
	sources = get_plugin_attribute(plugin_name, attr)
	if not sources:
		return
	for source in get_plugin_attributes(plugin_name, sources, warn=True):
示例#22
0
文件: launch.py 项目: pbx/kupfer
from kupfer import pretty, config
from kupfer import scheduler
from kupfer import desktop_launch
from kupfer.ui import uievents
from kupfer import terminal

from kupfer.desktop_launch import SpawnError

## NOTE: SpawnError  *should* be imported from this module

try:
    import wnck
    wnck.set_client_type(wnck.CLIENT_TYPE_PAGER)
except ImportError, e:
    pretty.print_info(__name__, "Disabling window tracking:", e)
    wnck = None

default_associations = {
    "evince": "Document Viewer",
    "file-roller": "File Roller",
    #"gedit" : "Text Editor",
    "gnome-keyring-manager": "Keyring Manager",
    "nautilus-browser": "File Manager",
    "rhythmbox": "Rhythmbox Music Player",
}


def application_id(app_info, desktop_file=None):
    """Return an application id (string) for GAppInfo @app_info"""
    app_id = app_info.get_id()
示例#23
0
def debug_log(*args):
	pretty.print_info(__name__, *args)
示例#24
0
文件: plugins.py 项目: chmouel/kupfer
	and yield nothing.

	if @warn, we print a warning if a plugin does not have
	a requested attribute
	"""
	try:
		plugin = import_plugin(plugin_name)
	except ImportError, e:
		pretty.print_info(__name__, "Skipping plugin %s: %s" % (plugin_name, e))
		return
	for attr in attrs:
		try:
			obj = getattr(plugin, attr)
		except AttributeError, e:
			if warn:
				pretty.print_info(__name__, "Plugin %s: %s" % (plugin_name, e))
			yield None
		else:
			yield obj

def get_plugin_attribute(plugin_name, attr):
	"""Get single plugin attribute"""
	attrs = tuple(get_plugin_attributes(plugin_name, (attr,)))
	obj, = (attrs if attrs else (None, ))
	return obj

def load_plugin_sources(plugin_name, attr=sources_attribute, instantiate=True):
	sources = get_plugin_attribute(plugin_name, attr)
	if not sources:
		return
	for source in get_plugin_attributes(plugin_name, sources, warn=True):
示例#25
0
__description__ = _("Control VirtualBox Virtual Machines. "
                    "Supports both Sun VirtualBox and Open Source Edition.")
__version__ = "0.3"
__author__ = "Karol Będkowski <*****@*****.**>"

from kupfer.objects import Leaf, Action, Source
from kupfer import pretty, plugin_support
from kupfer.obj.apps import ApplicationSource

__kupfer_settings__ = plugin_support.PluginSettings(
		plugin_support.SETTING_PREFER_CATALOG,
)

try:
	from kupfer.plugin.virtualbox import vboxapi_support as vbox_support
	pretty.print_info(__name__, 'Using vboxapi...')
except ImportError, err:
	from kupfer.plugin.virtualbox import ose_support as vbox_support
	pretty.print_info(__name__, 'Using cli...', err)

from kupfer.plugin.virtualbox import constants as vbox_const


class VirtualMachine(Leaf):
	def __init__(self, obj, name, description):
		Leaf.__init__(self, obj, name)
		self.description = description

	def get_description(self):
		return self.description
示例#26
0
def _icon_theme_changed(theme):
	pretty.print_info(__name__, "Icon theme changed, clearing cache")
	global icon_cache
	icon_cache = {}
示例#27
0
from kupfer import scheduler
from kupfer import desktop_launch
from kupfer.ui import uievents
from kupfer import terminal

from kupfer.desktop_launch import SpawnError

## NOTE: SpawnError  *should* be imported from this module

try:
    import gi
    gi.require_version("Wnck", "3.0")
    from gi.repository import Wnck
    Wnck.set_client_type(Wnck.ClientType.PAGER)
except ValueError as e:
    pretty.print_info(__name__, "Disabling window tracking:", e)
    Wnck = None

default_associations = {
    "evince": "Document Viewer",
    "file-roller": "File Roller",
    #"gedit" : "Text Editor",
    "gnome-keyring-manager": "Keyring Manager",
    "nautilus-browser": "File Manager",
    "rhythmbox": "Rhythmbox Music Player",
}


def application_id(app_info, desktop_file=None):
    """Return an application id (string) for GAppInfo @app_info"""
    app_id = app_info.get_id()