ソースを参照

shift more control to conf.py

Martin 9 年 前
親
コミット
18012205e3

+ 3 - 0
voice_control/conf.py

@@ -34,3 +34,6 @@ WUNDERLIST_ACCESS_TOKEN = 'a7258e8b6596fdaffc904fc6b65d40c23afe6d2a28bfe7be1a902
 # met.no weather service
 WEATHER_LAT = 53.283148
 WEATHER_LON = -6.146421
+
+# Timezone
+TZ = 'Europe/Dublin'

+ 1 - 0
voice_control/input_sources/__init__.py

@@ -35,6 +35,7 @@ def launch_input_sources(curses_client):
     if conf.SPEECH_INPUT_ENABLED:
         import google_cloud_speech
         services.append(google_cloud_speech.GoogleCloudSpeech(_TOKEN_STREAM))
+        
     if conf.SLACK_BOT_API_KEY:
         import slack_bot
         services.append(slack_bot.SlackBot(_TOKEN_STREAM))

+ 17 - 8
voice_control/services/__init__.py

@@ -1,26 +1,18 @@
 import threading
 import traceback
 
-import email_mailgun
 import todo_wunderlist
 import input_sources
 import output
-import current_time
 import services.help
 import echo
 import duckduckgo_answers
-import music
 import conf
 
 def _get_services(cclient):
     res = {
-        'email': email_mailgun.Email(),
-        'food': todo_wunderlist.Wunderlist(True, 'food'),
-        'todo': todo_wunderlist.Wunderlist(False),
-        'time': current_time.CurrentTime('Europe/Dublin'),
         'echo': echo.Echo(),
         'duck': duckduckgo_answers.DuckDuckGo(),
-        'play': music.Music(cclient),
     }
 
     res['help'] = services.help.Help(res)
@@ -29,6 +21,23 @@ def _get_services(cclient):
         import weather
         res['weather'] = weather.Weather()
 
+    if conf.MAILGUN_API_KEY:
+        import email_mailgun
+        res['email'] = email_mailgun.Email()
+
+    if conf.WUNDERLIST_ACCESS_TOKEN:
+        import todo_wunderlist
+        res['food'] = todo_wunderlist.Wunderlist(True, 'food')
+        res['todo'] = todo_wunderlist.Wunderlist(False)
+
+    if conf.MUSIC_FOLDERS:
+        import music
+        res['play'] = music.Music(cclient)
+
+    if conf.TZ:
+        import current_time
+        res['time'] = current_time.CurrentTime(conf.TZ)
+
     return res
 
 def launch_services(cclient, interrupted):