delete db file if exist on startup
authorOrakaro <nhatminh_179@hotmail.com>
Sat, 26 Jul 2014 12:31:16 +0000 (21:31 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sat, 26 Jul 2014 12:31:16 +0000 (21:31 +0900)
rainbowstream/config.py
rainbowstream/db.py
setup.py

index 41312952fe8419b489df5f3be84cfef133e8650e..c27812e9ad9759ed97f5bb5a9611bab7c470132d 100644 (file)
@@ -42,11 +42,7 @@ def get_all_config():
     """
     Get all config
     """
-    path = os.environ.get(
-        'HOME',
-        os.environ.get(
-            'USERPROFILE',
-            '')) + os.sep + '.rainbow_config.json'
+    path = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
     data = load_config(path)
     # Hard to set from prompt
     data.pop('ONLY_LIST', None)
@@ -86,11 +82,7 @@ def set_config(key, value):
     elif value.lower() == 'false':
         value = False
     # Fix up
-    path = os.environ.get(
-        'HOME',
-        os.environ.get(
-            'USERPROFILE',
-            '')) + os.sep + '.rainbow_config.json'
+    path = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
     data = {}
     try:
         data = load_config(path)
@@ -113,11 +105,7 @@ def delete_config(key):
     """
     Delete a config key
     """
-    path = os.environ.get(
-        'HOME',
-        os.environ.get(
-            'USERPROFILE',
-            '')) + os.sep + '.rainbow_config.json'
+    path = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
     data = load_config(path)
     # Drop key
     if key in data and key in c:
@@ -139,11 +127,7 @@ def reload_config():
     """
     Reload config
     """
-    rainbow_config = os.environ.get(
-        'HOME',
-        os.environ.get(
-            'USERPROFILE',
-            '')) + os.sep + '.rainbow_config.json'
+    rainbow_config = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
     try:
         data = load_config(rainbow_config)
         for d in data:
@@ -166,11 +150,7 @@ def init_config():
     except:
         pass
     # Load user's config
-    rainbow_config = os.environ.get(
-        'HOME',
-        os.environ.get(
-            'USERPROFILE',
-            '')) + os.sep + '.rainbow_config.json'
+    rainbow_config = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
     try:
         data = load_config(rainbow_config)
         for d in data:
index 1714005d77a4154d9052144b595e5b978a855640..8f4ce40491a6c82c7b294cbe6b73116f7a86e2e6 100644 (file)
@@ -12,8 +12,9 @@ class RainbowDB():
         """
         Init DB
         """
-        if not os.path.isfile('rainbow.db'):
-            init_db()
+        if os.path.isfile('rainbow.db'):
+            os.system('rm -rf rainbow.db')
+        init_db()
         self.engine = create_engine('sqlite:///rainbow.db', echo=False)
 
 
index 73573d011dee18400f7771e85b5b1c68c7326f78..dc7fa6fe033395c85216b2f889da8aa0b0c5341f 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,8 @@
 from setuptools import setup, find_packages
-import os, sys
+import os, os.path, sys
 
 # Bumped version
-version = '0.4.9'
+version = '0.4.10'
 
 # Require
 install_requires = [
@@ -19,11 +19,7 @@ if sys.version[0] == "2":
     install_requires += ["pysqlite"]
 
 # Copy default config if not exists
-default = os.environ.get(
-    'HOME',
-    os.environ.get(
-        'USERPROFILE',
-        '')) + os.sep + '.rainbow_config.json'
+default = os.path.expanduser("~") + os.sep + '.rainbow_config.json'
 if not os.path.isfile(default):
     cmd = 'cp rainbowstream/colorset/config ' + default
     os.system(cmd)