[elbe-devel] [PATCH] init: fix crash if --directory was not specified
Manuel Traut
manut at linutronix.de
Fri Apr 26 17:32:54 CEST 2019
this fixes #217
Traceback (most recent call last):
File "/usr/bin/elbe", line 55, in <module>
cmdmod.run_command(sys.argv[2:])
File "/usr/lib/python2.7/dist-packages/elbepack/commands/init.py", line 218, in run_command
init_template_dir, t), d, linebreak=True)
File "/usr/lib/python2.7/dist-packages/elbepack/templates.py", line 38, in write_template
outfile.write(template(fname, d, linebreak))
File "/usr/lib/python2.7/dist-packages/elbepack/templates.py", line 28, in template
**d)
File "/usr/lib/python2.7/dist-packages/mako/template.py", line 462, in render
return runtime._render(self, self.callable_, args, data)
File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 838, in _render
**_kwargs_for_callable(callable_, data))
File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 873, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 899, in _exec_template
callable_(context, *args, **kwargs)
File "_usr_lib_python2_7_dist_packages_elbepack_init_libvirt_xml_mako", line 46, in render_body
File "/usr/lib/python2.7/posixpath.py", line 70, in join
elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/commands/init.py | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 8b5a6fee..08f77d1e 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -36,7 +36,7 @@ def run_command(argv):
dest="skip_validation", default=False,
help="Skip xml schema validation")
- oparser.add_option("--directory", dest="directory",
+ oparser.add_option("--directory", dest="directory", default="./build",
help="Working directory (default is build)",
metavar="FILE")
@@ -142,11 +142,6 @@ def run_command(argv):
cdrom = mirror.ensure_child("cdrom")
cdrom.set_text(os.path.abspath(opt.cdrom))
- if not opt.directory:
- path = "./build"
- else:
- path = opt.directory
-
# this is a workaround for
# http://lists.linutronix.de/pipermail/elbe-devel/2017-July/000541.html
_, virt = command_out('test -x /usr/bin/systemd-detect-virt && /usr/bin/systemd-detect-virt');
@@ -158,14 +153,14 @@ def run_command(argv):
machine_type = 'pc'
try:
- os.makedirs(path)
+ os.makedirs(opt.directory)
except OSError as e:
print(
"unable to create project directory: %s (%s)" %
- (path, e.strerror))
+ (opt.directory, e.strerror))
sys.exit(30)
- out_path = os.path.join(path, ".elbe-in")
+ out_path = os.path.join(opt.directory, ".elbe-in")
try:
os.makedirs(out_path)
except OSError as e:
@@ -214,7 +209,7 @@ def run_command(argv):
if t == "Makefile.mako" or t == "libvirt.xml.mako":
write_template(
os.path.join(
- path, o), os.path.join(
+ opt.directory, o), os.path.join(
init_template_dir, t), d, linebreak=True)
else:
write_template(
--
2.20.1
More information about the elbe-devel
mailing list