1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!@PYTHON@
"""\
nbb - ndim's branch builder
Build, install given branch of source code into a branch specific place
Copyright (C) 2007, 2008 Hans Ulrich Niedermann <hun@n-dimensional.de>
License conditions TBA
"""
import sys
import os
PACKAGE_VERSION = "@PACKAGE_VERSION@"
if sys.version_info < (2,4):
print "Fatal: This program requires Python 2.4 or later."
sys.exit(3)
import logging # since python 2.3
# funcName: Since python 2.5
# format="%(filename)s:%(lineno)d:%(funcName)s:"
logging.basicConfig(format = "%(levelname)s: %(message)s",
# level = logging.DEBUG,
level = logging.WARNING,
stream = sys.stderr)
if False:
logging.debug("xxx debug")
logging.info("xxx info")
logging.warning("xxx warn")
logging.error("xxx error")
if __name__ == '__main__':
pythondir = "@pythondir@"
lib_found = False
#print "pythondir", pythondir
#print "sys.path", sys.path
sys.stdout.flush()
orig_path = sys.path
for cond, path in [
(True, orig_path),
(os.path.exists(pythondir), [pythondir] + orig_path),
]:
if cond:
sys.path = path
try:
import nbblib
logging.debug("nbb.PACKAGE_VERSION %s, nbblib.PACKAGE_VERSION %s",
PACKAGE_VERSION, nbblib.PACKAGE_VERSION)
assert(nbblib.PACKAGE_VERSION == PACKAGE_VERSION)
lib_found = True
break
except AssertionError, e:
logging.debug("Assertion error", exc_info=True)
sys.path = orig_path
except ImportError, e:
logging.debug("Import error", exc_info=True)
sys.path = orig_path
if not lib_found:
logging.error("nbb: Fatal: Could not import nbblib.")
logging.shutdown()
sys.exit(3)
import nbblib.main
nbblib.main.cmdmain(sys.argv)
# vim: syntax=python
# Local Variables:
# mode: python
# End:
|