Example #1
0
 def test_run_retcodes(self):
     p = Commands(CommandsBase("opengrok-master", [["/bin/echo"], ["foo"]]))
     p.run()
     self.assertEqual(
         {
             '/bin/echo opengrok-master': 0,
             'foo opengrok-master': None
         }, p.retcodes)
Example #2
0
 def test_project_subst(self):
     cmds = Commands(
         CommandsBase("test-subst", [{
             "command": ["/bin/echo", '%PROJECT%']
         }]))
     cmds.run()
     self.assertEqual(['test-subst\n'],
                      cmds.outputs['/bin/echo test-subst'])
Example #3
0
 def test_str(self):
     cmds = Commands(
         CommandsBase("opengrok-master", [{
             "command": ['foo']
         }, {
             "command": ["bar"]
         }]))
     self.assertEqual("opengrok-master", str(cmds))
Example #4
0
 def test_terminate_after_non_zero_code(self):
     cmds = Commands(
         CommandsBase("opengrok-master", [{
             "command": ["/bin/false"]
         }, {
             "command": ["/bin/true"]
         }]))
     cmds.run()
     self.assertEqual({'/bin/false opengrok-master': 1}, cmds.retcodes)
Example #5
0
 def test_run_retcodes(self):
     cmds = Commands(CommandsBase("opengrok-master",
                     [{"command": ["/bin/echo"]},
                      {"command": ["/bin/true"]},
                      {"command": ["/bin/false"]}]))
     cmds.run()
     # print(p.retcodes)
     self.assertEqual({'/bin/echo opengrok-master': 0,
                       '/bin/true opengrok-master': 0,
                       '/bin/false opengrok-master': 1}, cmds.retcodes)
Example #6
0
 def test_run_retcodes(self):
     p = Commands(
         CommandsBase("opengrok-master",
                      [["/bin/echo"], ["/bin/true"], ["/bin/false"]]))
     p.run()
     # print(p.retcodes)
     self.assertEqual(
         {
             '/bin/echo opengrok-master': 0,
             '/bin/true opengrok-master': 0,
             '/bin/false opengrok-master': 1
         }, p.retcodes)
Example #7
0
                    for line in indexed_projects:
                        dirs_to_process.append(line.strip())
                else:
                    logger.error("cannot get list of projects")
                    sys.exit(1)
            else:
                directory = args.directory
                for entry in os.listdir(directory):
                    if path.isdir(path.join(directory, entry)):
                        dirs_to_process.append(entry)

            logger.debug("to process: {}".format(dirs_to_process))

            cmds_base = []
            for d in dirs_to_process:
                cmd_base = CommandsBase(d, commands, config.get("cleanup"))
                cmds_base.append(cmd_base)

            # Map the commands into pool of workers so they can be processed.
            try:
                cmds_base_results = pool.map(worker, cmds_base, 1)
            except KeyboardInterrupt:
                # XXX lock.release() or return 1 ?
                sys.exit(1)
            else:
                for cmds_base in cmds_base_results:
                    logger.debug(
                        "Checking results of project {}".format(cmds_base))
                    cmds = Commands(cmds_base)
                    cmds.fill(cmds_base.retcodes, cmds_base.outputs,
                              cmds_base.failed)
Example #8
0
 def test_str(self):
     p = Commands(CommandsBase("opengrok-master", [['foo'], ["bar"]]))
     self.assertEqual("opengrok-master", str(p))
Example #9
0
                    for line in cmd.getoutput():
                        dirs_to_process.append(line.strip())
                else:
                    logger.error("cannot get list of projects")
                    sys.exit(1)
            else:
                directory = args.directory
                for entry in os.listdir(directory):
                    if path.isdir(path.join(directory, entry)):
                        dirs_to_process.append(entry)

            logger.debug("to process: {}".format(dirs_to_process))

            projects = []
            for d in dirs_to_process:
                proj = CommandsBase(d, config.get("commands"),
                                    config.get("cleanup"))
                projects.append(proj)

            try:
                projects = pool.map(worker, projects, 1)
            except KeyboardInterrupt:
                # XXX lock.release() or return 1 ?
                sys.exit(1)
            else:
                for proj in projects:
                    logger.debug("Checking results of project {}".format(proj))
                    cmds = Commands(proj)
                    cmds.fill(proj.retcodes, proj.outputs, proj.failed)
                    cmds.check(ignore_errors)
    except Timeout:
        logger.warning("Already running, exiting.")
Example #10
0
                    for line in cmd.getoutput():
                        dirs_to_process.append(line.strip())
                else:
                    logger.error("cannot get list of projects")
                    sys.exit(1)
            else:
                directory = args.directory
                for entry in os.listdir(directory):
                    if path.isdir(path.join(directory, entry)):
                        dirs_to_process.append(entry)

            logger.debug("to process: {}".format(dirs_to_process))

            projects = []
            for d in dirs_to_process:
                proj = CommandsBase(d, config["commands"])
                projects.append(proj)

            try:
                projects = pool.map(worker, projects, 1)
            except KeyboardInterrupt:
                # XXX lock.release() or return 1 ?
                sys.exit(1)
            else:
                for proj in projects:
                    cmds = Commands(proj)
                    cmds.check(ignore_errors)
    except Timeout:
        logger.warning("Already running, exiting.")
        sys.exit(1)
Example #11
0
                    for line in cmd.getoutput():
                        dirs_to_process.append(line.strip())
                else:
                    logger.error("cannot get list of projects")
                    sys.exit(1)
            else:
                directory = args.directory
                for entry in os.listdir(directory):
                    if path.isdir(path.join(directory, entry)):
                        dirs_to_process.append(entry)

            logger.debug("to process: {}".format(dirs_to_process))

            projects = []
            for d in dirs_to_process:
                proj = CommandsBase(d, config["commands"])
                projects.append(proj)

            try:
                projects = pool.map(worker, projects, 1)
            except KeyboardInterrupt:
                # XXX lock.release() or return 1 ?
                sys.exit(1)
            else:
                # XXX move the code below to Commands once it can work with
                # logger
                for proj in projects:
                    logger.debug("Output from {}:".format(proj.name))
                    for cmd in proj.outputs.keys():
                        if proj.outputs[cmd] and len(proj.outputs[cmd]) > 0:
                            logger.debug("{}: {}".