Ejemplo n.º 1
0
 def run(self, gui):
     failList = []
     for user in self.userlist:
         gui.report(u"::: " + user)
         backup = Dump(self.master, self.dbpath, user)
         if not backup.filepath:
             failList.append(user)
             continue
         backup.run(gui)
         if not backup.filepath:
             failList.append(user)
     if failList:
         gui.report(_("***************\n"
                 "Database files could not be created for:\n  %s")
                 % repr(failList))
Ejemplo n.º 2
0
 def run(self, gui):
     failList = []
     for user in self.userlist:
         gui.report(u"::: " + user)
         backup = Dump(self.master, self.dbpath, user)
         if not backup.filepath:
             failList.append(user)
             continue
         backup.run(gui)
         if not backup.filepath:
             failList.append(user)
     if failList:
         gui.report(
             _("***************\n"
               "Database files could not be created for:\n  %s") %
             repr(failList))
Ejemplo n.º 3
0
def recreate(dbm, filepath, user, gui):
    """Recreate the user database, taking master update lock
    into consideration. NOTE that this 'lock' is not 100%
    effective, but it is a simple method which I hope will be
    adequate for the envisaged application.
    """
    dir = os.path.dirname(filepath)
    while True:
        udt = getudtime(dbm)
        if not mUnstable(dbm):
            break
        gui.report(_("Master database is in unstable state.\n  Waiting ..."))
        sleep(10)

    # Dump the master database to the selected file
    while True:
        dump = Dump(dbm, dir, user)
        if dump.filepath:
            break
        warning(_("Couldn't create database file in folder %1,"
                " select new folder"), (dir,))
        dir = getDirectory(dir)
        if not dir:
            if confirmationDialog(_("Abandon?"),
                    _("User database not regenerated,"
                    " do you really want to abandon this operation?"), False):
                break

    if dump.filepath:
        dump.run(gui)

    fp = dump.filepath
    dump = None
    if fp:
        # Check master database hasn't been updated
        if (udt == getudtime(dbm)):
            gui.report(_("\nSUCCESS! - User database regenerated"))
        else:
            gui.report(_("Master has been updated,"
                    " need to repeat...\n"))
            recreate(dbm, filepath, user, gui)
    else:
        gui.report(_("\nFAILED! Couldn't regenerate user database.\n"
                " --- Please contact administrator!"))