[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [gettor/master] Rewrite scripts



commit df7da7b8a9137276dd646fb627b26c4e8390bd52
Author: hiro <hiro@xxxxxxxxxxxxxx>
Date:   Fri Mar 8 10:55:23 2019 +0100

    Rewrite scripts
---
 scripts/add_lins_to_db | 58 ++++++++++++++++++++++++++++++++++++++++++--------
 share/locale/en.json   |  4 ++--
 2 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/scripts/add_lins_to_db b/scripts/add_lins_to_db
old mode 100644
new mode 100755
index 5da92b3..351ef56
--- a/scripts/add_lins_to_db
+++ b/scripts/add_lins_to_db
@@ -11,22 +11,58 @@
 import os
 import sys
 import sqlite3
-import urllib import request
+import argparse
+from urllib import request
+
+def print_header():
+    header = """
+                             __     __
+                            /\ \__ /\ \__
+                  __      __\ \ ,_\\\ \ ,_\   ____   _  __
+                /'_ `\  /'__`\ \ \/ \ \ \/  / __ `\/\`'__\
+               /\ \L\ \/\  __/\ \ \_ \ \ \ /\ \L\  \ \ \/
+               \ \____ \ \____\\\__\ \ \ \__\ \_____/\ \_\
+                \/___L\ \/____/ \/__/  \/__/\/___/  \/_/
+                 /\_____/
+                 \_/___/
+
+    """
+    print("")
+    print("@"*100)
+    print("@"*100)
+    print(header)
+    print("@"*100)
+    print("")
+
+def print_footer():
+    print("")
+    print("@"*100)
+    print("@"*100)
+    print("")
 
 def main():
+  parser = argparse.ArgumentParser(
+    description="Tool to create the gettor SQLite database."
+  )
+
+  parser.add_argument(
+    "-f", "--filename", default="gettor.db", metavar="gettor.db",
+    help="Database filename."
+  )
+
   args = parser.parse_args()
   abs_filename = os.path.abspath(args.filename)
 
   webFile = request.urlopen("https://lektor-staging.torproject.org/tpo/staging/projects/torbrowser/RecommendedTBBVersions/";)
-  versions = webfile.read().decode('utf-8')
+  versions = webFile.read().decode('utf-8')
   version = versions.split("&#34;")[1]
 
   gitlab = "https://gitlab.com/hiromipaw/torbrowser/raw/releases/";
 
   prefixes = {
-    "osx": "TorBrowser-",
-    "windows": "torbrowser-install-",
-    "linux": "tor-browser-linux64-"
+    "osx": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/TorBrowser-";,
+    "windows": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/torbrowser-install-";,
+    "linux": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/tor-browser-linux64-";
   }
 
   versions = {"windows": version, 'linux': version, 'osx': version}
@@ -43,9 +79,7 @@ def main():
 
   if not abs_filename:
       print("Missing database filename.")
-  elif args.new and not args.overwrite and os.path.isfile(abs_filename):
-      print("Database file already exists.")
-  elif args.new:
+  else:
       conn = sqlite3.connect(abs_filename)
       with conn:
           c = conn.cursor()
@@ -60,5 +94,11 @@ def main():
           for k in keys:
               c.execute(
                   "INSERT INTO links(link, platform, arch, version, provider, status)"
-                  "VALUES ('%s', '%s' '64', '%s', 'gitlab', 'ACTIVE')" %(releases.get(key), k, version)
+                  "VALUES ('%s', '%s', '64', '%s', 'gitlab', 'ACTIVE')" %(releases.get(k), k, version)
               )
+
+
+if __name__ == "__main__":
+    print_header()
+    main()
+    print_footer
diff --git a/share/locale/en.json b/share/locale/en.json
index 8824c2c..83c91e6 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -1,6 +1,6 @@
 {
-  "links_body": "GetTor Test. Please be kind.",
-  "links_subject": "GetTor Email Test",
+  "links_body": "GetTor Test. Please be kind. \n \n You can download GetTor from the following links: \n \n %s",
+  "links_subject": "GetTor Email Test.",
   "help_body": "GetTor Help Test. Please be kind.",
   "help_subject": "GetTor Help Email Test",
   "help_debug": "Log application errors to stdout",



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits