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')
except KeyError: return default def testConfiguration(): """ Checks, whether configuration can be loaded from PISI core. If not possible, an error message is visualized in a GTK dialog. @return: False, if an Error occurs when loading the configration from core; otherwise True """ try: pisi.getConfiguration() return True except ValueError: dialog = gtk.MessageDialog(None, buttons=gtk.BUTTONS_OK, message_format = "PISI configuration not found", type = gtk.MESSAGE_ERROR) configfile = pisi.getConfigLocation() dialog.format_secondary_markup("For running PISI you must have a configuration file located at\n '%s'.\n\nWith the package a well-documented sample was placed at '/usr/share/doc/pisi/conf.example'. You may move this for a starting point - then edit this file in order to configure your PIM synchronization data sources." %(configfile)) ret = dialog.run() dialog.destroy() return False """ This starts the GUI version of PISI """ if __name__ == "__main__": if testConfiguration(): base = Base() pisiprogress.registerCallback(base) base.main()