コード例 #1
0
ファイル: regression.py プロジェクト: Justasic/cia-vc
"""

import os
import re
import xmlrpclib
import shutil

import sys
import time
from cia.tools import RandomMessage


sys.path[0] = os.path.join(sys.path[0], "..")
from cia.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
ファイル: upgrade-6-to-7.py プロジェクト: Justasic/cia-vc
# place, note the ID of the last converted message and add
# a "WHERE id > foo" clause to the stats_messages query.
#
# -- Micah Dowty
#

import os

import sys
from cia.LibCIA import XML, Database


sys.path[0] = os.path.join(sys.path[0], "..")
from cia.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
コード例 #3
0
ファイル: upgrade-3-to-4.py プロジェクト: Justasic/cia-vc
# Back up your database before running this, as failure to
# finish could cause all security data to be lost!
#
# -- Micah Dowty
#

import os
import md5

import sys
import time

sys.path[0] = os.path.join(sys.path[0], "..")
from cia.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()