[tor-commits] [ooni-probe/master] Clean up unused code

art at torproject.org art at torproject.org
Sat Nov 10 14:02:09 UTC 2012


commit 3b394e4d82c5b13cb537fcf7bc84bb75b773eb1c
Author: Arturo Filastò <art at fuffa.org>
Date:   Sat Nov 10 15:00:54 2012 +0100

    Clean up unused code
    * Fix imports in oonib
---
 oonib/__init__.py      |    2 +-
 oonib/config.py        |    1 +
 oonib/models.py        |    2 +-
 oonib/report/api.py    |    2 +-
 oonib/report/models.py |  122 ------------------------------------------------
 5 files changed, 4 insertions(+), 125 deletions(-)

diff --git a/oonib/__init__.py b/oonib/__init__.py
index f672728..1a853dd 100644
--- a/oonib/__init__.py
+++ b/oonib/__init__.py
@@ -17,6 +17,6 @@ from storm.databases.sqlite import SQLite
 from oonib import config
 
 database = SQLite(URI(config.main.database_uri))
-db_threadpool = ThreadPool(0, config.main.db_thread_pool_size)
+db_threadpool = ThreadPool(0, config.main.db_threadpool_size)
 db_threadpool.start()
 transactor = Transactor(db_threadpool)
diff --git a/oonib/config.py b/oonib/config.py
index 70cb457..0156b69 100644
--- a/oonib/config.py
+++ b/oonib/config.py
@@ -16,6 +16,7 @@ main.dns_tcp_port = 8002
 main.daphn3_port = 9666
 main.server_version = "Apache"
 main.database_uri = "sqlite:"+get_root_path()+"oonib_test_db.db"
+main.db_threadpool_size = 10
 #main.ssl_private_key = /path/to/data/private.key
 #main.ssl_certificate = /path/to/data/certificate.crt
 #main.ssl_port = 8433
diff --git a/oonib/models.py b/oonib/models.py
index ddf79a3..e7d2f69 100644
--- a/oonib/models.py
+++ b/oonib/models.py
@@ -2,7 +2,7 @@ __all__ = ['Report', 'TestHelperTMP']
 from storm.twisted.transact import transact
 from storm.locals import *
 
-from oonib.report.db import getStore, transactor
+from oonib import transactor
 
 def generateReportID():
     size = 100
diff --git a/oonib/report/api.py b/oonib/report/api.py
index 996a6e4..1a4746a 100644
--- a/oonib/report/api.py
+++ b/oonib/report/api.py
@@ -14,7 +14,7 @@ from twisted.internet import reactor, defer
 
 from cyclone import web
 
-from oonib.report import models
+from oonib import models
 
 backend_version = '0.0.1'
 
diff --git a/oonib/report/models.py b/oonib/report/models.py
deleted file mode 100644
index ddf79a3..0000000
--- a/oonib/report/models.py
+++ /dev/null
@@ -1,122 +0,0 @@
-__all__ = ['Report', 'TestHelperTMP']
-from storm.twisted.transact import transact
-from storm.locals import *
-
-from oonib.report.db import getStore, transactor
-
-def generateReportID():
-    size = 100
-    report_id = ''.join(random.choice(string.ascii_letters) for x in range(size))
-    return report_id
-
-class OModel(object):
-
-    transactor = transactor
-
-    def getStore(self):
-        return Store(database)
-
-    @transact
-    def create(self, query):
-        store = Store(database)
-        store.execute(query)
-        store.commit()
-
-    @transact
-    def save(self):
-        store = getStore()
-        store.add(self)
-        store.commit()
-
-class Report(OModel):
-    """
-    This represents an OONI Report as stored in the database.
-
-    report_id: this is generated by the backend and is used by the client to
-               reference a previous report and append to it. It should be
-               treated as a shared secret between the probe and backend.
-
-    software_name: this indicates the name of the software performing the test
-                   (this will default to ooniprobe)
-
-    software_version: this is the version number of the software running the
-                      test.
-
-    test_name: the name of the test on which the report is being created.
-
-    test_version: indicates the version of the test
-
-    progress: what is the current progress of the report. This allows clients
-              to report event partial reports up to a certain percentage of
-              progress. Once the report is complete progress will be 100.
-
-    content: what is the content of the report. If the current progress is less
-             than 100 we should append to the YAML data structure that is
-             currently stored in such field.
-    """
-    __storm_table__ = 'reports'
-
-    createQuery = "CREATE TABLE " + __storm_table__ +\
-                  "(id INTEGER PRIMARY KEY, report_id VARCHAR, software_name VARCHAR,"\
-                  "software_version VARCHAR, test_name VARCHAR, test_version VARCHAR,"\
-                  "progress VARCHAR, content VARCHAR)"
-
-
-    id = Int(primary=True)
-
-    report_id = Unicode()
-
-    software_name = Unicode()
-    software_version = Unicode()
-    test_name = Unicode()
-    test_version = Unicode()
-    progress = Int()
-
-    content = Unicode()
-
-    @transact
-    def new(report):
-        store = self.getStore()
-
-        print "Creating new report %s" % report
-
-        report_id = generateReportID()
-        new_report = models.Report()
-        new_report.report_id = unicode(report_id)
-
-        new_report.software_name = report['software_name']
-        new_report.software_version = report['software_version']
-        new_report.test_name = report['test_name']
-        new_report.test_version = report['test_version']
-        new_report.progress = report['progress']
-
-        if 'content' in report:
-            new_report.content = report['content']
-
-        print "Report: %s" % report
-
-        store.add(new_report)
-        try:
-            store.commit()
-        except:
-            store.close()
-
-        defer.returnValue({'backend_version': backend_version, 'report_id':
-                            report_id})
-
-
-class TestHelperTMP(OModel):
-    __storm_table__ = 'testhelpertmp'
-
-    createQuery = "CREATE TABLE " + __storm_table__ +\
-                  "(id INTEGER PRIMARY KEY, report_id VARCHAR, test_helper VARCHAR,"\
-                  " client_ip VARCHAR, creation_time VARCHAR)"
-
-    id = Int(primary=True)
-
-    report_id = Unicode()
-
-    test_helper = Unicode()
-    client_ip = Unicode()
-
-    creation_time = Date()



More information about the tor-commits mailing list