from __future__ import absolute_import, division, print_function, unicode_literals

from contextlib import closing

from command import Router
from config import Config
from network import Discovery
from sound import Microphone

if __name__ == '__main__':
  discovery = Discovery.Discovery(Config.discovery_port,
                                  Config.discovery_timeout,
                                  Router.ROUTER)
  mic = Microphone.run_mic_levels_thread(print, Config)
  with closing(discovery):
    with closing(mic):
      raw_input('Press return to exit\n')

  discovery.join()

@@ -201,21 +201,20 @@
 rom 
-sound
+util
  import 
 Micr
@@ -209,26 +209,24 @@
  import 
-Microphone
+Platform
 %0A%0Aif __n
@@ -412,16 +412,42 @@
 ROUTER)%0A
+  if Platform.IS_LINUX:%0A  
   mic = 
@@ -494,16 +494,17 @@
 Config)%0A
+%0A
   with c
@@ -526,33 +526,8 @@
 y):%0A
-    with closing(mic):%0A  
     
@@ -563,16 +563,57 @@
 it%5Cn')%0A%0A
+  if Platform.IS_LINUX:%0A    mic.close()%0A%0A
   discov

Make Echomesh work on Mac