# Path: neubot/database/table_bittorrent.py
# TEMPLATE = {
#     "timestamp": 0,
#     "uuid": "",
#     "internal_address": "",
#     "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": "",
# 
#     # Added Neubot 0.4.12
#     "test_version": 1,
# }
# CREATE_TABLE = _table_utils.make_create_table("bittorrent", TEMPLATE)
# INSERT_INTO = _table_utils.make_insert_into("bittorrent", TEMPLATE)
# def create(connection, commit=True):
# def insert(connection, dictobj, commit=True, override_timestamp=True):
# def listify(connection, since=-1, until=-1):
# def prune(connection, until=None, commit=True):
# 
# Path: neubot/utils_path.py
# def depth_visit(prefix, components, visit):
# def decode(string, encoding):
# def encode(string, encoding):
# def possibly_decode(string, encoding):
# def append(rootdir, path, unquote_path):
# def normalize(string):
# def join(left, right):
# def main(args):
# STRING_CLASS = six.u("").__class__


import logging
import os
    import cPickle as pickle
    import pickle
from neubot.database import DATABASE
from neubot.database import table_bittorrent
from neubot.database import table_speedtest
from neubot.database import table_raw
from neubot.backend_null import BackendNull
from neubot import utils_path

#
# The traditional Neubot backend, which saves results into
# an sqlite3 database.  Codesigned with Alessio Palmero Aprosio
# and with comments and feedback from Roberto D'Auria.
#


try:
except ImportError:




SPLIT_INTERVAL = 1024
SPLIT_NUM_FILES = 15

class BackendNeubot(BackendNull):
    ''' Neubot backend '''

    def __init__(self, proxy):
        BackendNull.__init__(self, proxy)
        self.generic = {}

    def bittorrent_store(self, message):
        ''' Saves the results of a bittorrent test '''
        DATABASE.connect()
        if DATABASE.readonly:
            logging.warning('backend_neubot: readonly database')
            return

# Path: neubot/database/table_bittorrent.py
# TEMPLATE = {
#     "timestamp": 0,
#     "uuid": "",
#     "internal_address": "",
#     "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": "",
# 
#     # Added Neubot 0.4.12
#     "test_version": 1,
# }
# CREATE_TABLE = _table_utils.make_create_table("bittorrent", TEMPLATE)
# INSERT_INTO = _table_utils.make_insert_into("bittorrent", TEMPLATE)
# def create(connection, commit=True):
# def insert(connection, dictobj, commit=True, override_timestamp=True):
# def listify(connection, since=-1, until=-1):
# def prune(connection, until=None, commit=True):
# 
# Path: neubot/utils_path.py
# def depth_visit(prefix, components, visit):
# def decode(string, encoding):
# def encode(string, encoding):
# def possibly_decode(string, encoding):
# def append(rootdir, path, unquote_path):
# def normalize(string):
# def join(left, right):
# def main(args):
# STRING_CLASS = six.u("").__class__


# Path: neubot/backend_neubot.py
import logging
import os
    import cPickle as pickle
    import pickle
from neubot.database import DATABASE
from neubot.database import table_bittorrent
from neubot.database import table_speedtest
from neubot.database import table_raw
from neubot.backend_null import BackendNull
from neubot import utils_path


#
# The traditional Neubot backend, which saves results into
# an sqlite3 database.  Codesigned with Alessio Palmero Aprosio
# and with comments and feedback from Roberto D'Auria.
#


try:
except ImportError:




SPLIT_INTERVAL = 1024
SPLIT_NUM_FILES = 15

class BackendNeubot(BackendNull):
    ''' Neubot backend '''

    def __init__(self, proxy):
        BackendNull.__init__(self, proxy)
        self.generic = {}

    def bittorrent_store(self, message):
        ''' Saves the results of a bittorrent test '''
        DATABASE.connect()
        if DATABASE.readonly:
            logging.warning('backend_neubot: readonly database')
            return

        table_bittorrent.insert(DATABASE.connection(), message)