Corrections & lisibility in package command
Use os.path.join() rather than "/".join() Respect 80 chars wide formatmaster
parent
eab5121d97
commit
20f000f3b8
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os.path
|
||||
import time
|
||||
import tarfile
|
||||
|
||||
|
@ -44,14 +45,22 @@ def run(args, persoconf, logger):
|
|||
for app in args.apps :
|
||||
# Load app META file
|
||||
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:
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# TODO check that the app exists
|
||||
|
@ -74,7 +83,7 @@ def run(args, persoconf, logger):
|
|||
filedest = appmeta.files[f]["dest"]
|
||||
|
||||
# Remove possible 'home'. The final targz should be extracted
|
||||
# at 'home.
|
||||
# at $HOME.
|
||||
if filedest.startswith("~/"):
|
||||
filedest = filedest[2:]
|
||||
|
||||
|
@ -82,8 +91,10 @@ def run(args, persoconf, logger):
|
|||
try:
|
||||
pkg.add(filename, arcname=filedest)
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue