Пример #1
0
 def test_success(self):
     ''' Test for the successful case '''
     connection = sqlite3.connect(':memory:')
     connection.execute(_table_utils.make_create_table(
                        'Person', self.template))
     _table_utils.rename_column(connection, 'Person', self.template,
                                self.mapping)
     cursor = connection.cursor()
     cursor.execute('SELECT sql FROM sqlite_master WHERE name="Person";')
     query = cursor.next()[0]
     self.assertEqual(query, 'CREATE TABLE Person (id INTEGER PRIMARY '
                             'KEY, age INTEGER, surname TEXT, name TEXT)')
Пример #2
0
 def test_success(self):
     ''' Test for the successful case '''
     connection = sqlite3.connect(':memory:')
     connection.execute(
         _table_utils.make_create_table('Person', self.template))
     _table_utils.rename_column(connection, 'Person', self.template,
                                self.mapping)
     cursor = connection.cursor()
     cursor.execute('SELECT sql FROM sqlite_master WHERE name="Person";')
     query = cursor.next()[0]
     self.assertEqual(
         query, 'CREATE TABLE Person (id INTEGER PRIMARY '
         'KEY, age INTEGER, surname TEXT, name TEXT)')
Пример #3
0
    "privacy_can_collect": 0,
    "privacy_can_publish": 0,

    "connect_time": 0.0,
    "download_speed": 0.0,
    "upload_speed": 0.0,
    "latency": 0.0,

    "platform": "",
    "neubot_version": "",

    # Added Neubot 0.4.12
    "test_version": 1,
}

CREATE_TABLE = _table_utils.make_create_table("speedtest", TEMPLATE)
INSERT_INTO = _table_utils.make_insert_into("speedtest", TEMPLATE)

def create(connection, commit=True):
    ''' Create a new speedtest table '''
    connection.execute(CREATE_TABLE)
    if commit:
        connection.commit()

def insert(connection, dictobj, commit=True, override_timestamp=True):
    ''' Insert a result dictionary into speedtest table '''
    _table_utils.do_insert_into(connection, INSERT_INTO, dictobj, TEMPLATE,
                                commit, override_timestamp)

def listify(connection, since=-1, until=-1):
    ''' Converts the content of speedtest table into a list '''
Пример #4
0
    return {
            'timestamp': result['server']['goodput']['ticks'],
            'uuid': result['client']['uuid'],
            'internal_address': result['client']['myname'],
            'real_address': result['server']['peername'],
            'remote_address': result['server']['myname'],
            'neubot_version': result['client']['version'],
            'platform': result['client']['platform'],
            'connect_time': result['client']['connect_time'],
            'latency': result['client']['alrtt_avg'],
            'download_speed': (result['client']['goodput']['bytesdiff'] /
                               result['client']['goodput']['timediff']),
            'json_data': json.dumps(result),
           }

CREATE_TABLE = _table_utils.make_create_table('raw', TEMPLATE)
INSERT_INTO = _table_utils.make_insert_into('raw', TEMPLATE)

def create(connection, commit=True):
    ''' Create the RAW table '''
    connection.execute(CREATE_TABLE)
    if commit:
        connection.commit()

def insert(connection, dictobj, commit=True, override_timestamp=True):
    ''' Insert a result into RAW table '''
    dictobj = __json_to_mapped_row(dictobj)
    _table_utils.do_insert_into(connection, INSERT_INTO, dictobj, TEMPLATE,
                                commit, override_timestamp)

def listify(connection, since=-1, until=-1):
Пример #5
0
    "real_address": "",
    "remote_address": "",

    "privacy_informed": 0,
    "privacy_can_collect": 0,
    "privacy_can_publish": 0,

    "connect_time": 0.0,
    "download_speed": 0.0,
    "upload_speed": 0.0,

    "neubot_version": "",
    "platform": "",
}

CREATE_TABLE = _table_utils.make_create_table("bittorrent", TEMPLATE)
INSERT_INTO = _table_utils.make_insert_into("bittorrent", TEMPLATE)

def create(connection, commit=True):
    ''' Create the bittorrent table '''
    connection.execute(CREATE_TABLE)
    if commit:
        connection.commit()

def insert(connection, dictobj, commit=True, override_timestamp=True):
    ''' Insert a result into bittorrent table '''
    _table_utils.do_insert_into(connection, INSERT_INTO, dictobj, TEMPLATE,
                                commit, override_timestamp)

def listify(connection, since=-1, until=-1):
    ''' Converts to list the content of bittorrent table '''
Пример #6
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Neubot.  If not, see <http://www.gnu.org/licenses/>.
#

from neubot.database import _table_utils
from neubot import utils

TEMPLATE = {
    "timestamp": 0,
    "severity": "",
    "message": "",
}

CREATE_TABLE = _table_utils.make_create_table("log", TEMPLATE)
INSERT_INTO = _table_utils.make_insert_into("log", TEMPLATE)

def create(connection, commit=True):
    connection.execute(CREATE_TABLE)
    if commit:
        connection.commit()

def insert(connection, dictobj, commit=True):
    connection.execute(INSERT_INTO, dictobj)
    if commit:
        connection.commit()

def walk(connection, func, since=-1, until=-1):
    cursor = connection.cursor()
    SELECT = _table_utils.make_select("log", TEMPLATE,