from sqlite3 import dbapi2 as sqlite import conduit import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.dataproviders.DataProvider as DataProvider import conduit.datatypes.Audio as Audio from gettext import gettext as _ BANSHEE_INSTALLED = False BANSHEE_VERSION_1 = False BANSHEE_BASE_LOCATION = "" if Utils.program_installed("banshee-1"): BANSHEE_INSTALLED = True BANSHEE_VERSION_1 = True import gconf BANSHEE_BASE_LOCATION = "file://%s/" % gconf.Client().get_string( "/apps/banshee-1/library/base_location" ) elif Utils.program_installed("banshee"): BANSHEE_INSTALLED = True if BANSHEE_INSTALLED: MODULES = { "BansheeSource" : { "type": "dataprovider" } } else: MODULES = {} (ID_IDX, NAME_IDX, CHECKED_IDX, TYPE_IDX) = range( 4 )
import conduit.datatypes.Photo as Photo import conduit.utils as Utils import logging log = logging.getLogger('modules.Shotwell') from gettext import gettext as _ try: import shotwell except ImportError: Utils.dataprovider_add_dir_to_path(__file__) import shotwell if Utils.program_installed("shotwell"): MODULES = {"ShotwellDataProvider": {"type": "dataprovider"}} else: MODULES = {} log.info("Shotwell not installed") # Why is this not in the standard library? def _flatten(lst): for elem in lst: if type(elem) in (tuple, list): for i in _flatten(elem): yield i else: yield elem
import glib import urllib import os.path import xml.sax import xml.etree.ElementTree as ET import logging log = logging.getLogger("modules.Rhythmbox") import conduit import conduit.dataproviders.DataProvider as DataProvider import conduit.utils as Utils import conduit.datatypes.Audio as Audio from gettext import gettext as _ if Utils.program_installed("rhythmbox"): MODULES = { "RhythmboxSource" : { "type": "dataprovider" }, } else: MODULES = {} #list store column define NAME_IDX=0 CHECK_IDX=1 #Rhythmbox moved its xml files from ~/.gnome2 -> XDG_USER_DATA_DIR def _get_rhythmbox_xml_path(xml): for base in (glib.get_user_data_dir(),os.path.expanduser("~/.gnome2")): path = os.path.join(base,"rhythmbox",xml)
import conduit import conduit.Exceptions as Exceptions import conduit.dataproviders.DataProvider as DataProvider import conduit.utils as Utils import conduit.datatypes.Audio as Audio import dbus try: import dbus.glib except ImportError: from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) from gettext import gettext as _ if Utils.program_installed("rhythmbox"): MODULES = { "RhythmboxDBusSource": { "type": "dataprovider" }, } else: MODULES = {} #list store column define NAME_IDX = 0 CHECK_IDX = 1 DBusPath = "com.googecode.airmindprojects.Rhythmbox"
import datetime import gobject from gettext import gettext as _ import logging log = logging.getLogger("modules.Evolution") import conduit import conduit.dataproviders.DataProvider as DataProvider import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.datatypes.Contact as Contact import conduit.datatypes.Event as Event import conduit.datatypes.Note as Note MODULES = {} if Utils.program_installed("evolution"): try: import evolution if evolution.__version__ >= (0, 0, 4): MODULES = { "EvoContactTwoWay": { "type": "dataprovider" }, "EvoCalendarTwoWay": { "type": "dataprovider" }, "EvoTasksTwoWay": { "type": "dataprovider" }, "EvoMemoTwoWay": { "type": "dataprovider"
import logging import string log = logging.getLogger("modules.Tomboy") import conduit import conduit.TypeConverter as TypeConverter import conduit.dataproviders.DataProvider as DataProvider import conduit.dataproviders.AutoSync as AutoSync import conduit.Exceptions as Exceptions import conduit.datatypes.Note as Note import conduit.datatypes.File as File import conduit.utils as Utils from gettext import gettext as _ if Utils.program_installed("tomboy"): MODULES = { "TomboyNoteTwoWay": { "type": "dataprovider" }, "TomboyNoteConverter": { "type": "converter" } } else: MODULES = {} class TomboyNote(Note.Note): """ Stores both the text and xml representations of the note
import gobject import dbus import logging log = logging.getLogger("modules.Fspot") import conduit import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.dataproviders.DataProvider as DataProvider import conduit.datatypes.Photo as Photo from conduit.datatypes import Rid import conduit.dataproviders.Image as Image from gettext import gettext as _ if Utils.program_installed("f-spot"): MODULES = { "FSpotDbusTwoWay": { "type": "dataprovider" }, } else: MODULES = {} NAME_IDX = 0 ID_IDX = 1 class FSpotDbusTwoWay(Image.ImageTwoWay): _name_ = _("F-Spot") _description_ = _("Synchronize your F-Spot photos")
import conduit.dataproviders.DataProvider as DataProvider import conduit.datatypes.Photo as Photo import conduit.utils as Utils import logging log = logging.getLogger('modules.Shotwell') from gettext import gettext as _ try: import shotwell except ImportError: Utils.dataprovider_add_dir_to_path(__file__) import shotwell if Utils.program_installed("shotwell"): MODULES = { "ShotwellDataProvider" : { "type": "dataprovider" } } else: MODULES = {} log.info("Shotwell not installed") # Why is this not in the standard library? def _flatten(lst): for elem in lst: if type(elem) in (tuple, list): for i in _flatten(elem): yield i else: yield elem
import gobject import dbus import logging log = logging.getLogger("modules.Fspot") import conduit import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.dataproviders.DataProvider as DataProvider import conduit.datatypes.Photo as Photo from conduit.datatypes import Rid import conduit.dataproviders.Image as Image from gettext import gettext as _ if Utils.program_installed("f-spot"): MODULES = { "FSpotDbusTwoWay" : { "type": "dataprovider" }, } else: MODULES = {} NAME_IDX = 0 ID_IDX = 1 class FSpotDbusTwoWay(Image.ImageTwoWay): _name_ = _("F-Spot") _description_ = _("Synchronize your F-Spot photos") _category_ = conduit.dataproviders.CATEGORY_PHOTOS _icon_ = "f-spot" _configurable_ = True
# w,h = Utils.get_proportional_resize(604,604,480,640) # ok("Resized Image into facebook dimensions (%sx%s)" % (w,h), w==453 and h==604) w,h = Utils.get_proportional_resize(100,-1,200,100) ok("Resized Image in one dimension OK", w==100 and h==50) w,h = Utils.get_proportional_resize(-1,1000,200,100) ok("Resized Image in one dimension OK", w==2000 and h==1000) w,h = Utils.get_proportional_resize(200,1000,200,100) ok("Resized Image in both dimension OK", w==2000 and h==1000) w,h = Utils.get_proportional_resize(2000,100,200,100) ok("Resized Image in both dimension OK", w==2000 and h==1000) w,h = Utils.get_proportional_resize(10,5,200,100) ok("Resized Image in both dimension OK", w==10 and h==5) ok("Resized Image returns integers", type(w)==int and type(h)==int) ok("Test program installed finds sh", Utils.program_installed('sh')) ok("Test program installed doesnt find foobar", Utils.program_installed('foobar') == False) fileuri = Utils.new_tempfile("bla").get_local_uri() ok("New tempfile: %s" % fileuri, os.path.isfile(fileuri)) tmpdiruri = Utils.new_tempdir() ok("New tempdir: %s" % tmpdiruri, os.path.isdir(tmpdiruri)) ok("Unique list keep order", Utils.unique_list([1,1,2,2,3,3,5,5,4,4]) == [1,2,3,5,4]) s = Utils.random_string() ok("Random string: %s" % s, len(s) > 0 and type(s) == str) s = Utils.md5_string('Foo') ok("md5 string: %s" % s, len(s) > 0 and type(s) == str) s = Utils.uuid_string() ok("uuid string: %s" % s, len(s) > 0 and type(s) == str)
import logging import string log = logging.getLogger("modules.Tomboy") import conduit import conduit.TypeConverter as TypeConverter import conduit.dataproviders.DataProvider as DataProvider import conduit.dataproviders.AutoSync as AutoSync import conduit.Exceptions as Exceptions import conduit.datatypes.Note as Note import conduit.datatypes.File as File import conduit.utils as Utils from gettext import gettext as _ if Utils.program_installed("tomboy"): MODULES = { "TomboyNoteTwoWay" : { "type": "dataprovider" }, "TomboyNoteConverter" : { "type": "converter" } } else: MODULES = {} class TomboyNote(Note.Note): """ Stores both the text and xml representations of the note """ def __init__(self, title, contents, xml): Note.Note.__init__(self, title, contents) self.xml = xml
import datetime import gobject from gettext import gettext as _ import logging log = logging.getLogger("modules.Evolution") import conduit import conduit.dataproviders.DataProvider as DataProvider import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.datatypes.Contact as Contact import conduit.datatypes.Event as Event import conduit.datatypes.Note as Note MODULES = {} if Utils.program_installed("evolution"): try: import evolution if evolution.__version__ >= (0,0,4): MODULES = { "EvoContactTwoWay" : { "type": "dataprovider" }, "EvoCalendarTwoWay" : { "type": "dataprovider" }, "EvoTasksTwoWay" : { "type": "dataprovider" }, "EvoMemoTwoWay" : { "type": "dataprovider" }, } log.info("Module Information: %s" % Utils.get_module_information(evolution, '__version__')) if evolution.__version__ <= (2,2,2): #Work around bug #561354 import bonobo except ImportError: log.info("Evolution support disabled (please install evolution bindings)")
#python 2.5 from sqlite3 import dbapi2 as sqlite import conduit import conduit.utils as Utils import conduit.Exceptions as Exceptions import conduit.dataproviders.DataProvider as DataProvider import conduit.datatypes.Audio as Audio from gettext import gettext as _ BANSHEE_INSTALLED = False BANSHEE_VERSION_1 = False BANSHEE_BASE_LOCATION = "" if Utils.program_installed("banshee-1"): BANSHEE_INSTALLED = True BANSHEE_VERSION_1 = True import gconf BANSHEE_BASE_LOCATION = "file://%s/" % gconf.Client().get_string( "/apps/banshee-1/library/base_location") elif Utils.program_installed("banshee"): BANSHEE_INSTALLED = True if BANSHEE_INSTALLED: MODULES = {"BansheeSource": {"type": "dataprovider"}} else: MODULES = {} (ID_IDX, NAME_IDX, CHECKED_IDX, TYPE_IDX) = range(4) (SMART_PLAYLIST, NORMAL_PLAYLIST,