diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index ed08cad..8b39c7e 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -65,9 +65,11 @@ class Account(CustomConfig.ConfigHelperMixin): self.name = name self.metadatadir = config.getmetadatadir() self.localeval = config.getlocaleval() - #Contains the current :mod:`offlineimap.ui`, and can be used for logging etc. + # current :mod:`offlineimap.ui`, can be used for logging: self.ui = getglobalui() self.refreshperiod = self.getconffloat('autorefresh', 0.0) + # should we run in "dry-run" mode? + self.dryrun = self.config.getboolean('general', 'dry-run') self.quicknum = 0 if self.refreshperiod == 0.0: self.refreshperiod = None @@ -312,7 +314,9 @@ class SyncableAccount(Account): # wait for all threads to finish for thr in folderthreads: thr.join() - mbnames.write() + # Write out mailbox names if required and not in dry-run mode + if not self.dryrun: + mbnames.write() localrepos.forgetfolders() remoterepos.forgetfolders() except: @@ -337,6 +341,8 @@ class SyncableAccount(Account): return try: self.ui.callhook("Calling hook: " + cmd) + if self.dryrun: # don't if we are in dry-run mode + return p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index d716968..da77b5a 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -461,7 +461,10 @@ class UIBase(object): ################################################## Hooks def callhook(self, msg): - self.info(msg) + if self.dryrun: + self.info("[DRYRUN] {}".format(msg)) + else: + self.info(msg) ################################################## Other