Skip to content

Commit 339e8d0

Browse files
author
Vladimir Kotal
authored
fixups to mirroring functions (#2747)
1 parent c8ea201 commit 339e8d0

File tree

12 files changed

+50
-62
lines changed

12 files changed

+50
-62
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import sys
2727

2828
from .utils.java import Java
29-
from .utils.log import print_exc_exit
29+
from .utils.log import fatal
3030
from .utils.parsers import get_javaparser
3131

3232
"""
@@ -42,7 +42,7 @@ def main():
4242
try:
4343
args = parser.parse_args()
4444
except ValueError as e:
45-
print_exc_exit(e)
45+
fatal(e)
4646

4747
# Avoid using utils.log.get_console_level() since the stdout of the program
4848
# is interpreted as data.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from zipfile import ZipFile
3030

3131
from .utils.log import get_console_logger, get_class_basename, \
32-
print_exc_exit
32+
fatal
3333
from .utils.parsers import get_baseparser
3434

3535
"""
@@ -111,7 +111,7 @@ def main():
111111
try:
112112
args = parser.parse_args()
113113
except ValueError as e:
114-
print_exc_exit(e)
114+
fatal(e)
115115

116116
logger = get_console_logger(get_class_basename(), args.loglevel)
117117

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import sys
2626

2727
from .utils.java import Java
28-
from .utils.log import get_console_logger, get_class_basename, print_exc_exit
28+
from .utils.log import get_console_logger, get_class_basename, fatal
2929
from .utils.parsers import get_javaparser
3030

3131
"""
@@ -41,7 +41,7 @@ def main():
4141
try:
4242
args = parser.parse_args()
4343
except ValueError as e:
44-
print_exc_exit(e)
44+
fatal(e)
4545

4646
logger = get_console_logger(get_class_basename(), args.loglevel)
4747

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import sys
2828

2929
from .utils.indexer import FindCtags, Indexer
30-
from .utils.log import get_console_logger, get_class_basename, print_exc_exit
30+
from .utils.log import get_console_logger, get_class_basename, fatal
3131
from .utils.parsers import get_javaparser
3232

3333
"""
@@ -46,7 +46,7 @@ def main():
4646
try:
4747
args = parser.parse_args()
4848
except ValueError as e:
49-
print_exc_exit(e)
49+
fatal(e)
5050

5151
logger = get_console_logger(get_class_basename(), args.loglevel)
5252

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import sys
2727

2828
from .utils.java import Java
29-
from .utils.log import get_console_logger, get_class_basename, print_exc_exit
29+
from .utils.log import get_console_logger, get_class_basename, fatal
3030
from .utils.parsers import get_javaparser
3131

3232

@@ -39,7 +39,7 @@ def main():
3939
try:
4040
args = parser.parse_args()
4141
except ValueError as e:
42-
print_exc_exit(e)
42+
fatal(e)
4343

4444
logger = get_console_logger(get_class_basename(), args.loglevel)
4545

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from filelock import Timeout, FileLock
4040

4141
from .utils.log import get_console_logger, get_class_basename, \
42-
print_exc_exit, get_batch_logger
42+
fatal, get_batch_logger
4343
from .utils.opengrok import get_config_value, list_indexed_projects
4444
from .utils.parsers import get_baseparser
4545
from .utils.readconfig import read_config
@@ -50,8 +50,7 @@
5050

5151
major_version = sys.version_info[0]
5252
if major_version < 3:
53-
print("Need Python 3, you are running {}".format(major_version))
54-
sys.exit(1)
53+
fatal("Need Python 3, you are running {}".format(major_version))
5554

5655
__version__ = "0.8"
5756

@@ -99,30 +98,26 @@ def main():
9998
try:
10099
args = parser.parse_args()
101100
except ValueError as e:
102-
print_exc_exit(e)
101+
fatal(e)
103102

104103
logger = get_console_logger(get_class_basename(), args.loglevel)
105104

106105
if len(args.project) > 0 and args.all:
107-
logger.fatal("Cannot use both project list and -a/--all")
108-
sys.exit(1)
106+
fatal("Cannot use both project list and -a/--all")
109107

110108
if not args.all and len(args.project) == 0:
111-
logger.fatal("Need at least one project or --all")
112-
sys.exit(1)
109+
fatal("Need at least one project or --all")
113110

114111
if args.config:
115112
config = read_config(logger, args.config)
116113
if config is None:
117-
logger.fatal("Cannot read config file from {}".format(args.config))
118-
sys.exit(1)
114+
fatal("Cannot read config file from {}".format(args.config))
119115
else:
120116
config = {}
121117

122118
uri = args.uri
123119
if not is_web_uri(uri):
124-
logger.fatal("Not a URI: {}".format(uri))
125-
sys.exit(1)
120+
fatal("Not a URI: {}".format(uri))
126121
logger.debug("web application URI = {}".format(uri))
127122

128123
if not check_configuration(config):
@@ -153,9 +148,8 @@ def main():
153148
if args.batch:
154149
logdir = config.get(LOGDIR_PROPERTY)
155150
if not logdir:
156-
logger.fatal("The {} property is required in batch mode".
157-
format(LOGDIR_PROPERTY))
158-
sys.exit(1)
151+
fatal("The {} property is required in batch mode".
152+
format(LOGDIR_PROPERTY))
159153

160154
projects = args.project
161155
if len(projects) == 1:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
from .utils.command import Command
4040
from .utils.log import get_console_logger, get_class_basename, \
41-
print_exc_exit
41+
fatal
4242
from .utils.opengrok import get_configuration, set_configuration, \
4343
add_project, delete_project, get_config_value
4444
from .utils.parsers import get_baseparser
@@ -247,7 +247,7 @@ def main():
247247
try:
248248
args = parser.parse_args()
249249
except ValueError as e:
250-
print_exc_exit(e)
250+
fatal(e)
251251

252252
doit = not args.noop
253253
configmerge = None

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

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

3030
from .utils.indexer import Indexer
31-
from .utils.log import get_console_logger, get_class_basename, print_exc_exit
31+
from .utils.log import get_console_logger, get_class_basename, fatal
3232
from .utils.opengrok import get_configuration
3333
from .utils.parsers import get_javaparser
3434

@@ -87,7 +87,7 @@ def main():
8787
try:
8888
args = parser.parse_args()
8989
except ValueError as e:
90-
print_exc_exit(e)
90+
fatal(e)
9191

9292
logger = get_console_logger(get_class_basename(), args.loglevel)
9393

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from filelock import Timeout, FileLock
3838

3939
from .utils.commandsequence import CommandSequence, CommandSequenceBase
40-
from .utils.log import get_console_logger, get_class_basename, print_exc_exit
40+
from .utils.log import get_console_logger, get_class_basename, fatal
4141
from .utils.opengrok import list_indexed_projects, get_config_value
4242
from .utils.parsers import get_baseparser
4343
from .utils.readconfig import read_config
@@ -95,7 +95,7 @@ def main():
9595
try:
9696
args = parser.parse_args()
9797
except ValueError as e:
98-
print_exc_exit(e)
98+
fatal(e)
9999

100100
logger = get_console_logger(get_class_basename(), args.loglevel)
101101

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
from logging.handlers import RotatingFileHandler
2929

3030

31-
def print_exc_exit(e):
31+
def fatal(msg):
3232
"""
33-
Print exception and exit
34-
:param e: exception
35-
:return: nothing
33+
Print message to standard error output and exit
34+
:param msg: message
3635
"""
37-
print(e, file=sys.stderr)
36+
print(msg, file=sys.stderr)
3837
sys.exit(1)
3938

4039

0 commit comments

Comments
 (0)