# 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
            tmppath = fullpath + "." + str(SPLIT_NUM_FILES)
            if os.path.isfile(tmppath):
                os.unlink(tmppath)

            for index in range(SPLIT_NUM_FILES, 0, -1):
                srcpath = fullpath + "." + str(index - 1)
                if not os.path.isfile(srcpath):
                    continue
                destpath = fullpath + "." + str(index)
                os.rename(srcpath, destpath)

            tmppath = fullpath + ".0"
            filep = open(tmppath, "wb")
            pickle.dump(self.generic[test], filep)
            filep.close()
            self.generic[test] = []

        # Write
        self.generic[test].append(results)
        filep = open(fullpath, "wb")
        pickle.dump(self.generic[test], filep)
        filep.close()

    def walk_generic(self, test, index):
        """ Walk over the results of a generic test """

        filename = "%s.pickle" % test
        if index != None:
            filename += "." + str(int(index))


# 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

            tmppath = fullpath + "." + str(SPLIT_NUM_FILES)
            if os.path.isfile(tmppath):
                os.unlink(tmppath)

            for index in range(SPLIT_NUM_FILES, 0, -1):
                srcpath = fullpath + "." + str(index - 1)
                if not os.path.isfile(srcpath):
                    continue
                destpath = fullpath + "." + str(index)
                os.rename(srcpath, destpath)

            tmppath = fullpath + ".0"
            filep = open(tmppath, "wb")
            pickle.dump(self.generic[test], filep)
            filep.close()
            self.generic[test] = []

        # Write
        self.generic[test].append(results)
        filep = open(fullpath, "wb")
        pickle.dump(self.generic[test], filep)
        filep.close()

    def walk_generic(self, test, index):
        """ Walk over the results of a generic test """

        filename = "%s.pickle" % test
        if index != None:
            filename += "." + str(int(index))


        fullpath = utils_path.append(self.proxy.datadir, filename, False)