Example #1
0
    def _run(self, args):
        if not console.yesno("Are you sure you want to empty the MPT?"):
            return 1

        if not console.yesno("Really... is this what you want?"):
            return 1

        self._sm.reset()
        self._dbi.commit()
Example #2
0
    def _run(self, args):
        if not console.yesno("Are you sure you want to empty the MPT?"):
            return 1

        if not console.yesno("Really... is this what you want?"):
            return 1

        self._sm.reset()
        self._dbi.commit()
Example #3
0
    def _run(self, args):
        avatar = Avatar()

        name = raw_input("New administrator name: ").strip()
        surname = raw_input("New administrator surname: ").strip()
        organization = raw_input("New administrator organization: ").strip()
        email = raw_input("New administrator email: ").strip()
        login = raw_input("New administrator login: "******"New administrator password: "******"Retype administrator password: "******"Sorry, passwords do not match")

        avatar.setName(name)
        avatar.setSurName(surname)
        avatar.setOrganisation(organization)
        avatar.setLang("en_GB")
        avatar.setEmail(email)

        self.printUserInfo(avatar)

        if console.yesno("Are you sure to create and grant administrator privileges to this user?"):
            avatar.activateAccount()
            loginInfo = LoginInfo(login, password)
            authMgr = AuthenticatorMgr()
            userid = authMgr.createIdentity(loginInfo, avatar, "Local")
            authMgr.add(userid)
            adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
            AvatarHolder().add(avatar)
            adminList.grant(avatar)
            print "New administrator created successfully with id: %s" % avatar.getId()
Example #4
0
    def _run(self, args):
        avatar = Avatar()

        name = raw_input("New administrator name: ").strip()
        surname = raw_input("New administrator surname: ").strip()
        organization = raw_input("New administrator organization: ").strip()
        email = raw_input("New administrator email: ").strip()
        login = raw_input("New administrator login: "******"New administrator password: "******"Retype administrator password: "******"Sorry, passwords do not match")

        avatar.setName(name)
        avatar.setSurName(surname)
        avatar.setOrganisation(organization)
        avatar.setLang("en_GB")
        avatar.setEmail(email)

        self.printUserInfo(avatar)

        if console.yesno(
                "Are you sure to create and grant administrator privileges to this user?"
        ):
            avatar.activateAccount()
            loginInfo = LoginInfo(login, password)
            authMgr = AuthenticatorMgr()
            userid = authMgr.createIdentity(loginInfo, avatar, "Local")
            authMgr.add(userid)
            adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getAdminList()
            AvatarHolder().add(avatar)
            adminList.grant(avatar)
            print "New administrator created successfully with id: %s" % avatar.getId(
            )
Example #5
0
def main():
    """
    Main program cycle
    """

    print console.colored("""\nThis script will migrate your Indico DB to a new version. We recommend that
this operation be executed while the web server is down, in order to avoid
concurrency problems and DB conflicts.\n\n""", 'yellow')

    parser = argparse.ArgumentParser(description='Execute migration')
    parser.add_argument('--with-rb', dest='useRBDB', action='store_true',
                        help='Use the Room Booking DB')
    parser.add_argument('--run-only', dest='specified', default='',
                        help='Specify which step(s) to run (comma-separated)')
    parser.add_argument('--prev-version', dest='prevVersion', help='Previous version of Indico (used by DB)', default=__version__)

    args = parser.parse_args()

    if console.yesno("Are you sure you want to execute the "
                     "migration now?"):
        try:
            return runMigration(withRBDB=args.useRBDB,
                                prevVersion=parse_version(args.prevVersion),
                                specified=filter(lambda x: x, map(lambda x: x.strip(), args.specified.split(','))))
        except:
            print console.colored("\nMigration failed! DB may be in "
                                  " an inconsistent state:", 'red', attrs=['bold'])
            print console.colored(traceback.format_exc(), 'red')
    else:
        return 1
Example #6
0
 def _run(self, args):
     avatar = AvatarHolder().getById(args.id)
     self.printUserInfo(avatar, args.id)
     if not avatar.isAdmin():
         print "User seems to has no administrator privileges"
     if console.yesno("Are you sure to revoke administrator privileges from this user?"):
         adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
         adminList.revoke(avatar)
         print "Administrator privileges revoked successfully"
     return 0
Example #7
0
 def _run(self, args):
     avatar = AvatarHolder().getById(args.id)
     self.printUserInfo(avatar, args.id)
     if avatar.isAdmin():
         print "User seems to already has administrator privileges"
     if console.yesno("Are you sure to grant administrator privileges to this user?"):
         adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
         adminList.grant(avatar)
         avatar.activateAccount()
         print "Administrator privileges granted successfully"
     return 0
Example #8
0
 def _run(self, args):
     avatar = AvatarHolder().getById(args.id)
     self.printUserInfo(avatar, args.id)
     if not avatar.isAdmin():
         print "User seems to has no administrator privileges"
     if console.yesno(
             "Are you sure to revoke administrator privileges from this user?"
     ):
         adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance(
         ).getAdminList()
         adminList.revoke(avatar)
         print "Administrator privileges revoked successfully"
     return 0
Example #9
0
def main():
    """
    Main program cycle
    """

    print console.colored("""\nThis script will migrate your Indico DB to a new version. We recommend that
this operation be executed while the web server is down, in order to avoid
concurrency problems and DB conflicts.\n\n""", 'yellow')

    parser = argparse.ArgumentParser(description='Execute migration')
    parser.add_argument('--dry-run', '-n', dest='dry_run', action='store_true',
                        help='Only show which migration tasks would be executed')
    parser.add_argument('--with-rb', dest='useRBDB', action='store_true',
                        help='Use the Room Booking DB')
    parser.add_argument('--run-only', dest='specified', default='',
                        help='Specify which step(s) to run (comma-separated)')
    parser.add_argument('--run-from', dest='run_from', default='',
                        help='Specify FROM which step to run (inclusive)')
    parser.add_argument('--prev-version', dest='prevVersion', help='Previous version of Indico (used by DB)', default=__version__)
    parser.add_argument('--profile', dest='profile', help='Use profiling during the migration', action='store_true')

    args = parser.parse_args()

    if args.dry_run or console.yesno("Are you sure you want to execute the migration now?"):
        try:
            if args.profile:
                import profile, random, os
                proffilename = os.path.join(Config.getInstance().getTempDir(), "migration%s.prof" % str(random.random()))
                result = None
                profile.runctx("""result=runMigration(withRBDB=args.useRBDB,
                                  prevVersion=parse_version(args.prevVersion),
                                  specified=filter(lambda x: x, map(lambda x: x.strip(), args.specified.split(','))),
                                  run_from=args.run_from,
                                  dry_run=args.dry_run)""",
                                  globals(), locals(), proffilename)
                return result
            else:
                return runMigration(withRBDB=args.useRBDB,
                                    prevVersion=parse_version(args.prevVersion),
                                    specified=filter(lambda x: x, map(lambda x: x.strip(), args.specified.split(','))),
                                    run_from=args.run_from,
                                    dry_run=args.dry_run)
        except ControlledExit:
            return 1
        except (Exception, SystemExit, KeyboardInterrupt):
            print console.colored("\nMigration failed! DB may be in "
                                  " an inconsistent state:", 'red', attrs=['bold'])
            print console.colored(traceback.format_exc(), 'red')
            return -1
    else:
        return 1
Example #10
0
 def _run(self, args):
     avatar = AvatarHolder().getById(args.id)
     self.printUserInfo(avatar, args.id)
     if avatar.isAdmin():
         print "User seems to already has administrator privileges"
     if console.yesno(
             "Are you sure to grant administrator privileges to this user?"
     ):
         adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance(
         ).getAdminList()
         adminList.grant(avatar)
         avatar.activateAccount()
         print "Administrator privileges granted successfully"
     return 0
Example #11
0
def main():
    """
    Main program cycle
    """

    print console.colored("""\nThis script will migrate your Indico DB to a new version. We recommend that
this operation be executed while the web server is down, in order to avoid
concurrency problems and DB conflicts.\n\n""", 'yellow')

    parser = argparse.ArgumentParser(description='Execute migration')
    parser.add_argument('--dry-run', '-n', dest='dry_run', action='store_true',
                        help='Only show which migration tasks would be executed')
    parser.add_argument('--run-only', dest='specified', default='',
                        help='Specify which step(s) to run (comma-separated)')
    parser.add_argument('--run-from', dest='run_from', default='',
                        help='Specify FROM which step to run (inclusive)')
    parser.add_argument('--prev-version', dest='prevVersion', help='Previous version of Indico (used by DB)', default=__version__)
    parser.add_argument('--profile', dest='profile', help='Use profiling during the migration', action='store_true')

    args = parser.parse_args()

    if args.dry_run or console.yesno("Are you sure you want to execute the migration now?"):
        try:
            if args.profile:
                import profile, random, os
                proffilename = os.path.join(Config.getInstance().getTempDir(), "migration%s.prof" % str(random.random()))
                result = None
                profile.runctx("""result=runMigration(
                                  prevVersion=parse_version(args.prevVersion),
                                  specified=filter(lambda x: x, map(lambda x: x.strip(), args.specified.split(','))),
                                  run_from=args.run_from,
                                  dry_run=args.dry_run)""",
                                  globals(), locals(), proffilename)
                return result
            else:
                with make_app().app_context():
                    return runMigration(prevVersion=parse_version(args.prevVersion),
                                        specified=filter(None, map(str.strip, args.specified.split(','))),
                                        run_from=args.run_from,
                                        dry_run=args.dry_run)
        except ControlledExit:
            return 1
        except (Exception, SystemExit, KeyboardInterrupt):
            print console.colored("\nMigration failed! DB may be in an inconsistent state:", 'red', attrs=['bold'])
            print console.colored(traceback.format_exc(), 'red')
            return -1
    else:
        return 1
Example #12
0
    def _export(self, args):
        logger = _basicStreamHandler()

        if console.yesno("This will export all the data to the remote service "
                         "using the agent (takes LONG). Are you sure?"):
            try:
                agent = self._sm.getAllAgents()[args.agent]
            except KeyError:
                raise Exception("Agent '%s' was not found!" % args.agent)

            root = CategoryManager().getById(args.cat or 0)

            if args.monitor:
                monitor = open(args.monitor, 'w')
            else:
                monitor = None

            if args.fast:
                iterator = console.conferenceHolderIterator(
                    ConferenceHolder(), verbose=args.verbose)
            else:
                iterator = categoryIterator(root, 0, verbose=args.verbose)

            if args.output:
                nbatch = 0
                batch = []
                for record, rid, operation in _wrapper(_only_second(iterator),
                                                       agent._creationState,
                                                       self._dbi):
                    if len(batch) > SIZE_BATCH_PER_FILE:
                        self._writeFile(agent, args.output, nbatch, batch,
                                        logger)
                        nbatch += 1
                        batch = []

                    batch.append((record, rid, operation))

                if batch:
                    self._writeFile(agent, args.output, nbatch, batch, logger)
            else:
                agent._run(_wrapper(_only_second(iterator),
                                    agent._creationState, self._dbi),
                           logger=logger,
                           monitor=monitor)

            if monitor:
                monitor.close()
Example #13
0
    def _export(self, args):
        logger = _basicStreamHandler()

        if console.yesno("This will export all the data to the remote service "
                         "using the agent (takes LONG). Are you sure?"):
            try:
                agent = self._sm.getAllAgents()[args.agent]
            except KeyError:
                raise Exception("Agent '%s' was not found!" % args.agent)

            root = CategoryManager().getById(args.cat or 0)

            if args.monitor:
                monitor = open(args.monitor, 'w')
            else:
                monitor = None

            if args.fast:
                iterator = console.conferenceHolderIterator(ConferenceHolder(),
                                                            verbose=args.verbose)
            else:
                iterator = categoryIterator(root, 0, verbose=args.verbose)

            if args.output:
                nbatch = 0
                batch = []
                for record, rid, operation in _wrapper(_only_second(iterator),
                                                  agent._creationState,
                                                  self._dbi):
                    if len(batch) > SIZE_BATCH_PER_FILE:
                        self._writeFile(agent, args.output,
                                        nbatch, batch, logger)
                        nbatch += 1
                        batch = []

                    batch.append((record, rid, operation))

                if batch:
                    self._writeFile(agent, args.output, nbatch, batch, logger)
            else:
                agent._run(_wrapper(_only_second(iterator),
                                    agent._creationState, self._dbi),
                           logger=logger,
                           monitor=monitor)

            if monitor:
                    monitor.close()
Example #14
0
def main():
    """
    Main program cycle
    """

    print console.colored(
        """\nThis script will migrate your Indico DB to a new version. We recommend that
this operation be executed while the web server is down, in order to avoid
concurrency problems and DB conflicts.\n\n""", 'yellow')

    parser = argparse.ArgumentParser(description='Execute migration')
    parser.add_argument('--with-rb',
                        dest='useRBDB',
                        action='store_true',
                        help='Use the Room Booking DB')
    parser.add_argument('--run-only',
                        dest='specified',
                        default='',
                        help='Specify which step(s) to run (comma-separated)')
    parser.add_argument('--prev-version',
                        dest='prevVersion',
                        help='Previous version of Indico (used by DB)',
                        default=__version__)

    args = parser.parse_args()

    if console.yesno("Are you sure you want to execute the " "migration now?"):
        try:
            return runMigration(withRBDB=args.useRBDB,
                                prevVersion=parse_version(args.prevVersion),
                                specified=filter(
                                    lambda x: x,
                                    map(lambda x: x.strip(),
                                        args.specified.split(','))))
        except:
            print console.colored(
                "\nMigration failed! DB may be in "
                " an inconsistent state:",
                'red',
                attrs=['bold'])
            print console.colored(traceback.format_exc(), 'red')
    else:
        return 1
Example #15
0
def catalogMigration(dbi, withRBDB, prevVersion):
    """
    Initializing/updating index catalog
    """
    PluginsHolder().reloadAllPlugins(disable_if_broken=False)
    skip = False

    for plugin in (p for p in PluginsHolder().getList() if isinstance(p, Plugin) or isinstance(p, PluginType)):
        if plugin.isActive() and not plugin.isUsable():
            print console.colored(
                "\r  Plugin '{0}' is going to be disabled: {1}".format(
                    plugin.getName(),
                    plugin.getNotUsableReason()
                ), 'yellow')
            skip = True

    if skip and not console.yesno('\r  Do you want to continue the migration anyway?'):
        raise ControlledExit()

    Catalog.updateDB(dbi=dbi)
Example #16
0
def catalogMigration(dbi, prevVersion):
    """
    Initializing/updating index catalog
    """
    PluginsHolder().reloadAllPlugins(disable_if_broken=False)
    skip = False

    for plugin in (p for p in PluginsHolder().getList() if isinstance(p, Plugin) or isinstance(p, PluginType)):
        if plugin.isActive() and not plugin.isUsable():
            print console.colored(
                "\r  Plugin '{0}' is going to be disabled: {1}".format(
                    plugin.getName(),
                    plugin.getNotUsableReason()
                ), 'yellow')
            skip = True

    if skip and not console.yesno('\r  Do you want to continue the migration anyway?'):
        raise ControlledExit()

    Catalog.updateDB(dbi=dbi)