def startCLI(): """ Controls the major flow for PISI (CLI) Calls one after another the supporting functions in this module. """ if not testConfiguration(): sys.exit(0) verbose, modulesToLoad, modulesNamesCombined, soft, mergeMode = parseArguments() cb = CLICallback(verbose) pisiprogress.registerCallback(cb) cb.progress.push(0, 8) cb.update('Starting Configuration') cb.verbose('') cb.verbose("*" * 55) cb.verbose( "*" * 22 + " PISI " + "*" * 22) cb.verbose( "*" * 55) cb.verbose( "** PISI is synchronizing information " + "*" * 18) cb.verbose( "** http://freshmeat.net/projects/pisiom " + "*" * 8) cb.verbose( "*" * 55) cb.verbose( ("\n" + "*" * 15 + " PHASE 0 - Configuration " + "*" * 15)) cb.verbose( "Verbose mode on") cb.verbose( ("In case of conflicts I use the following strategy: %s" %(MERGEMODE_STRINGS[mergeMode]))) config, configfolder = pisi.readConfiguration() source = pisi.importModules(configfolder, config, modulesToLoad, modulesNamesCombined, soft) mode = pisi.determineMode(config, modulesToLoad) cb.progress.drop() cb.progress.push(8, 10) cb.update('Pre-Processing sources') cb.verbose("\tSource 1") source[0].preProcess() cb.verbose("\tSource 2") source[1].preProcess() cb.verbose(" Pre-Processing Done") cb.progress.drop() cb.progress.push(10, 40) cb.update('Loading from sources') cb.verbose("\n" + "*" * 18 + " PHASE 1 - Loading " + "*" * 18) cb.progress.push(0, 50) source[0].load() cb.progress.drop() cb.progress.push(50, 100) cb.update('Loading') source[1].load() cb.progress.drop() cb.progress.drop() cb.progress.push(40, 70) cb.update('Comparing sources') cb.verbose("\n" + "*" * 17 + " PHASE 2 - Comparing " + "*" * 17) if mode == MODE_CALENDAR: # events mode pisi.eventsSync.syncEvents(verbose, modulesToLoad, source) elif mode == MODE_CONTACTS: # contacts mode pisi.contactsSync.syncContacts(verbose, modulesToLoad, source, mergeMode) cb.progress.drop() cb.progress.push(70, 95) cb.update('Making changes permanent') cb.verbose ("\n" + "*" * 18 + " PHASE 3 - Saving " + "*" * 18) if soft: print "You chose soft mode for PISI - changes are not applied to data sources." else: pisi.applyChanges(source) cb.verbose( "*" * 24 + " DONE " + "*" * 24) cb.progress.drop() cb.progress.push(95, 100) cb.update('Post-Processing sources') cb.verbose("\tSource 1") source[0].postProcess() cb.verbose("\tSource 2") source[1].postProcess() cb.verbose(" Post-Processing Done") cb.progress.drop() cb.update('Finished')
self.progress.drop() self.progress.push(40, 70) self.update('Comparing') self.verbose("\n PHASE 2 - Comparing ") if mode == MODE_CALENDAR: # events mode pisi.eventsSync.syncEvents(True, modulesToLoad, source) elif mode == MODE_CONTACTS: # contacts mode pisi.contactsSync.syncContacts(True, modulesToLoad, source, mergeMode) self.progress.drop() self.progress.push(70, 95) self.update('Storing') self.verbose ("\n PHASE 3 - Saving ") try: pisi.applyChanges(source) self.verbose( " DONE ") self.progress.drop() self.progress.push(95, 100) self.update('Post-Processing sources') self.verbose('Post-Processing sources') self.verbose("\tSource 1") source[0].postProcess() self.verbose("\tSource 2") source[1].postProcess() self.verbose(" Post-Processing Done") self.progress.drop() self.progress.setProgress(100) self.update('Finished')