How to use the offlineimap.mbnames function in offlineimap

To help you get started, we’ve selected a few offlineimap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OfflineIMAP / offlineimap / offlineimap / init.py View on Github external
stacktrace.dump(sys.stderr)
                os.abort()

        try:
            self.num_sigterm = 0
            signal.signal(signal.SIGHUP, sig_handler)
            signal.signal(signal.SIGUSR1, sig_handler)
            signal.signal(signal.SIGUSR2, sig_handler)
            signal.signal(signal.SIGABRT, sig_handler)
            signal.signal(signal.SIGTERM, sig_handler)
            signal.signal(signal.SIGINT, sig_handler)
            signal.signal(signal.SIGQUIT, sig_handler)

            # Various initializations that need to be performed:
            activeaccounts = self._get_activeaccounts(options)
            mbnames.init(self.config, self.ui, options.dryrun)

            if options.singlethreading:
                # Singlethreaded.
                self.__sync_singlethreaded(activeaccounts, options.profiledir)
            else:
                # Multithreaded.
                t = threadutil.ExitNotifyThread(
                    target=syncitall,
                    name='Sync Runner',
                    args=(activeaccounts, self.config,)
                    )
                # Special exit message for the monitor to stop looping.
                t.exit_message = threadutil.STOP_MONITOR
                t.start()
                threadutil.monitor()
github OfflineIMAP / offlineimap / offlineimap / init.py View on Github external
def run(self):
        """Parse the commandline and invoke everything"""
        # next line also sets self.config and self.ui
        options, args = self.__parse_cmd_options()
        if options.diagnostics:
            self.__serverdiagnostics(options)
        elif options.migrate_fmd5:
            self.__migratefmd5(options)
        elif options.mbnames_prune:
            mbnames.init(self.config, self.ui, options.dryrun)
            mbnames.prune(self.config.get("general", "accounts"))
            mbnames.write()
        elif options.deletefolder:
            return self.__deletefolder(options)
        else:
            return self.__sync(options)
github OfflineIMAP / offlineimap / offlineimap / init.py View on Github external
def run(self):
        """Parse the commandline and invoke everything"""
        # next line also sets self.config and self.ui
        options, args = self.__parse_cmd_options()
        if options.diagnostics:
            self.__serverdiagnostics(options)
        elif options.migrate_fmd5:
            self.__migratefmd5(options)
        elif options.mbnames_prune:
            mbnames.init(self.config, self.ui, options.dryrun)
            mbnames.prune(self.config.get("general", "accounts"))
            mbnames.write()
        elif options.deletefolder:
            return self.__deletefolder(options)
        else:
            return self.__sync(options)
github OfflineIMAP / offlineimap / offlineimap / head / offlineimap / syncmaster.py View on Github external
def syncitall(accounts, config):
    currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
    ui = UIBase.getglobalui()
    threads = threadutil.threadlist()
    mbnames.init(config, accounts)
    for accountname in accounts:
        syncaccount(threads, config, accountname)
    # Wait for the threads to finish.
    threads.reset()
github OfflineIMAP / offlineimap / offlineimap / accounts.py View on Github external
remoterepos = account.remoterepos
    localrepos = account.localrepos
    statusrepos = account.statusrepos

    ui = getglobalui()
    ui.registerthread(account)
    try:
        # Load local folder.
        localfolder = account.get_local_folder(remotefolder)

        # Acquire the mutex to start syncing.
        acquire_mutex()

        # Add the folder to the mbnames mailboxes.
        mbnames.add(account.name, localrepos.getlocalroot(),
            localfolder.getname())

        # Load status folder.
        statusfolder = statusrepos.getfolder(remotefolder.getvisiblename().
            replace(remoterepos.getsep(), statusrepos.getsep()))
        statusfolder.openfiles()
        statusfolder.cachemessagelist()

        # Load local folder.
        ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)

        # Retrieve messagelists, taking into account age-restriction
        # options.
        maxage = localfolder.getmaxage()
        localstart = localfolder.getstartdate()
        remotestart = remotefolder.getstartdate()
github OfflineIMAP / offlineimap / offlineimap / head / offlineimap / accounts.py View on Github external
remoterepos.syncfoldersto(localrepos)

            folderthreads = []
            for remotefolder in remoterepos.getfolders():
                thread = InstanceLimitedThread(\
                    instancename = 'FOLDER_' + self.remoterepos.getname(),
                    target = syncfolder,
                    name = "Folder sync %s[%s]" % \
                    (self.name, remotefolder.getvisiblename()),
                    args = (self.name, remoterepos, remotefolder, localrepos,
                            statusrepos))
                thread.setDaemon(1)
                thread.start()
                folderthreads.append(thread)
            threadutil.threadsreset(folderthreads)
            mbnames.write()
            localrepos.holdordropconnections()
            remoterepos.holdordropconnections()
        finally:
            pass
github OfflineIMAP / offlineimap / offlineimap / accounts.py View on Github external
thread = InstanceLimitedThread(
                        limitNamespace="%s%s"% (
                            FOLDER_NAMESPACE, self.remoterepos.getname()),
                        target=syncfolder,
                        name="Folder %s [acc: %s]"% (
                            remotefolder.getexplainedname(), self),
                        args=(self, remotefolder, quick)
                    )
                    thread.start()
                    folderthreads.append(thread)
                else:
                    syncfolder(self, remotefolder, quick)
            # Wait for all threads to finish.
            for thr in folderthreads:
                thr.join()
            mbnames.writeIntermediateFile(self.name) # Write out mailbox names.
            localrepos.forgetfolders()
            remoterepos.forgetfolders()
        except:
            # Error while syncing. Drop all connections that we have, they
            # might be bogus by now (e.g. after suspend).
            localrepos.dropconnections()
            remoterepos.dropconnections()
            raise
        else:
            # Sync went fine. Hold or drop depending on config.
            localrepos.holdordropconnections()
            remoterepos.holdordropconnections()

        hook = self.getconf('postsynchook', '')
        self.callhook(hook)
github OfflineIMAP / offlineimap / offlineimap / accounts.py View on Github external
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
               statusrepos, quick):
    global mailboxes
    ui = UIBase.getglobalui()
    ui.registerthread(accountname)
    # Load local folder.
    localfolder = localrepos.\
                  getfolder(remotefolder.getvisiblename().\
                            replace(remoterepos.getsep(), localrepos.getsep()))
    # Write the mailboxes
    mbnames.add(accountname, localfolder.getvisiblename())

    # Load status folder.
    statusfolder = statusrepos.getfolder(remotefolder.getvisiblename().\
                                         replace(remoterepos.getsep(),
                                                 statusrepos.getsep()))
    if localfolder.getuidvalidity() == None:
        # This is a new folder, so delete the status cache to be sure
        # we don't have a conflict.
        statusfolder.deletemessagelist()
        
    statusfolder.cachemessagelist()

    if quick:
        if not localfolder.quickchanged(statusfolder) \
               and not remotefolder.quickchanged(statusfolder):
            ui.skippingfolder(remotefolder)