コード例 #1
0
ファイル: test_commands.py プロジェクト: kentsay/opengrok
 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)
コード例 #2
0
ファイル: test_commands.py プロジェクト: sfetome/opengrok
 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'])
コード例 #3
0
ファイル: test_commands.py プロジェクト: sfetome/opengrok
 def test_str(self):
     cmds = Commands(
         CommandsBase("opengrok-master", [{
             "command": ['foo']
         }, {
             "command": ["bar"]
         }]))
     self.assertEqual("opengrok-master", str(cmds))
コード例 #4
0
ファイル: test_commands.py プロジェクト: sfetome/opengrok
 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)
コード例 #5
0
ファイル: test_commands.py プロジェクト: robin536180/opengrok
 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)
コード例 #6
0
ファイル: test_commands.py プロジェクト: yutuer/opengrok
 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)
コード例 #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)
コード例 #8
0
ファイル: test_commands.py プロジェクト: kentsay/opengrok
 def test_str(self):
     p = Commands(CommandsBase("opengrok-master", [['foo'], ["bar"]]))
     self.assertEqual("opengrok-master", str(p))
コード例 #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.")
コード例 #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)
コード例 #11
0
ファイル: sync.py プロジェクト: praveenmunagapati/OpenGrok
                    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("{}: {}".