@@ -57,7 +57,7 @@ class SWUGenerator:
new = image
break
if not new:
- print("New artifact %s" % entry['filename'])
+ logging.debug("New artifact %s" % entry['filename'])
new = Artifact(entry['filename'])
if not new.findfile(self.artifactory):
logging.critical("Artifact %s not found" % entry['filename'])
@@ -107,7 +107,7 @@ class SWUGenerator:
self.artifacts.append(new)
else:
- print("Artifact %s already stored" % entry['filename'])
+ logging.debug("Artifact %s already stored" % entry['filename'])
entry['filename'] = new.newfilename
entry['sha256'] = new.getsha256()
@@ -121,7 +121,7 @@ class SWUGenerator:
for t in val:
self.find_files_in_swdesc(t)
else:
- print("%s = %s" % (n, val))
+ logging.debug("%s = %s" % (n, val))
if n == 'filename':
self.filelist.append(first)
@@ -124,20 +124,36 @@ def main() -> None:
help="configuration file",
)
+ parser.add_argument(
+ "-l",
+ "--loglevel",
+ help="set log level, default is WARNING",
+ )
parser.add_argument('command', metavar='command', default=[], help='command to be executed (create)')
args = parser.parse_args()
+ if args.loglevel:
+ if args.loglevel == "DEBUG":
+ logging.basicConfig(level=logging.DEBUG)
+ if args.loglevel == "INFO":
+ logging.basicConfig(level=logging.INFO)
+ if args.loglevel == "ERROR":
+ logging.basicConfig(level=logging.ERROR)
+ if args.loglevel == "CRITICAL":
+ logging.basicConfig(level=logging.CRITICAL)
+
# Read configuration file if any
vars = {}
if args.config and args.config != "":
- print ("Reading configuration file %s" % args.config)
+ logging.info("Reading configuration file %s" % args.config)
+
with codecs.open(args.config, 'r', 'utf-8') as f:
config = libconf.load(f)
for key, keydict in config.items():
if key == 'variables':
for varname, varvalue in keydict.items():
- print("VAR = %s VAL = %s" % (varname, varvalue))
+ logging.debug("VAR = %s VAL = %s" % (varname, varvalue))
vars[varname] = varvalue
f.close()
Signed-off-by: Stefano Babic <sbabic@denx.de> --- swugenerator/generator.py | 6 +++--- swugenerator/main.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-)