def _new_syncset(self): ss = SyncSet.SyncSet(moduleManager=self.moduleManager, syncManager=self.sync_manager) i = Utils.uuid_string() new = SyncSetDBusItem(ss, i) EXPORTED_OBJECTS[new.get_path()] = new return new
def __init__(self, syncManager, uid=""): """ Makes and empty conduit ready to hold one datasource and many datasinks """ gobject.GObject.__init__(self) self.syncManager = syncManager if uid == "": self.uid = Utils.uuid_string() else: self.uid = uid #a conduit can hold one datasource and many datasinks (wrappers) self.datasource = None self.datasinks = [] self.twoWaySyncEnabled = False self.slowSyncEnabled = False self.autoSyncEnabled = False self.conflictPolicy = "" self.deletedPolicy = "" #set conduits to have the default conflict/deleted policy for policyName in CONFLICT_POLICY_NAMES: policyValue = conduit.GLOBALS.settings.get("default_policy_%s" % policyName) self.set_policy(policyName, policyValue) self._conflicts = {}
def __init__(self, syncManager, uid=""): """ Makes and empty conduit ready to hold one datasource and many datasinks """ gobject.GObject.__init__(self) self.syncManager = syncManager if uid == "": self.uid = Utils.uuid_string() else: self.uid = uid #a conduit can hold one datasource and many datasinks (wrappers) self.datasource = None self.datasinks = [] self.twoWaySyncEnabled = False self.slowSyncEnabled = False self.autoSyncEnabled = False self.conflictPolicy = "" self.deletedPolicy = "" #set conduits to have the default conflict/deleted policy for policyName in CONFLICT_POLICY_NAMES: policyValue = conduit.GLOBALS.settings.get("default_policy_%s" % policyName) self.set_policy(policyName,policyValue) self._conflicts = {}
def _new_syncset(self): ss = SyncSet.SyncSet( moduleManager=self.moduleManager, syncManager=self.sync_manager ) i = Utils.uuid_string() new = SyncSetDBusItem(ss, i) EXPORTED_OBJECTS[new.get_path()] = new return new
def _get_dataprovider(self, key): """ Instantiates a new dataprovider (source or sink), storing it appropriately. @param key: Key of the DP to create @returns: The new DP """ dpw = self.moduleManager.get_module_wrapper_with_instance(key) if dpw == None: raise ConduitException("Could not find dataprovider with key: %s" % key) i = Utils.uuid_string() new = DataProviderDBusItem(dpw, i) EXPORTED_OBJECTS[new.get_path()] = new return new
def _get_conduit(self, source=None, sink=None, sender=None): """ Instantiates a new dataprovider (source or sink), storing it appropriately. @param key: Key of the DP to create @returns: The new DP """ if sender == None: raise ConduitException("Invalid DBus Caller") cond = Conduit.Conduit(self.sync_manager) if source != None: if not cond.add_dataprovider(dataprovider_wrapper=source, trySourceFirst=True): raise ConduitException("Error adding source to conduit") if sink != None: if not cond.add_dataprovider(dataprovider_wrapper=sink, trySourceFirst=False): raise ConduitException("Error adding source to conduit") i = Utils.uuid_string() new = ConduitDBusItem(self.sync_manager, cond, i) EXPORTED_OBJECTS[new.get_path()] = new return new
def add(self, obj): LUID = Utils.uuid_string() self._commit(LUID, CHANGE_ADDED, self._data_to_blob(obj)) return LUID
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) s = Utils.get_user_string() ok("user string: %s" % s, len(s) > 0 and type(s) == str) #test command line processing ok("Cmd executed", len(Utils.exec_command_and_return_result("ls",".")) > 0) ok("Cmd with wrong args", Utils.exec_command_and_return_result("ls","does-not-exist") == None) ok("Cmd that doesnt exist", Utils.exec_command_and_return_result("cmd-does-not-exist",".") == None) ts = 0 dt = Utils.datetime_from_timestamp(ts) ok("Datetime to unix timestamp", Utils.datetime_get_timestamp(dt) == ts) ok("Unix timestamp to datetime", Utils.datetime_from_timestamp(ts) == dt) m = Memstats.Memstats()