def handle(self, *args, **options):
    if len(args) > 3 or len(args) == 0:
      raise CommandError(_("Expected arguments: app_name app_web_url [app_dir]"))
    app_name = args[0]
    if len(args) == 2:
      app_url = args[1]
      app_dir = os.getcwd()
    elif len(args) == 3:
      app_url = args[1]
      app_dir = args[2]
    else:
      app_url = "http://gethue.com"
      app_dir = os.getcwd()

    app_template = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'app_template_proxy'))
    assert os.path.isdir(app_template), _("App template dir missing: %(template)s.") % {'template': app_template}
    app_dir = os.path.join(app_dir, app_name)

    if not os.path.exists(app_template):
      raise CommandError(_("The template path, %(path)r, does not exist.") % {'path': app_template})

    if not re.search(r'^\w+$', app_name):
      raise CommandError(_("%(name)r is not a valid application name. Use only numbers, letters and underscores.") % {'name': app_name})
    try:
      os.makedirs(app_dir)
    except OSError, e:
      raise CommandError(e)

    copy_template(app_template, app_dir, app_name, app_url)
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/management/commands/create_proxy_app.py/Command.handle/original