mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-08-17 11:50:11 +02:00
Merge branch 'nice-console-output' into 'master'
method to globally set logging to output nicely to the console See merge request fdroid/fdroidserver!1449
This commit is contained in:
commit
9dc14674f1
@ -192,6 +192,31 @@ def setup_global_opts(parser):
|
|||||||
help=_("Restrict output to warnings and errors"))
|
help=_("Restrict output to warnings and errors"))
|
||||||
|
|
||||||
|
|
||||||
|
def set_console_logging(verbose=False):
|
||||||
|
"""Globally set logging to output nicely to the console."""
|
||||||
|
|
||||||
|
class _StdOutFilter(logging.Filter):
|
||||||
|
def filter(self, record):
|
||||||
|
return record.levelno < logging.ERROR
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
level = logging.DEBUG
|
||||||
|
else:
|
||||||
|
level = logging.ERROR
|
||||||
|
|
||||||
|
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
stdout_handler.addFilter(_StdOutFilter())
|
||||||
|
stdout_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||||
|
|
||||||
|
stderr_handler = logging.StreamHandler(sys.stderr)
|
||||||
|
stderr_handler.setLevel(logging.ERROR)
|
||||||
|
stderr_handler.setFormatter(logging.Formatter(_('ERROR: %(message)s')))
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
force=True, level=level, handlers=[stdout_handler, stderr_handler]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _add_java_paths_to_config(pathlist, thisconfig):
|
def _add_java_paths_to_config(pathlist, thisconfig):
|
||||||
def path_version_key(s):
|
def path_version_key(s):
|
||||||
versionlist = []
|
versionlist = []
|
||||||
|
@ -83,6 +83,8 @@ def main():
|
|||||||
)
|
)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
common.set_console_logging(options.verbose)
|
||||||
|
|
||||||
fdroiddir = os.getcwd()
|
fdroiddir = os.getcwd()
|
||||||
test_config = dict()
|
test_config = dict()
|
||||||
examplesdir = common.get_examples_dir()
|
examplesdir = common.get_examples_dir()
|
||||||
@ -290,4 +292,9 @@ and https://f-droid.org/docs/Signing_Process'''
|
|||||||
)
|
)
|
||||||
% os.path.join(fdroiddir, 'repo')
|
% os.path.join(fdroiddir, 'repo')
|
||||||
)
|
)
|
||||||
logging.info(msg)
|
if not options.quiet:
|
||||||
|
# normally, INFO is only shown with --verbose, but show this unless --quiet
|
||||||
|
logger = logging.getLogger()
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
logger.info(msg)
|
||||||
|
logging.shutdown()
|
||||||
|
@ -54,6 +54,8 @@ def main():
|
|||||||
help=_("Install all signed applications available"))
|
help=_("Install all signed applications available"))
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
common.set_console_logging(options.verbose)
|
||||||
|
|
||||||
if not options.appid and not options.all:
|
if not options.appid and not options.all:
|
||||||
parser.error(_("option %s: If you really want to install all the signed apps, use --all") % "all")
|
parser.error(_("option %s: If you really want to install all the signed apps, use --all") % "all")
|
||||||
|
|
||||||
|
@ -95,6 +95,8 @@ def main():
|
|||||||
)
|
)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
common.set_console_logging(options.verbose)
|
||||||
|
|
||||||
if options.all:
|
if options.all:
|
||||||
options.archive = True
|
options.archive = True
|
||||||
options.build_logs = True
|
options.build_logs = True
|
||||||
@ -152,10 +154,10 @@ def main():
|
|||||||
if hostname == 'f-droid.org' or (
|
if hostname == 'f-droid.org' or (
|
||||||
ip is not None and hostname in socket.gethostbyname_ex('f-droid.org')[2]
|
ip is not None and hostname in socket.gethostbyname_ex('f-droid.org')[2]
|
||||||
):
|
):
|
||||||
print(
|
logging.error(
|
||||||
_(
|
_(
|
||||||
'ERROR: this command should never be used to mirror f-droid.org!\n'
|
'This command should never be used to mirror f-droid.org! '
|
||||||
'A full mirror of f-droid.org requires more than 200GB.'
|
'A full copy requires more than 600GB.'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -105,6 +105,8 @@ def main():
|
|||||||
parser.add_argument("--no-check-https", action="store_true", default=False)
|
parser.add_argument("--no-check-https", action="store_true", default=False)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
common.set_console_logging(options.verbose)
|
||||||
|
|
||||||
# Read config.py...
|
# Read config.py...
|
||||||
common.read_config(options)
|
common.read_config(options)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user