mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-30 23:36:23 +00:00
Set warnings filter on CLI programs.
Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
This commit is contained in:
parent
5943451017
commit
865f523b1f
11
apol
11
apol
@ -7,6 +7,7 @@
|
||||
import sys
|
||||
import argparse
|
||||
import logging
|
||||
import warnings
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
import setools
|
||||
@ -30,13 +31,23 @@ if args.debug:
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
console_handler.setFormatter(
|
||||
logging.Formatter('%(asctime)s|%(levelname)s|%(name)s|%(message)s'))
|
||||
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
|
||||
elif args.verbose:
|
||||
console_handler.setLevel(logging.INFO)
|
||||
console_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
console_handler.setLevel(logging.WARNING)
|
||||
console_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
logging.getLogger().addHandler(console_handler)
|
||||
|
||||
try:
|
||||
|
@ -9,6 +9,7 @@ import argparse
|
||||
import sys
|
||||
import logging
|
||||
import signal
|
||||
import warnings
|
||||
|
||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||
|
||||
@ -26,10 +27,16 @@ args = parser.parse_args()
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
try:
|
||||
p = setools.SELinuxPolicy(args.policy)
|
||||
|
7
sediff
7
sediff
@ -9,6 +9,7 @@ import argparse
|
||||
import sys
|
||||
import logging
|
||||
import signal
|
||||
import warnings
|
||||
from itertools import chain
|
||||
from contextlib import suppress
|
||||
from typing import List
|
||||
@ -115,10 +116,16 @@ all_differences = not any((args.class_, args.common, args.type_, args.attribute,
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
try:
|
||||
p1 = setools.SELinuxPolicy(args.POLICY1[0])
|
||||
|
7
sedta
7
sedta
@ -8,6 +8,7 @@ import sys
|
||||
import argparse
|
||||
import logging
|
||||
import signal
|
||||
import warnings
|
||||
|
||||
import setools
|
||||
|
||||
@ -97,10 +98,16 @@ if args.target and not (args.shortest_path or args.all_paths):
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
try:
|
||||
p = setools.SELinuxPolicy(args.policy)
|
||||
|
7
seinfo
7
seinfo
@ -11,6 +11,7 @@ import sys
|
||||
import logging
|
||||
import signal
|
||||
import ipaddress
|
||||
import warnings
|
||||
from typing import Callable, List, Tuple
|
||||
|
||||
|
||||
@ -102,10 +103,16 @@ args = parser.parse_args()
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
try:
|
||||
p = setools.SELinuxPolicy(args.policy)
|
||||
|
@ -9,6 +9,7 @@ import argparse
|
||||
import sys
|
||||
import logging
|
||||
import signal
|
||||
import warnings
|
||||
from typing import Dict, Optional
|
||||
|
||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||
@ -66,10 +67,16 @@ if args.limit_flows < 0:
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
booleans: Optional[Dict[str, bool]] = None
|
||||
if args.booleans == 'default':
|
||||
|
7
sesearch
7
sesearch
@ -9,6 +9,7 @@ import argparse
|
||||
import sys
|
||||
import logging
|
||||
import signal
|
||||
import warnings
|
||||
|
||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||
|
||||
@ -125,10 +126,16 @@ if not args.tertypes and not args.mlsrtypes and not args.rbacrtypes:
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("default")
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
if not sys.warnoptions:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
try:
|
||||
p = setools.SELinuxPolicy(args.policy)
|
||||
|
Loading…
Reference in New Issue
Block a user