fix sqlalchemy bug
[rainbowstream.git] / rainbowstream / draw.py
index 5063df4..148fc58 100644 (file)
@@ -14,7 +14,6 @@ from .config import *
 from .db import *
 
 db = RainbowDB()
-cur_theme = None
 
 def check_theme():
     """
@@ -22,21 +21,22 @@ def check_theme():
     """
     exists = db.theme_query()
     themes = [t.theme_name for t in exists]
-    if cur_theme != themes[0]:
-        cur_theme = themes[0]
+    if c['theme'] != themes[0]:
+        c['theme'] = themes[0]
         # Determine path
-        if cur_theme == 'user':
+        if c['theme'] == 'custom':
             config = os.environ.get(
                 'HOME',
                 os.environ.get(
                 'USERPROFILE',
                 '')) + os.sep + '.rainbow_config.json'
         else:
-            config = 'rainbowstream/colorset/'+cur_theme+'.json'
+            config = 'rainbowstream/colorset/'+c['theme']+'.json'
         # Load new config
         data = load_config(config)
-        for d in data:
-            c[d] = data[d]
+        if data:
+            for d in data:
+                c[d] = data[d]
 
 
 def color_func(func_name):
@@ -304,6 +304,6 @@ def print_trends(trends):
     for topic in trends[:c['TREND_MAX']]:
         name = topic['name']
         url = topic['url']
-        line = cycle_color(name) + ': ' + color_func(TREND['url'])(url)
+        line = cycle_color(name) + ': ' + color_func(c['TREND']['url'])(url)
         printNicely(line)
     printNicely('')