Mercurial > cgi-bin > hgweb.cgi > tincan
comparison tincan.py @ 46:997d0c8c174f draft
Default for the launch callable should be not to log.
author | David Barts <n5jrn@me.com> |
---|---|
date | Thu, 30 May 2019 16:36:43 -0700 |
parents | 969f515b505b |
children | 3a6180c1feea |
comparison
equal
deleted
inserted
replaced
45:969f515b505b | 46:997d0c8c174f |
---|---|
19 from stat import S_ISDIR, S_ISREG | 19 from stat import S_ISDIR, S_ISREG |
20 from string import whitespace | 20 from string import whitespace |
21 from threading import Lock | 21 from threading import Lock |
22 import time | 22 import time |
23 import urllib | 23 import urllib |
24 import uuid | |
25 | 24 |
26 import bottle | 25 import bottle |
27 | 26 |
28 # E x c e p t i o n s | 27 # E x c e p t i o n s |
29 | 28 |
881 self.logger.error(str(e)) | 880 self.logger.error(str(e)) |
882 self.errors += 1 | 881 self.errors += 1 |
883 elif S_ISDIR(etype): | 882 elif S_ISDIR(etype): |
884 self._launch(subdir + [entry]) | 883 self._launch(subdir + [entry]) |
885 | 884 |
886 def launch(fsroot=None, urlroot='/', logger=None, debug=False, | 885 _BITBUCKET = logging.getLogger(__name__) |
887 encoding=ENCODING, static=False, multithread=True): | 886 _BITBUCKET.addHandler(logging.NullHandler) |
887 | |
888 def launch(fsroot=None, urlroot='/', logger=_BITBUCKET, encoding=ENCODING, | |
889 static=False, multithread=True): | |
888 """ | 890 """ |
889 Launch and return a TinCan webapp. Does not run the app; it is the | 891 Launch and return a TinCan webapp. Does not run the app; it is the |
890 caller's responsibility to call app.run() | 892 caller's responsibility to call app.run() |
891 """ | 893 """ |
892 if logger is None: | |
893 logger = logging.getLogger("{0!s}-{1!s}".format(__name__, uuid.uuid1())) | |
894 logger.addHandler(logging.StreamHandler()) | |
895 logger.setLevel(logging.DEBUG if debug else logging.INFO) | |
896 if fsroot is None: | 894 if fsroot is None: |
897 fsroot = os.getcwd() | 895 fsroot = os.getcwd() |
898 launcher = _Launcher(fsroot, urlroot, multithread) | 896 launcher = _Launcher(fsroot, urlroot, multithread) |
899 launcher.logger = logger | 897 launcher.logger = logger |
900 launcher.encoding = encoding | 898 launcher.encoding = encoding |