Skip to content

Commit d0a55b4

Browse files
author
Vladimir Kotal
committed
rename Commands to CommandSequence
1 parent a86ae97 commit d0a55b4

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

opengrok-tools/src/main/python/opengrok_tools/sync.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from multiprocessing import Pool
4040
from os import path
4141

42-
from .utils.commands import Commands, CommandsBase
42+
from .utils.commandsequence import CommandSequence, CommandSequenceBase
4343
from .utils.filelock import Timeout, FileLock
4444
from .utils.opengrok import list_indexed_projects, get_config_value
4545
from .utils.readconfig import read_config
@@ -59,7 +59,7 @@ def worker(base):
5959
Process one project by calling set of commands.
6060
"""
6161

62-
x = Commands(base)
62+
x = CommandSequence(base)
6363
x.run()
6464
base.fill(x.retcodes, x.outputs, x.failed)
6565

@@ -175,8 +175,8 @@ def main():
175175

176176
cmds_base = []
177177
for d in dirs_to_process:
178-
cmd_base = CommandsBase(d, commands,
179-
config.get("cleanup"))
178+
cmd_base = CommandSequenceBase(d, commands,
179+
config.get("cleanup"))
180180
cmds_base.append(cmd_base)
181181

182182
# Map the commands into pool of workers so they can be processed.
@@ -189,7 +189,7 @@ def main():
189189
for cmds_base in cmds_base_results:
190190
logger.debug("Checking results of project {}".
191191
format(cmds_base))
192-
cmds = Commands(cmds_base)
192+
cmds = CommandSequence(cmds_base)
193193
cmds.fill(cmds_base.retcodes, cmds_base.outputs,
194194
cmds_base.failed)
195195
cmds.check(ignore_errors)

opengrok-tools/src/main/python/opengrok_tools/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import commands
1+
from . import commandsequence
22
from . import command
33
from . import opengrok
44
from . import utils
@@ -12,7 +12,7 @@
1212
'opengrok',
1313
'utils',
1414
'command',
15-
'commands',
15+
'commandsequence',
1616
'filelock',
1717
'hook',
1818
'repofactory',

opengrok-tools/src/main/python/opengrok_tools/utils/commands.py renamed to opengrok-tools/src/main/python/opengrok_tools/utils/commandsequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import json
2929

3030

31-
class CommandsBase:
31+
class CommandSequenceBase:
3232
"""
3333
Wrap the run of a set of Command instances.
3434
@@ -61,7 +61,7 @@ def fill(self, retcodes, outputs, failed):
6161
self.failed = failed
6262

6363

64-
class Commands(CommandsBase):
64+
class CommandSequence(CommandSequenceBase):
6565
PROJECT_SUBST = '%PROJECT%'
6666

6767
def __init__(self, base):

opengrok-tools/src/test/python/test_commands.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,47 @@
3232
os.path.join(os.path.dirname(__file__), '..', '..',
3333
'main', 'python')))
3434

35-
from opengrok_tools.utils.commands import Commands, CommandsBase
35+
from opengrok_tools.utils.commandsequence import CommandSequence, CommandSequenceBase
3636

3737

3838
class TestApp(unittest.TestCase):
3939
def test_str(self):
40-
cmds = Commands(CommandsBase("opengrok-master",
41-
[{"command": ['foo']}, {"command": ["bar"]}]))
40+
cmds = CommandSequence(CommandSequenceBase("opengrok-master",
41+
[{"command": ['foo']}, {"command": ["bar"]}]))
4242
self.assertEqual("opengrok-master", str(cmds))
4343

4444
@unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
4545
def test_run_retcodes(self):
46-
cmds = Commands(CommandsBase("opengrok-master",
47-
[{"command": ["/bin/echo"]},
48-
{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 0"]},
49-
{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 1"]}]))
46+
cmds = CommandSequence(CommandSequenceBase("opengrok-master",
47+
[{"command": ["/bin/echo"]},
48+
{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 0"]},
49+
{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 1"]}]))
5050
cmds.run()
5151
self.assertEqual({'/bin/echo opengrok-master': 0,
5252
'/bin/sh -c echo opengrok-master; exit 0': 0,
5353
'/bin/sh -c echo opengrok-master; exit 1': 1}, cmds.retcodes)
5454

5555
@unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
5656
def test_terminate_after_non_zero_code(self):
57-
cmds = Commands(CommandsBase("opengrok-master",
58-
[{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 255"]},
57+
cmds = CommandSequence(CommandSequenceBase("opengrok-master",
58+
[{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 255"]},
5959
{"command": ["/bin/echo"]}]))
6060
cmds.run()
6161
self.assertEqual({'/bin/sh -c echo opengrok-master; exit 255': 255}, cmds.retcodes)
6262

6363
@unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
6464
def test_exit_2_handling(self):
65-
cmds = Commands(CommandsBase("opengrok-master",
66-
[{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 2"]},
65+
cmds = CommandSequence(CommandSequenceBase("opengrok-master",
66+
[{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 2"]},
6767
{"command": ["/bin/echo"]}]))
6868
cmds.run()
6969
self.assertEqual({'/bin/sh -c echo opengrok-master; exit 2': 2}, cmds.retcodes)
7070
self.assertFalse(cmds.failed)
7171

7272
@unittest.skipUnless(os.path.exists('/bin/echo'), "requires Unix")
7373
def test_project_subst(self):
74-
cmds = Commands(CommandsBase("test-subst",
75-
[{"command": ["/bin/echo", Commands.PROJECT_SUBST]}]))
74+
cmds = CommandSequence(CommandSequenceBase("test-subst",
75+
[{"command": ["/bin/echo", CommandSequence.PROJECT_SUBST]}]))
7676
cmds.run()
7777
self.assertEqual(['test-subst\n'],
7878
cmds.outputs['/bin/echo test-subst'])

0 commit comments

Comments
 (0)