コード例 #1
0
ファイル: contacts_google.py プロジェクト: kichkasch/pisi
    def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
        """
        Constructor
        
        Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
        Local variables are initialized.
        The settings from the configuration file are loaded. 
        The connection to the Google Gdata backend is established.

        @param modulesString: is a small string to help you make a unique id. It is the two modules configuration-names concatinated.
        @param config: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param configsection: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param folder: is a string with the location for where your module can save its own files if necessary
        @param verbose: should make your module "talk" more
        @param soft: should tell you if you should make changes (ie. save)
        """
        contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "Google contacts")
        pisitools.GDataSyncer.__init__(self, config.get(configsection,'user'), config.get(configsection,'password'))
        self.verbose = verbose
        pisiprogress.getCallback().verbose("Google contacts module loaded")

        self._idMappingInternalGlobal = {}
        self._idMappingGlobalInternal = {}

        self._gd_client = gdata.contacts.service.ContactsService()
        self._google_client = self._gd_client
        self._doGoogleLogin(GOOGLE_CONTACTS_APPNAME)
コード例 #2
0
ファイル: calendar_google.py プロジェクト: kichkasch/pisi
 def load(self):
     """
     Load all data from backend
     
     A single query is performed and the result set is parsed afterwards.
     """
     pisiprogress.getCallback().verbose("Google Calendar: Loading")        
     feed = self.cal_client.GetCalendarEventFeed('/calendar/feeds/'+self.calendarid+'/private/full?max-results=%d' %(GOOGLE_CALENDAR_MAXRESULTS))
     pisiprogress.getCallback().progress.setProgress(20) # we guess that the actual query took up 20 % of the time - the remaining 80 % are taken by parsing the content ...
     pisiprogress.getCallback().update('Loading')
     count = 0
     inTotal = len(feed.entry)        
     for i, an_event in enumerate(feed.entry):
         globalId,  updated, attributes = self._geventToPisiEvent(an_event)
         if globalId == None:
             globalId = events.assembleID()
             tmpEvent = events.Event( globalId, updated, attributes )
             tmpEvent.attributes['globalid'] = globalId
             self.replaceEvent(globalId,  tmpEvent)
         else:
             tmpEvent = events.Event( globalId, updated, attributes)
         self._allEvents[globalId] = tmpEvent
         self._googleevents[globalId] = an_event
         count+=1
         pisiprogress.getCallback().progress.setProgress(20 + ((count*80) / inTotal))
         pisiprogress.getCallback().update('Loading')
コード例 #3
0
ファイル: contacts_vcf.py プロジェクト: kichkasch/pisi
 def _promptFilename(self, prompt, default=None, description=None):
     """
     Asks for user input on console
     """
     if description:
         pisiprogress.getCallback().message(description)
     return pisiprogress.getCallback().promptFilename(prompt, default)
コード例 #4
0
ファイル: pisi.py プロジェクト: kichkasch/pisi
def readConfiguration():
    """
    Loads configuration from the configuration file and returns the container with all the information as well as the config folder
    """
    configfolder = os.path.join(os.environ.get('HOME'), '.pisi')
    pisiprogress.getCallback().verbose("Reading configfile: %s" %(getConfigLocation()) )
    config = getConfiguration()
    return config, configfolder
コード例 #5
0
ファイル: contacts.py プロジェクト: kichkasch/pisi
    def replaceContact( self, id, updatedContact):
        """
        Replaces an existing contact entry with a new one.

        One entry is added to the history list (L{_history}) with action id for 'replace' and the old instance is replaced by the new one in the contacts dictionary (L{_allContacts}).
        """
        pisiprogress.getCallback().verbose("We will replace contact %s" %(id))
        self.replaceEntry(id, updatedContact)
        self._history.append([ACTIONID_MODIFY,  id])
コード例 #6
0
ファイル: contacts.py プロジェクト: kichkasch/pisi
 def removeContact( self, id ):
     """
     Removes a contact entry
     
     One entry is added to the history list (L{_history}) with action id for 'delete' and the instance is as well removed from the contacts dictionary (L{_allContacts}).
     """
     pisiprogress.getCallback().verbose("We will delete contact %s" %(id))
     self.removeEntry(id)
     self._history.append([ACTIONID_DELETE,  id])
コード例 #7
0
ファイル: calendar_remoteics.py プロジェクト: kichkasch/pisi
 def saveModifications(self):
     """
     Modifications are applied by local ICS module - the new file is uploaded to the original location.
     """
     pisiprogress.getCallback().verbose("Remote ICalendar module: I apply %d changes now" %(len(self._history)))
     if len(self._history) == 0:
         return      # don't touch anything if there haven't been any changes
         
     calendar_ics.SynchronizationModule.saveModifications(self)
     self.upload()
     self.cleanup()
コード例 #8
0
ファイル: contacts_ldap.py プロジェクト: kichkasch/pisi
    def saveModifications( self ):
        """
        Stub: To save all changes that have come by
        
        Saving for LDAP is not yet implemented. This function only raIses an exception (L{ValueError}), informing about this status of implementation.
        """
        pisiprogress.getCallback().verbose("LDAP module: I would apply %d changes now" %(len(self._history)))
        if len(self._history) == 0:
            return      # don't touch anything if there haven't been any changes

        raise ValueError("LDAP module not (yet) writable!")
コード例 #9
0
ファイル: contacts_google.py プロジェクト: kichkasch/pisi
 def _unpackGoogleTitle(self, atts, gtitle):
     """
     Takes the components of a Google Title apart (all names)
     
     The whole thing is about guessing - check code for details.
     """
     pisiprogress.getCallback().verbose("Google Contacts: Loading")
     title,  first,  last,  middle = pisitools.parseFullName(gtitle)
     atts['title'] = title
     atts['firstname'] = first
     atts['lastname'] = last
     atts['middlename'] = middle
コード例 #10
0
ファイル: contacts_sqlite3.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     The settings from the configuration file are loaded. 
     """
     contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "SQLite")
     self._dbpath = config.get(configsection,'database')
     pisiprogress.getCallback().verbose('contact sqlite module loaded using file %s' % (self._dbpath))
     self._idMappingInternalGlobal = {}
     self._idMappingGlobalInternal = {}
コード例 #11
0
ファイル: calendar_ics.py プロジェクト: kichkasch/pisi
 def load(self):
     """
     Load all data from local ICS file
     
     File is opened and the entries are parsed. For each entry an L{events.events.Event} instance is created and stored in the instance dictionary.
     """
     pisiprogress.getCallback().verbose("ICalendar: Loading")
     file = None
     try:
         file = open(self._path,  "r")
     except IOError,  e:
         pisiprogress.getCallback().error("--> Error: Could not load ICS file - we still carry on with processing:\n\t%s" %(e))
         return
コード例 #12
0
ファイル: calendar_ics.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{events.AbstractCalendarSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     The settings from the configuration file are loaded.
     """
     events.AbstractCalendarSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "ICalendar file")
     self._folder = folder
     self._path = config.get(configsection,'path')
     pisiprogress.getCallback().verbose('ics-module using file %s' % (self._path))
     self._rawData = {}
コード例 #13
0
ファイル: contacts_syncml.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     """
     contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "SyncML")
     pisiprogress.getCallback().verbose('contact syncml module loaded')
     self._url = config.get(configsection,'url')
     self._username = config.get(configsection,'username')
     self._password = config.get(configsection,'password')
     self._database = config.get(configsection,'database')
     self._mapping = {}
コード例 #14
0
ファイル: contacts_ldap.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     The settings from the configuration file are loaded. 
     """
     contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "LDAP")
     self._ldapHost = config.get(configsection,'ldapHost')
     self._ldapDomain = config.get(configsection,'ldapDomain')
     self._ldapFilter = config.get(configsection,'ldapFilter')
     self._ldapUser = config.get(configsection,'ldapUser')
     self._ldapPassword = config.get(configsection,'ldapPassword')
     pisiprogress.getCallback().verbose('contact ldap module loaded using host %s' % (self._ldapHost))
コード例 #15
0
ファイル: contacts_ldap.py プロジェクト: kichkasch/pisi
    def load(self):
        """
        Loads all attributes for all contact items from LDAP repository
        
        For each entry a new L{contacts.contacts.Contact} instance is created and stored in the instance dictionary L{contacts.AbstractContactSynchronizationModule._allContacts}.
        """
        pisiprogress.getCallback().verbose("LDAP: Loading")
        l = ldap.initialize("ldap://" + self._ldapHost)
        l.simple_bind_s(self._ldapUser,self._ldapPassword)
        res = l.search_s(self._ldapDomain, ldap.SCOPE_SUBTREE, self._ldapFilter)
        l.unbind()
        pisiprogress.getCallback().progress.setProgress(20)     # we guess that the actual query took up 20 % of the time - the remaining 80 % are taken by parsing the content ...
        pisiprogress.getCallback().update('Loading')
        i=0
        for cn,  contactEntry in res:
            atts = {}
            
            atts['firstname'] = self._extractAtt(contactEntry, "givenName")
            atts['middlename'] = self._extractAtt(contactEntry, "mozillaNickname")
            atts['lastname'] = self._extractAtt(contactEntry,"sn")
            atts['title'] = self._extractAtt(contactEntry,"title")
            
            atts['email'] = self._extractAtt(contactEntry,"mail")
            atts['mobile'] = self._extractAtt(contactEntry,"mobile")
            atts['phone'] = self._extractAtt(contactEntry,"homePhone")  
            atts['officePhone'] = self._extractAtt(contactEntry,"telephoneNumber")
            atts['fax'] = self._extractAtt(contactEntry,"facsimileTelephoneNumber")

            atts['homeStreet'] = self._extractAtt(contactEntry,  "mozillaHomeStreet")
            atts['homePostalCode'] = self._extractAtt(contactEntry,  "mozillaHomePostalCode")   
            atts['homeCity'] = self._extractAtt(contactEntry,  "mozillaHomeLocalityName") 
            atts['homeCountry'] = self._extractAtt(contactEntry,  "mozillaHomeCountryName")   
            atts['homeState'] = self._extractAtt(contactEntry,  "mozillaHomeState") 

            atts['businessOrganisation'] = self._extractAtt(contactEntry,  "o")
            atts['businessDepartment'] = self._extractAtt(contactEntry,  "ou")
            atts['businessPostalCode'] = self._extractAtt(contactEntry,  "postalCode")
            atts['businessStreet'] = self._extractAtt(contactEntry,  "street")
            atts['businessCity'] = self._extractAtt(contactEntry,  "l")
            atts['businessCountry'] = self._extractAtt(contactEntry,  "c")
            atts['businessState'] = self._extractAtt(contactEntry,  "st")

            id = contacts.assembleID(atts)
            c = contacts.Contact(id,  atts)
            self._allContacts[id] = c            
            i+=1
            pisiprogress.getCallback().progress.setProgress(20 + ((i*80) / len(res)))
            pisiprogress.getCallback().update('Loading')
コード例 #16
0
ファイル: calendar_remoteics.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Local variables are initialized.
     The settings from the configuration file are loaded.
     Super class constructors are called.
     """
     self._url = config.get(configsection,'url')
     self._file = config.get(configsection,'file')
     self._username = config.get(configsection,'username')
     self._password = config.get(configsection,'password')
     config.set(configsection, 'path', FILEDOWNLOAD_TMPFILE) # for constructor of superclass
     pisiprogress.getCallback().verbose('remote ics-module using server %s' % (self._url))
     calendar_ics.SynchronizationModule.__init__(self,  modulesString,  config,  configsection,  folder, verbose,  soft)
     generic_remote.RemoteRessourceHandler.__init__(self, self._url, self._file, FILEDOWNLOAD_TMPFILE, self._username, self._password)
コード例 #17
0
ファイル: contacts_opimd.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     """
     contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "OPIMD")
     pisiprogress.getCallback().verbose('contact opimd module loaded using file')
     try:
         mode = config.get(configsection, CONF_FIELDSUPPORT)
         self._fieldSupport = mode and mode.lower() == "true"
     except:
         self._fieldSupport = True         
     self._idMappingInternalGlobal = {}
     self._idMappingGlobalInternal = {}
コード例 #18
0
ファイル: calendar_syncml.py プロジェクト: kichkasch/pisi
 def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{events.AbstractCalendarSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     The settings from the configuration file are loaded. 
     The connection to the Google Gdata backend is established.
     """
     events.AbstractCalendarSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "Syncml Calendar")
     pisiprogress.getCallback().verbose('calendar syncml module loaded')
     self._url = config.get(configsection,'url')
     self._username = config.get(configsection,'username')
     self._password = config.get(configsection,'password')
     self._database = config.get(configsection,'database')
     self._mapping = {}
コード例 #19
0
ファイル: calendar_ics.py プロジェクト: kichkasch/pisi
 def saveModifications(self):
     """
     Save whatever changes have come by
     
     Iterates the history of actions and replaces the corresponding items with new vobject instances.
     In the end, the vobject representation is written to the ICS file.
     """
     pisiprogress.getCallback().verbose("ICalendar module: I apply %d changes now" %(len(self._history)))
     if len(self._history) == 0:
         return      # don't touch anything if there haven't been any changes
         
     # rename old file         
     try:
         bakFilename = os.path.join(self._folder,  os.path.basename(self._path))
         os.rename(self._path,  bakFilename)
     except OSError,  e:
         pisiprogress.getCallback().verbose("\tError when backing up old ICS file - we still carry on with processing:\n\t%s" %(e))
コード例 #20
0
ファイル: calendar_dummy.py プロジェクト: kichkasch/pisi
    def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
        """
        Constructor
        
        Super class constructor (L{events.AbstractCalendarSynchronizationModule.__init__}) is called.
        Local variables are initialized.
        The settings from the configuration file are loaded. 

        @param modulesString: is a small string to help you make a unique id. It is the two modules configuration-names concatinated.
        @param config: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param configsection: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param folder: is a string with the location for where your module can save its own files if necessary
        @param verbose: should make your module "talk" more
        @param soft: should tell you if you should make changes (ie. save)
        """
        events.AbstractCalendarSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "Calendar DUMMY")
        self.verbose = verbose
        pisiprogress.getCallback().verbose("Dummy module loaded")
コード例 #21
0
ファイル: contacts_vcf.py プロジェクト: kichkasch/pisi
 def __init__(self, modulesString, config, configsection, folder, verbose=False, soft=False):
     """
     Constructor
     
     Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
     Local variables are initialized.
     The settings from the configuration file are loaded.
     """
     contacts.AbstractContactSynchronizationModule.__init__(
         self, verbose, soft, modulesString, config, configsection, "VCF"
     )
     self._vcfpath = config.get(configsection, "vcfpath")
     try:
         self._defaultPhone = config.get(configsection, "default_phonetype")
     except:
         self._defaultPhone = DEFAULT_PHONETYPE
     self._folder = folder
     pisiprogress.getCallback().verbose("contact VCF module loaded using file %s" % (self._vcfpath))
     self._rawData = {}
コード例 #22
0
ファイル: contactsSync.py プロジェクト: kichkasch/pisi
def _askConfirmation(source,  idList):
    """
    Use interaction for choosing which contact entry to keep in case of a conflict
    
    @return: A dictionary which contains the action for each conflict entry; the key is the id of the contact entry, 
    the value one out of a - keep entry from first source, b - keep value from second source and s - skip this entry (no change on either side)
    
    The call is passed on to L{pisiprogress.AbstractCallback.askConfirmation}
    """
    return pisiprogress.getCallback().askConfirmation(source,  idList)
コード例 #23
0
ファイル: calendar_google.py プロジェクト: kichkasch/pisi
 def _commitModifications(self):
     """
     Makes changes permanent
     """
     pisiprogress.getCallback().verbose("Commiting Google-calendar modifications")
     response_feed = self.cal_client.ExecuteBatch(self.batchOperations, '/calendar/feeds/'+self.calendarid+'/private/full/batch')
     for entry in response_feed.entry:
         try:
             pisiprogress.getCallback().verbose('batch id: %s' % (entry.batch_id.text))
             pisiprogress.getCallback().verbose('status: %s' % (entry.batch_status.code))
             pisiprogress.getCallback().verbose('reason: %s' % (entry.batch_status.reason))
         except AttributeError:
             print "<<",  entry.content.text,  entry.title.text, "\n",  entry
コード例 #24
0
ファイル: contacts_vcf.py プロジェクト: kichkasch/pisi
    def saveModifications(self):
        """
        Save whatever changes have come by
        
        We first make a backup of the old file. Then, the entire set of information is dumped into a new file. (I hope, you don't mind the order of your entries).
        Thereby, we shouldn't create entries from the scratch when they were not changed in the meantime (in the likely case of PISI not supporting all fields
        within the VCF format and file).
        """
        pisiprogress.getCallback().verbose("VCF module: I apply %d changes now" % (len(self._history)))

        if len(self._history) == 0:
            return  # don't touch anything if there haven't been any changes

        # rename old file
        try:
            bakFilename = os.path.join(self._folder, os.path.basename(self._vcfpath))
            os.rename(self._vcfpath, bakFilename)
        except OSError, e:
            pisiprogress.getCallback().verbose(
                "\tError when backing up old VCF file - we still carry on with processing:\n\t%s" % (e)
            )
コード例 #25
0
ファイル: contacts_google.py プロジェクト: kichkasch/pisi
 def saveModifications(self ):
     """
     Save whatever changes have come by
     
     The L{_history} variable is iterated. The corresponding function is called for each action.
     """
     i=0
     for listItem in self._history:
         action = listItem[0]
         id = listItem[1]
         if action == ACTIONID_ADD:
             pisiprogress.getCallback().verbose("\t\t<google contacts> adding %s" %(id))
             self._saveOperationAdd(id)
         elif action == ACTIONID_DELETE:
             pisiprogress.getCallback().verbose("\t\t<google contacts> deleting %s" %(id))
             self._saveOperationDelete(id)
         elif action == ACTIONID_MODIFY:
             self._saveOperationModify(id)
             pisiprogress.getCallback().verbose("\t\t<google contacts> replacing %s" %(id))
         i+=1
         pisiprogress.getCallback().progress.setProgress(i * 100 / len(self._history))
         pisiprogress.getCallback().update('Storing')
コード例 #26
0
ファイル: pisi.py プロジェクト: kichkasch/pisi
def determineMode(config,  modulesToLoad):
    """
    Check, what type of information we have to synchronize
    
    Checks, whether the two modules (for the given data sources) are equal in type for data they can sync (contacts - contacts or calendar - calendar). 
    This is done by simply comparing the starting part of the module names (all stuff left from '_'); this is a naming convention.
    E.g. contacts_ldap and contacts_sqlite3 would return 'CONTACTS' mode, whereby contacts_ldap and calendar_google would raise an error.
    An error is thrown whenever the two sources do not match in type, or if a type is not known or unvalid..
    """
    modes = [None,  None]
    for j in range(0, 2):
        modulename = config.get(  modulesToLoad[j], 'module' )
        modeString = modulename[:modulename.index("_")]
        for i in range (0, len(MODE_STRINGS)):
            if MODE_STRINGS[i] == modeString:
                modes[j] = i
        if modes[j] == None:
            raise ValueError ("Mode check: mode <%s> not known." %(modulesToLoad[j]))
    if modes[0] != modes[1]:
        raise ValueError("Mode check: Source 1 and 2 are not compatible.")
    pisiprogress.getCallback().verbose("Running in mode <%s>." %(MODE_STRINGS[modes[0]]))
    return modes[0]
コード例 #27
0
ファイル: eventsSync.py プロジェクト: kichkasch/pisi
def syncEvents(verbose,  modulesToLoad,  source):
    modulesToLoad.sort() 
    modulesNamesCombined = modulesToLoad[0] + modulesToLoad[1]
    knownEvents = _readModulesPreviousEvents( modulesNamesCombined )
    
    allEventsLeft = source[0].allEvents()
    allEventsRight = source[1].allEvents()
    pisiprogress.getCallback().verbose("")
    pisiprogress.getCallback().verbose("Module %s has %d events in total" %(modulesToLoad[0],  len(allEventsLeft)))
    pisiprogress.getCallback().verbose("Module %s has %d events in total" %(modulesToLoad[1],  len(allEventsRight)))
    pisiprogress.getCallback().verbose("")
    for id in allEventsLeft.keys():
        event = allEventsLeft[id]
        if not id in allEventsRight.keys():    
            # This event is not in the right side
            if id in knownEvents:
                # It is deleted from the right side
                source[0].removeEvent(id)
            else:
                # It's new
                source[1].addEvent(event)
                knownEvents.append(id)
        else:
            sameEvent = allEventsRight[id]
            if not event.compare(sameEvent):    # only update if something really changed; update time is not an indicator - this was updated when we wrote the last entry
                if event.updated == "":     # this event has never been updated
                    source[0].replaceEvent( event.id, sameEvent )
                elif sameEvent.updated == "":     # the other event has never been updated
                    source[1].replaceEvent( event.id, event )
                elif event.updated < sameEvent.updated:
                    source[0].replaceEvent( event.id, sameEvent )
                elif event.updated > sameEvent.updated:
                    source[1].replaceEvent( sameEvent.id, event )
                else:
                    pass    # same update time should mean both sides are untouched!

    for id in allEventsRight.keys():
        event = allEventsRight[id]
        if not id in allEventsLeft.keys():
            # This event is not in the left side
            if id in knownEvents:
                # It is deleted from the left side
                source[1].removeEvent(id)
            else:
                source[0].addEvent( event )
                knownEvents.append(id)
    
    _saveModulesNewEvent(modulesNamesCombined, knownEvents)
コード例 #28
0
ファイル: contacts_dbussim.py プロジェクト: kichkasch/pisi
    def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
        """
        Constructor
        
        Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called.
        Local variables are initialized.
        The settings from the configuration file are loaded. 

        @param modulesString: is a small string to help you make a unique id. It is the two modules configuration-names concatinated.
        @param config: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param configsection: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user')
        @param folder: is a string with the location for where your module can save its own files if necessary
        @param verbose: should make your module "talk" more
        @param soft: should tell you if you should make changes (ie. save)
        """
        contacts.AbstractContactSynchronizationModule.__init__(self,  verbose,  soft,  modulesString,  config,  configsection,  "Contacts DBUS SIM")
        self.verbose = verbose
        self._determineSimLimitations()        
        self._availableIds = {}
        for i in range (1, self._max_simentries + 1):
            self._availableIds[i] = 1
        self._idMappings = {}
        pisiprogress.getCallback().verbose("DBUS_SIM module loaded")
コード例 #29
0
ファイル: contacts_vcf.py プロジェクト: kichkasch/pisi
    def load(self):
        """
        Load all data from local VCF file
        
        File opened and the entries are parsed. For each entry a L{contacts.contacts.Contact} instance is created and stored in the instance dictionary
        L{contacts.AbstractContactSynchronizationModule._allContacts}.
        """
        pisiprogress.getCallback().verbose("VCF: Loading")
        if self._vcfpath == PATH_INTERACTIVE:
            self._vcfpath = self._promptFilename(
                "\tPath to VCF file ",
                "pisi_export.vcf",
                "You configured PISI VCF support to ask for VCF file name when running.",
            )

        file = None
        try:
            file = open(self._vcfpath, "r")
        except IOError, e:
            pisiprogress.getCallback().error(
                "--> Error: Could not load VCF file - we still carry on with processing:\n\t%s" % (e)
            )
            return
コード例 #30
0
ファイル: pisi.py プロジェクト: kichkasch/pisi
def applyChanges(source):
    """
    Write changes through to data source backends
    
    All changes in syncing are only performed in memory. This function finally requests the data sources to make their changes permanent by calling
    the corresponding function in there.
    """
    pisiprogress.getCallback().verbose("Making changes permanent")
    pisiprogress.getCallback().progress.push(0, 50)
    try:
        source[0].saveModifications()
    except ValueError,  ex:
        pisiprogress.getCallback().error("Changes to source 1 (%s) could not be applied due to the following reason: %s" %(source[0].getName(),  ex))