def test_get_output_dir(self): test = ibuilder.get_output_dir(TEST_CONFIG_FILENAME) output = os.path.join(os.path.expanduser("~"), "projects", "ibuilder_project") self.assertEqual(test, output)
def image_builder(args, status): output_dir = None s = status s.Debug("Generating Project: %s" % args.config[0]) if len(args.output) > 0: output_dir = args.output[0] if args.upaths is None: args.upaths = [] paths = args.upaths local_path = os.path.abspath(os.getcwdu()) need_local = args.local for p in paths: if not os.path.exists(p): continue if os.path.abspath(p) == local_path: need_local = False break if need_local: paths.append(local_path) try: ibuilder.generate_project(args.config[0], user_paths=paths, output_directory=output_dir, status=s) except urllib2.URLError as ex: s.Fatal("URL Error: %s, Are you connected to the internet?" % str(ex)) sys.exit(1) if output_dir is None: output_dir = ibuilder.get_output_dir(args.config[0]) s.Info("Generating Project %s @ %s" % (args.config[0], output_dir)) if args.compress: output_dir = ibuilder.get_output_dir(args.config[0], dbg=args.debug) name = os.path.split(output_dir)[1] out_loc = os.path.split(output_dir)[0] s.Debug("Current dir: %s" % os.getcwd()) s.Debug("Output Location: %s" % out_loc) s.Debug("archive name: %s" % name) archive_loc = os.path.join(out_loc, name) s.Debug("Compress using gztar format") name = shutil.make_archive(base_name=archive_loc, format='gztar', root_dir=out_loc, base_dir=name) remove_output_project(output_dir, debug=args.debug) if args.zip: output_dir = ibuilder.get_output_dir(args.config[0], dbg=args.debug) name = os.path.split(output_dir)[1] out_loc = os.path.split(output_dir)[0] s.Debug("Current dir: %s" % os.getcwd()) s.Debug("Output Location: %s" % out_loc) s.Debug("archive name: %s" % name) archive_loc = os.path.join(out_loc, name) s.Debug("Compress using zip format") name = shutil.make_archive(base_name=archive_loc, format='zip', root_dir=out_loc, base_dir=name) remove_output_project(output_dir, debug=args.debug)