示例#1
0
DO NOT use this on a server with important data, as
the database is reinitialized before each trial! Don't
use it on a server running twistd for other purposes,
or an important server of any kind. This program
may eat your pets and cause your toaster to impersonate
former US senators.

usage: regression.py first-rev last-rev output.csv
"""

import sys, os, time, re, xmlrpclib, shutil
import RandomMessage
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database

Database.init({'db': None})
dbcursor = Database.pool.connect().cursor()


def readStatements(filename):
    """Return a sequence of SQL statements from the given file"""
    lines = []
    for line in open(filename).xreadlines():
        line = line.strip()
        if not line.startswith("--"):
            lines.append(line)
    fulltext = " ".join(lines)
    for statement in fulltext.split(";"):
        statement = statement.strip()
        if statement:
            yield statement
示例#2
0
#
# Upgrades a CIA database from version 3 to version 4.
#
# This script must migrate security data to the new format.
# Back up your database before running this, as failure to
# finish could cause all security data to be lost!
#
# -- Micah Dowty
#

import sys, os, time, md5
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database

Database.init()
cursor = Database.pool.connect().cursor()

# Make sure we're starting with version 3
cursor.execute("SELECT value FROM meta WHERE name = 'version'")
if cursor.fetchone()[0] != "3":
    raise Exception("This script must only be run on version 3 databases")

# Read in all security data from the old capabilities table...
# Each key gets a list of capabilities, but only one owner.
cursor.execute("SELECT * FROM capabilities")
key_owner = {}
key_ownerMail = {}
key_capabilities = {}
while True:
    row = cursor.fetchone()
    if row:
示例#3
0
#
# If the conversion takes a while and you want to pick
# up the commits you missed while the conversion was taking
# place, note the ID of the last converted message and add
# a "WHERE id > foo" clause to the stats_messages query.
#
# -- Micah Dowty
#

import sys, os

sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database, XML
from LibCIA.Stats.Target import StatsTarget

Database.init(serverCursor=True)
cursor = Database.pool.connect().cursor()

# Make sure we're starting with version 3
cursor.execute("SELECT value FROM meta WHERE name = 'version'")
if cursor.fetchall()[0][0] != "6":
    raise Exception("This script must only be run on version 6 databases")

# To avoid spending all our time reading buffer headers, cache frequently used targets
targetCache = {}
targetHits = {}
targetCacheMax = 128

rowsProcessed = 0
prevId = 0
示例#4
0
文件: regression.py 项目: Kays/cia-vc
DO NOT use this on a server with important data, as
the database is reinitialized before each trial! Don't
use it on a server running twistd for other purposes,
or an important server of any kind. This program
may eat your pets and cause your toaster to impersonate
former US senators.

usage: regression.py first-rev last-rev output.csv
"""

import sys, os, time, re, xmlrpclib, shutil
import RandomMessage
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database

Database.init({'db': None})
dbcursor = Database.pool.connect().cursor()


def readStatements(filename):
    """Return a sequence of SQL statements from the given file"""
    lines = []
    for line in open(filename).xreadlines():
        line = line.strip()
        if not line.startswith("--"):
            lines.append(line)
    fulltext = " ".join(lines)
    for statement in fulltext.split(";"):
        statement = statement.strip()
        if statement:
            yield statement
示例#5
0
# sized without stats_messages.
#
# If the conversion takes a while and you want to pick
# up the commits you missed while the conversion was taking
# place, note the ID of the last converted message and add
# a "WHERE id > foo" clause to the stats_messages query.
#
# -- Micah Dowty
#

import sys, os
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database, XML
from LibCIA.Stats.Target import StatsTarget

Database.init(serverCursor=True)
cursor = Database.pool.connect().cursor()

# Make sure we're starting with version 3
cursor.execute("SELECT value FROM meta WHERE name = 'version'")
if cursor.fetchall()[0][0] != "6":
    raise Exception("This script must only be run on version 6 databases")

# To avoid spending all our time reading buffer headers, cache frequently used targets
targetCache = {}
targetHits = {}
targetCacheMax = 128

rowsProcessed = 0
prevId = 0