47
47
import commands
48
48
from commands import Commands , CommandsBase
49
49
from readconfig import read_config
50
+ from shutil import which
50
51
51
52
52
53
major_version = sys .version_info [0 ]
@@ -96,6 +97,8 @@ def worker(base):
96
97
help = 'config file in JSON format' )
97
98
parser .add_argument ('-I' , '--indexed' , action = 'store_true' ,
98
99
help = 'Sync indexed projects only' )
100
+ parser .add_argument ('-m' , '--messages' ,
101
+ help = 'path to the Messages binary' )
99
102
args = parser .parse_args ()
100
103
101
104
if args .debug :
@@ -108,6 +111,18 @@ def worker(base):
108
111
109
112
logger = logging .getLogger (os .path .basename (sys .argv [0 ]))
110
113
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
+
111
126
config = read_config (logger , args .config )
112
127
if config is None :
113
128
logger .error ("Cannot read config file from {}" .format (args .config ))
@@ -139,7 +154,7 @@ def worker(base):
139
154
dirs_to_process = args .projects
140
155
elif args .indexed :
141
156
# 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' ,
143
158
'list-indexed' ])
144
159
cmd .execute ()
145
160
if cmd .state is "finished" :
0 commit comments