def makeSnapshot(self): """ Take a snapshot of our repository. Try to do a backup first. If that fails, take a full snapshot of the __repository__ directory instead. """ tarPath = wx.FileSelector(_(u"Save snapshot as..."), unicode(getDesktopDir(), sys.getfilesystemencoding()), _(u"ChandlerSnapshot.tgz"), u".tgz", u"*.tgz", flags=wx.SAVE | wx.OVERWRITE_PROMPT, parent=self) if not tarPath: return False # user canceled. repoDir = makeUncompressedBackup(Globals.options, masterPassword=True) archive = tarfile.open(tarPath, 'w:gz') archive.add(repoDir, '.') archive.add('version.py') for log in ('chandler.log', 'chandler.log.1', 'chandler.log.2', 'chandler.prefs'): logPath = os.path.join(Globals.options.profileDir, log) if os.path.isfile(logPath): archive.add(logPath, log) archive.close() return True
def onButton(self, event): if hasattr(self, 'create'): Globals.options.create = self.create.GetValue() if hasattr(self, 'repairRecover') and self.repairRecover.GetValue(): Globals.options.repair = True Globals.options.recover = True elif hasattr(self, 'undoRepair') and self.undoRepair.GetValue(): Globals.options.undo = 'repair' elif hasattr(self, 'undoStart') and self.undoStart.GetValue(): Globals.options.undo = 'start' elif hasattr(self, 'resetIndex') and self.resetIndex.GetValue(): Globals.options.resetIndex = True elif hasattr(self, 'snapshot') and self.snapshot.GetValue(): if self.makeSnapshot(): # Quit. Yes, it's weird having an exit point here, but we # only get here at startup before any other UI has been # presented and before twisted has started or the repo is # opened, etc. Plus, this dialog is a developmental hack to # allow us to collect crash info with less impact on users, # so it's worth it - that's all I'm saying. So sue me. sys.exit(0) return # user canceled save box - keep going. elif self.restore.GetValue(): restorePath = wx.FileSelector(_(u"Snapshot to restore?"), unicode(getDesktopDir(), sys.getfilesystemencoding()), u"", u".tgz", u"*.tgz", flags=wx.OPEN | wx.FILE_MUST_EXIST, parent=self) if not restorePath: return # user canceled. Globals.options.restore = restorePath self.EndModal(wx.OK)
def onButton(self, event): if hasattr(self, 'create'): Globals.options.create = self.create.GetValue() if hasattr(self, 'repairRecover') and self.repairRecover.GetValue(): Globals.options.repair = True Globals.options.recover = True elif hasattr(self, 'undoRepair') and self.undoRepair.GetValue(): Globals.options.undo = 'repair' elif hasattr(self, 'undoStart') and self.undoStart.GetValue(): Globals.options.undo = 'start' elif hasattr(self, 'resetIndex') and self.resetIndex.GetValue(): Globals.options.resetIndex = True elif hasattr(self, 'snapshot') and self.snapshot.GetValue(): if self.makeSnapshot(): # Quit. Yes, it's weird having an exit point here, but we # only get here at startup before any other UI has been # presented and before twisted has started or the repo is # opened, etc. Plus, this dialog is a developmental hack to # allow us to collect crash info with less impact on users, # so it's worth it - that's all I'm saying. So sue me. sys.exit(0) return # user canceled save box - keep going. elif self.restore.GetValue(): restorePath = wx.FileSelector(_(u"Snapshot to restore?"), unicode(getDesktopDir(), sys.getfilesystemencoding()), u"", u".tgz", u"*.tgz", flags=wx.OPEN|wx.FILE_MUST_EXIST, parent=self) if not restorePath: return # user canceled. Globals.options.restore = restorePath self.EndModal(wx.OK)
class SharingPreferences(schema.Item): import_dir = schema.One(schema.Text, defaultValue=unicode(getDesktopDir(), sys.getfilesystemencoding())) import_as_new = schema.One(schema.Boolean, defaultValue=True) isOnline = schema.One(schema.Boolean, defaultValue=True)