old_contents: # -*- coding: utf-8 -*-
  # Copyright 2016 upvm Contributors (see CONTRIBUTORS.md file in source)
  # License: Apache License 2.0 (see LICENSE file in source)
  
  # Modules from standard library
  from __future__ import print_function
  import os
  from sys import stdout, exit
  import subprocess
  import json
  
  # Custom modules
  from . import string_ops as c
  
  # Version info
  __version__ = '0.10.7'
  __date__    = '2016/02/19'
  
  # All references to program name should use this
  prog = 'upvm'
  
  # Path to helper blockdev script
  blockdevHelper = '/usr/share/{}/dd-helper.py'.format(prog)
  
  # Set config file locations used by configargparse
  cfgfileExample = '/usr/share/{}/example.conf'.format(prog)
  cfgfileSystem = '/etc/{}.conf'.format(prog)
  cfgfileUser = '~/.config/{}.conf'.format(prog)
  
  # This directory will hold cache files for tab-completion
  tabCacheDir = "{}/.cache/{}".format(os.environ['HOME'], prog)
  
  # This is the default args to pass to virt-install's --boot=
  virtinstall_default_bootopts = 'cdrom,hd,network,menu=on,useserial=on'
  
  # Hmmmmmm
  defaultRegisterScript = '{}/bin/reg'.format(os.environ['HOME'])
  
  # This will hold the options namespace generated by argparse
  opts = None
  
  # This holds output of command: osinfo-query os -f short-id
  osvariantChoices = []
  
  # This holds full output of cmd: virt-builder --list --list-format=json
  templateList = []
  
  # This is derived from the above -- a list of template names only
  templateChoices = []
  
  # This is also derived from templateList -- details about the chosen template
  templateInfo = {}
  
  # This holds list of VM names to avoid collisions
  guestList = []
  
  def get_virt_builder_list(returnType=None):
      cmd = ['virt-builder', '--list']
      if returnType == 'json':
          cmd.append('--list-format=json')
      c.debug("Executing: {}".format(" ".join(cmd)))
      try:
          out = subprocess.check_output(cmd)
      except:
          print(c.RED("\nError executing virt-builder --list\nProbably network connectivity issue\n"))
          exit(1)
      if returnType == 'json':
          return json.loads(out)['templates']
      else:
          return out
  
  def prompt_for_template_and_exit():
      if stdout.isatty():
          print(c.cyan("Press Ctrl-c to quit or Enter to see available virt-builder templates"))
          x = raw_input("")
          print(get_virt_builder_list())
          exit()
      else:
          exit(1)
  
  def cleanup_imagefile():
      try:
          imgfile = opts.outFile
      except:
          return
      try:
          os.remove(imgfile)
      except:
          print(c.yellow("[Cleanup] Deleting image file '{}' failed; you can safely delete it yourself".format(imgfile)))
      else:
          c.verbose("[Cleanup] Deleted image file '{}'".format(imgfile))
  
new_contents: # -*- coding: utf-8 -*-
  # Copyright 2016 upvm Contributors (see CONTRIBUTORS.md file in source)
  # License: Apache License 2.0 (see LICENSE file in source)
  
  # Modules from standard library
  from __future__ import print_function
  import os
  from sys import stdout, exit
  import subprocess
  import json
  
  # Custom modules
  from . import string_ops as c
  
  # Version info
  __version__ = '0.10.8'
  __date__    = '2016/03/01'
  
  # All references to program name should use this
  prog = 'upvm'
  
  # Path to helper blockdev script
  blockdevHelper = '/usr/share/{}/dd-helper.py'.format(prog)
  
  # Set config file locations used by configargparse
  cfgfileExample = '/usr/share/{}/example.conf'.format(prog)
  cfgfileSystem = '/etc/{}.conf'.format(prog)
  cfgfileUser = '~/.config/{}.conf'.format(prog)
  
  # This directory will hold cache files for tab-completion
  tabCacheDir = "{}/.cache/{}".format(os.environ['HOME'], prog)
  
  # This is the default args to pass to virt-install's --boot=
  virtinstall_default_bootopts = 'cdrom,hd,network'
  
  # Hmmmmmm
  defaultRegisterScript = '{}/bin/reg'.format(os.environ['HOME'])
  
  # This will hold the options namespace generated by argparse
  opts = None
  
  # This holds output of command: osinfo-query os -f short-id
  osvariantChoices = []
  
  # This holds full output of cmd: virt-builder --list --list-format=json
  templateList = []
  
  # This is derived from the above -- a list of template names only
  templateChoices = []
  
  # This is also derived from templateList -- details about the chosen template
  templateInfo = {}
  
  # This holds list of VM names to avoid collisions
  guestList = []
  
  def get_virt_builder_list(returnType=None):
      cmd = ['virt-builder', '--list']
      if returnType == 'json':
          cmd.append('--list-format=json')
      c.debug("Executing: {}".format(" ".join(cmd)))
      try:
          out = subprocess.check_output(cmd)
      except:
          print(c.RED("\nError executing virt-builder --list\nProbably network connectivity issue\n"))
          exit(1)
      if returnType == 'json':
          return json.loads(out)['templates']
      else:
          return out
  
  def prompt_for_template_and_exit():
      if stdout.isatty():
          print(c.cyan("Press Ctrl-c to quit or Enter to see available virt-builder templates"))
          x = raw_input("")
          print(get_virt_builder_list())
          exit()
      else:
          exit(1)
  
  def cleanup_imagefile():
      try:
          imgfile = opts.outFile
      except:
          return
      try:
          os.remove(imgfile)
      except:
          print(c.yellow("[Cleanup] Deleting image file '{}' failed; you can safely delete it yourself".format(imgfile)))
      else:
          c.verbose("[Cleanup] Deleted image file '{}'".format(imgfile))
  
subject: remove menu=on,useserial=on from virt-install --boot=