from ..payload import Payload
from .. import constants
from ..config import save_config_value
from ..demote import check_output_demoted
from ..log import log_to_client

def _get_mac_username():
    proposed_mac_username = check_output_demoted(['echo', '$USER'])
    if input('Is {} your mac_username. Enter y for yes'.format(proposed_mac_username)).upper() == 'Y':
        return proposed_mac_username
    else:
        return input('Enter your actual mac_username: ').strip()

def _get_default_specs_repo():
    return input('Please input the repo of your specs repo. For example github.com/gamechanger/dusty: ').strip()

def _get_nginx_includes_dir():
    return input('Please input the path where your nginx config pulls extra configs.  The default value is: /usr/local/etc/nginx/servers').strip()

def setup_dusty_config():
    logging.info('Going to be setting values for these config values: {}'. constants.WARN_ON_MISSING_CONFIG_KEYS)
    mac_username = _get_mac_username()
    specs_repo = _get_default_specs_repo()
    nginx_includes_dir = _get_nginx_includes_dir()
    config_dictionary = {'mac_username': mac_username,
                         'specs_repo': specs_repo,
                         'nginx_includes_dir':nginx_includes_dir}

    return Payload(save_dusty_config, config_dictionary)


def save_dusty_config(dict):
    for key, value in dict.iteritems():
        save_config_value(key, value)
    save_config_value('setup_has_run', True)
    log_to_client('You should now be able to use dusty!')

@@ -1,12 +1,28 @@
+import logging%0A%0A
 from ..paylo
@@ -278,16 +278,20 @@
 %0A    if 
+raw_
 input('I
@@ -329,16 +329,18 @@
  for yes
+: 
 '.format
@@ -438,24 +438,28 @@
      return 
+raw_
 input('Enter
@@ -531,32 +531,36 @@
 o():%0A    return 
+raw_
 input('Please in
@@ -688,16 +688,20 @@
  return 
+raw_
 input('P
@@ -787,17 +787,16 @@
 value is
-:
  /usr/lo
@@ -816,16 +816,18 @@
 /servers
+: 
 ').strip
@@ -930,17 +930,23 @@
 es: %7B%7D'.
- 
+format(
 constant
@@ -975,16 +975,17 @@
 IG_KEYS)
+)
 %0A    mac

fix small bugs