Skip to content

Commit 03ae44b

Browse files
author
Vladimir Kotal
committed
make it possible to find path to the Messages script
1 parent f339c41 commit 03ae44b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/sync/sync.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import commands
4848
from commands import Commands, CommandsBase
4949
from readconfig import read_config
50+
from shutil import which
5051

5152

5253
major_version = sys.version_info[0]
@@ -96,6 +97,8 @@ def worker(base):
9697
help='config file in JSON format')
9798
parser.add_argument('-I', '--indexed', action='store_true',
9899
help='Sync indexed projects only')
100+
parser.add_argument('-m', '--messages',
101+
help='path to the Messages binary')
99102
args = parser.parse_args()
100103

101104
if args.debug:
@@ -108,6 +111,18 @@ def worker(base):
108111

109112
logger = logging.getLogger(os.path.basename(sys.argv[0]))
110113

114+
if args.messages:
115+
messages_file = which(args.messages)
116+
if not messages_file:
117+
logger.error("file {} does not exist".format(args.messages))
118+
sys.exit(1)
119+
else:
120+
messages_file = which("Messages")
121+
if not messages_file:
122+
logger.error("cannot determine path to Messages")
123+
sys.exit(1)
124+
logger.debug("Messages = {}".format(messages_file))
125+
111126
config = read_config(logger, args.config)
112127
if config is None:
113128
logger.error("Cannot read config file from {}".format(args.config))
@@ -139,7 +154,7 @@ def worker(base):
139154
dirs_to_process = args.projects
140155
elif args.indexed:
141156
# XXX replace this with REST request after issue #1801
142-
cmd = Command(['/usr/opengrok/bin/Messages', '-n', 'project',
157+
cmd = Command([messages_file, '-n', 'project',
143158
'list-indexed'])
144159
cmd.execute()
145160
if cmd.state is "finished":

0 commit comments

Comments
 (0)