def install_osx():
 with os.popen('which hass') as inp:
  hass_path = inp.read().strip()
 with os.popen('whoami') as inp:
  user = inp.read().strip()
 template_path = os.path.join(os.path.dirname(__file__), 'launchd.plist')
 with open(template_path, 'r', encoding='utf-8') as inp:
  plist = inp.read()
 plist = plist.replace('$HASS_PATH$', hass_path)
 plist = plist.replace('$USER$', user)
 path = os.path.expanduser('~/Library/LaunchAgents/org.homeassistant.plist')
 try:
  with open(path, 'w', encoding='utf-8') as outp:
   outp.write(plist)
 except IOError as err:
  print (('Unable to write to ' + path), err)
  return
 os.popen(('launchctl load -w -F ' + path))
 print 'Home Assistant has been installed.         Open it here: http://localhost:8123'

def install_osx ( ) : with os . popen ( 'which hass' ) as inp : hass_path = inp . read ( ) . strip ( ) with os . popen ( 'whoami' ) as inp : user = inp . read ( ) . strip ( ) template_path = os . path . join ( os . path . dirname ( __file__ ) , 'launchd.plist' ) with open ( template_path , 'r' , encoding = 'utf-8' ) as inp : plist = inp . read ( ) plist = plist . replace ( '$HASS_PATH$' , hass_path ) plist = plist . replace ( '$USER$' , user ) path = os . path . expanduser ( '~/Library/LaunchAgents/org.homeassistant.plist' ) try : with open ( path , 'w' , encoding = 'utf-8' ) as outp : outp . write ( plist ) except IOError as err : print ( ( 'Unable to write to ' + path ) , err ) return os . popen ( ( 'launchctl load -w -F ' + path ) ) print 'Home Assistant has been installed.         Open it here: http://localhost:8123'
setup to run via launchd on os x .