Corrections & lisibility in package command

Use os.path.join() rather than "/".join()
Respect 80 chars wide format
master
Lertsenem 2015-12-07 16:56:13 +01:00
parent eab5121d97
commit 20f000f3b8
1 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os.path
import time import time
import tarfile import tarfile
@ -44,14 +45,22 @@ def run(args, persoconf, logger):
for app in args.apps : for app in args.apps :
# Load app META file # Load app META file
try: try:
appmetas.append( Metafile(json_path = "/".join([persoconf.path, app, persoconf.metafile])) ) appmetas.append(
Metafile(json_path = os.path.join(
persoconf.path ,
app ,
persoconf.metafile)
)
)
except FileNotFoundError: except FileNotFoundError:
logger.warning("Metafile %s does not exist for app %s; ignoring" % (persoconf.metafile, app)) logger.warning( "Metafile %s does not exist for app %s; ignoring"
% (persoconf.metafile, app) )
continue continue
except MalformedMetafileError: except MalformedMetafileError:
logger.warning("Malformed metafile %s in app %s; ignoring" % (persoconf.metafile, app) ) logger.warning( "Malformed metafile %s in app %s; ignoring"
% (persoconf.metafile, app) )
continue continue
# TODO check that the app exists # TODO check that the app exists
@ -74,7 +83,7 @@ def run(args, persoconf, logger):
filedest = appmeta.files[f]["dest"] filedest = appmeta.files[f]["dest"]
# Remove possible 'home'. The final targz should be extracted # Remove possible 'home'. The final targz should be extracted
# at 'home. # at $HOME.
if filedest.startswith("~/"): if filedest.startswith("~/"):
filedest = filedest[2:] filedest = filedest[2:]
@ -82,8 +91,10 @@ def run(args, persoconf, logger):
try: try:
pkg.add(filename, arcname=filedest) pkg.add(filename, arcname=filedest)
logger.info("Adding %s to package" % f) logger.info("Adding %s to package" % f)
except:
logger.warning("Failed to add %s to tar package %s" % (f, pkgname)) except Exception as e:
logger.warning( "Failed to add %s to tar package %s: %s"
% (f, pkgname, str(e)) )
pkg.close() pkg.close()