Gamaliel Espinoza 8 роки тому
батько
коміт
52d31bd359
2 змінених файлів з 24 додано та 1 видалено
  1. 1 1
      tools/fourier/__init__.py
  2. 23 0
      tools/fourier/cli.py

+ 1 - 1
tools/fourier/__init__.py

@@ -1 +1 @@
-__version__ = '1.0.0b5'
+__version__ = '1.0.0b6'

+ 23 - 0
tools/fourier/cli.py

@@ -5,6 +5,7 @@ from datetime import datetime
 import sqlite3
 import time
 import json
+import sys
 import os
 
 strptime = datetime.strptime
@@ -116,6 +117,28 @@ def main():
         print('total files indexed: {}'.format(counter))
         print('total files in existence: {}'.format(already_indexed))
         print('----------------------------------')
+
+    elif action == 'setup':
+        if not os.path.isfile(dbpath):
+            conn = sqlite3.connect(dbpath)
+            cursor = conn.cursor()
+            sentences = [
+                """create table file(
+                    hash text primary key,
+                    station text,
+                    timestamp int,
+                    filename text,
+                    uploaded int
+                )""",
+                "create index timestamp_index_desc on file (timestamp desc)",
+                "create index timestamp_index_asc on file (timestamp desc)",
+            ]
+            for query in sentences:
+                cursor.execute(query)
+            conn.commit()
+        else:
+            print('database already installed')
+            sys.exit(1)
                         
 
 if __name__ == '__main__':