def main(): """Main entry point.""" common.init_logging() server = TrackerServer('127.0.0.1', 8888) server.start() asyncio.get_event_loop().run_forever() asyncio.get_event_loop().close()
def main(): """Main entry point.""" common.init_logging() options = parse_args() client = ThrottlingClient('127.0.0.1', 8888, options.period) asyncio.get_event_loop().run_until_complete(client.start()) asyncio.get_event_loop().close()
def init_logging(set_level = logging.INFO, console = True, log_file_path = None): ''' we can use: httpc.init_logging(logging.ERROR) ''' common.init_logging(logger, set_level, console, log_file_path)
def main(): init_logging(__file__) logging.info("Starting pop upper") pop_upper = PopUpper() res = pop_upper.run() msg = "Result: {}".format(", ".join( ["{}: {}".format(prettify_string(k), v) for k, v in res.items()])) logging.info(msg)
opts.cmd, opts.fd, lambda wrapped_cmd: subprocess.Popen([ *(['sudo', *opts.sudo_arg, '--'] if opts.sudo else []), *wrapped_cmd, ], **popen_kwargs), set_listen_fds=opts.set_listen_fds, ) # The CLI functionality is pretty well-covered in `test_send_fds_and_run.py`. # Here is a manual smoke test that should print nothing and exit with code 1. # buck run //fs_image:send-fds-and-run -- --no-set-listen-fds -- \ # printenv LISTEN_FDS LISTEN_PID ; echo $? if __name__ == '__main__': # pragma: no cover init_logging() opts = parse_opts(sys.argv[1:]) with send_fds_and_popen(opts) as proc: # Since this program is a wrapper, it ought not keep random other # FDs open. The harm of leaving them open is that the parties using # the FDs to communicate might want to wait for a stream to get # closed ... which would never happen, causing a deadlock. for fd in opts.fd: # NB: This declines to close stderr since that would break any # future attempts to log from this code (afaik, there are not # any at present). This isn't a true FD leak, since `sudo` # would also keep FD 2 open, anyway. This wrapper never has any # business writing to 1, or reading from 0, so close those. if fd != 2: os.close(fd) sys.exit(proc.returncode)
material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2015 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common logger = common.init_logging('cloudnode') import BaseHTTPServer from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn import threading from urlparse import urlparse import json import base64 import ConfigParser import uuid import crypto import os import sys import tpm_quote
violate any copyrights that exist in this work. ''' import common import json import ConfigParser import os import subprocess import tornado_requests from M2Crypto import EVP, X509 import secure_mount import base64 import time import socket logger = common.init_logging('ca_impl_cfssl') config = ConfigParser.SafeConfigParser() config.read(common.CONFIG_FILE) cfsslproc = None def post_cfssl(url,data): numtries = 0 maxr = 10 retry=0.05 while True: try: response = tornado_requests.request("POST",url,params=None,data=data,context=None) break except Exception as e:
material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2015 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common logger = common.init_logging('registrar-common') import BaseHTTPServer from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn from urlparse import urlparse import json import threading import sys import crypto import base64 import ConfigParser import registrar_client import signal import time import hashlib
rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import sys import common import ConfigParser import registrar_client import vtpm_manager import base64 import os import errno import json logger = common.init_logging('provider_platform_init') config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) def symlink_force(target, link_name): try: os.symlink(target, link_name) except OSError, e: if e.errno == errno.EEXIST: os.remove(link_name) os.symlink(target, link_name) else: raise e def main(argv=sys.argv):
import logging import copy import random import httpc from httpc import * from httpc import HttplibHTTPC from httpc import HTTPException from common import init_logging, retry try: import json except: import simplejson as json init_logging(httpc.logger) #myuid: 1872013465 def _build_url(base_url, params): for k, v in params.items(): if isinstance(v, unicode) : params[k] = v.encode('utf-8') return base_url + '?' + urllib.urlencode(params) http_client = CurlHTTPC() headers = { 'Cookie' : 'xxxxxxxxxx' ,
Copyright 2015 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common import os import tpm_exec logger = common.init_logging('tpm_cexec') os.putenv('TPM_SERVER_PORT', '9999') os.putenv('TPM_SERVER_NAME', '9999') os.putenv('PATH', os.getenv('PATH') + ':/usr/local/bin') def check_quote(aikFile, quoteFile, extData): #print('Executing "%s"' % ("checkquote -aik %s -quote %s -nonce %s"%(aikFile, quoteFile, extData),)) if common.USE_CLIME: import _cLime retout = _cLime.checkquote('-aik', aikFile, '-quote', quoteFile, '-nonce', extData) retout = [line + '\n' for line in retout.split('\n')] # Try and be transparent to tpm_quote.py return retout
import tpm_exec import common import base64 import tempfile import traceback import tpm_random import secure_mount import tpm_nvram import json import crypto import sys from tpm_ek_ca import * import M2Crypto from M2Crypto import m2 logger = common.init_logging('tpm_initialize') global_tpmdata = None def random_password(length=20): rand = crypto.generate_random_key(length) chars = string.ascii_uppercase + string.digits + string.ascii_lowercase password = '' for i in range(length): password += chars[ord(rand[i]) % len(chars)] return password def create_ek(): # this function is intended to be idempotent (output,code,fileout) = tpm_exec.run("createek",raiseOnError=False) if code!=tpm_exec.EXIT_SUCESS:
material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2015 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common logger = common.init_logging('provider-registrar') import registrar_common import ConfigParser import sys config = ConfigParser.SafeConfigParser() config.read(common.CONFIG_FILE) def main(argv=sys.argv): registrar_common.start(config.getint('general', 'provider_registrar_port'), config.get('registrar', 'prov_db_filename')) if __name__ == "__main__":
This material is based upon work supported by the Assistant Secretary of Defense for Research and Engineering under Air Force Contract No. FA8721-05-C-0002 and/or FA8702-15-D-0001. Any opinions, findings, conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2017 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common import ConfigParser # read the config file config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) logger = common.init_logging('print_metadata') def execute(json_revocation): print json_revocation.get("metadata", {})
The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common import uuid import tornado_requests import traceback logger = common.init_logging('openstack') def get_openstack_uuid(uuid_service_ip='169.254.169.254', uuid_service_resource='/openstack/2012-08-10/meta_data.json'): logger.debug("Getting node UUID from openstack http://%s%s"%(uuid_service_ip,uuid_service_resource)) try: response = tornado_requests.request("GET", "http://" + uuid_service_ip + uuid_service_resource) if response.status_code == 200: response_body = response.json() return response_body["uuid"] logger.debug("Forcing using locally generated uuid.") return str(uuid.uuid4()) except Exception: logger.debug(traceback.format_exc()) logger.debug("Exception: Using locally generated uuid.")
def init_logging(set_level = logging.INFO, console = True, log_file_path = None): common.init_logging(httpc.logger, set_level, console, log_file_path)
import registrar_client import os import crypto import ssl import socket import ca_util import sqlite3 import revocation_notifier import keylime_sqlite import ConfigParser import tpm_obj from tpm_abstract import TPM_Utilities, Hash_Algorithms, Encrypt_Algorithms, Sign_Algorithms # setup logging logger = common.init_logging('cloudverifier_common') # setup config config = ConfigParser.SafeConfigParser() config.read(common.CONFIG_FILE) class CloudAgent_Operational_State: REGISTERED = 0 START = 1 SAVED = 2 GET_QUOTE = 3 GET_QUOTE_RETRY = 4 PROVIDE_V = 5 PROVIDE_V_RETRY = 6 FAILED = 7 TERMINATED = 8
252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import sys import os import tpm_exec import common import tempfile import crypto import fcntl import struct logger = common.init_logging('tpm_random') randomness = "" warned = False def get_tpm_rand_block(size=4096): global warned #make a temp file for the output rand = None with tempfile.NamedTemporaryFile() as randpath: try: command = "getrandom -size %d -out %s" % (size, randpath.name) (retout, code, rand) = tpm_exec.run(command, outputpath=randpath.name) except Exception as e:
rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import json import tornado_requests import traceback import crypto import base64 import common import ssl import os import logging logger = common.init_logging('registrar_client') context = None def init_client_tls(config, section): global context #make this reentrant if context is not None: return if not config.getboolean('general', "enable_tls"): logger.warning("TLS is currently disabled, AIKs may not be authentic.") return None logger.info("Setting up client TLS...")
def test_init_logging(self, mock_set_level, mock_add_handler): common.init_logging() self.assertEqual(mock_set_level.mock_calls, [unittest.mock.call(logging.DEBUG)]) self.assertIsNone(mock_add_handler.assert_called())
import tpm_initialize import argparse import crypto import traceback import time import user_data_encrypt import ca_util import os import ssl import tornado_requests import cloud_verifier_common import hashlib import ima #setup logging logger = common.init_logging('tenant') # setup config config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) class Tenant(): """Simple command processor example.""" config = None cloudverifier_ip = None cloudverifier_port = None cloudnode_ip = None
if args.random_mhc: return mhc_random.generate_scored_epitopes(mutated_regions, alleles) elif args.iedb_mhc: mhc = IEDB_MHC1(alleles=alleles) return mhc.predict(mutated_regions) elif args.netmhc_cons: predictor = ConsensusBindingPredictor(alleles) return predictor.predict(mutated_regions) else: predictor = PanBindingPredictor(alleles) return predictor.predict(mutated_regions) if __name__ == '__main__': args = parser.parse_args() init_logging(args.quiet) peptide_length = int(args.vaccine_peptide_length) # get rid of gene descriptions if they're in the dataframe if args.hla_file: alleles = [normalize_hla_allele_name(l) for l in open(args.hla_file)] elif args.hla: alleles = [normalize_hla_allele_name(l) for l in args.hla.split(",")] else: alleles = [normalize_hla_allele_name(DEFAULT_ALLELE)] # stack up the dataframes and later concatenate in case we # want both commandline strings (for weird mutations like translocations) # and files mutated_region_dfs = []
import M2Crypto from M2Crypto import m2 import os import re import secure_mount from sets import Set import string import subprocess import sys import tempfile import threading import time from tpm_abstract import * from tpm_ek_ca import * logger = common.init_logging('tpm1') # read the config file config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) class tpm1(AbstractTPM): def __init__(self, need_hw_tpm=False): AbstractTPM.__init__(self, need_hw_tpm) # shared lock to serialize access to tools self.tpmutilLock = threading.Lock() # TPM 1.2 supports fixed set of algorithms self.supported['hash'] = Set([Hash_Algorithms.SHA1])
def gencrl(_,a,b): logger = common.init_logging('ca_impl_openssl') logger.warning("CRL creation with openssl is not supported") return ""
import sys import base64 import tpm_exec import tpm_cexec import tempfile import hashlib import os import tpm_initialize import common import traceback import sets import time import ima import json logger = common.init_logging('tpm_quote') EMPTYMASK="1" EMPTY_PCR="0000000000000000000000000000000000000000" def check_mask(mask,pcr): if mask is None: return False return bool(1<<pcr & int(mask,0)) def create_deep_quote(nonce,data=None,vpcrmask=EMPTYMASK,pcrmask=EMPTYMASK): # don't deep quote when developing if common.DEVELOP_IN_ECLIPSE or common.STUB_TPM: # if not using TPM, just return a canned quote time.sleep(common.TEST_CREATE_DEEP_QUOTE_DELAY) return common.TEST_DQ
violate any copyrights that exist in this work. ''' import sys import common import ConfigParser import registrar_client import vtpm_manager import base64 import json # read the config file config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) logger = common.init_logging('platform-init') def add_vtpm(inputfile): # read in the file with open(inputfile, 'r') as f: group = json.load(f) # fetch configuration parameters provider_reg_port = config.get('general', 'provider_registrar_port') provider_reg_ip = config.get('general', 'provider_registrar_ip') # request a vtpm uuid from the manager vtpm_uuid = vtpm_manager.add_vtpm_to_group(group['uuid']) # registrar it and get back a blob
Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import sys import common import hashlib import struct import re import os import ConfigParser logger = common.init_logging('ima') # setup config config = ConfigParser.RawConfigParser() config.read(common.CONFIG_FILE) # m = ima_measure_re.match(measure_line) # measure = m.group('file_hash') # filename = m.group('file_path') START_HASH = '0000000000000000000000000000000000000000'.decode('hex') FF_HASH = 'ffffffffffffffffffffffffffffffffffffffff'.decode('hex') # struct event { # struct { # u_int32_t pcr;
material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2015 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common logger = common.init_logging('ca-util') import sys import os import crypto import base64 import argparse import ConfigParser import getpass import json import zipfile import cStringIO import socket import revocation_notifier import threading import BaseHTTPServer
''' import zmq import common import ConfigParser import json import crypto import threading import functools import time import os import sys from multiprocessing import Process import signal logger = common.init_logging('revocation_notifier') config = ConfigParser.SafeConfigParser() config.read(common.CONFIG_FILE) broker_proc = None def start_broker(): def worker(): context = zmq.Context(1) frontend = context.socket(zmq.SUB) frontend.bind("ipc:///tmp/keylime.verifier.ipc") frontend.setsockopt(zmq.SUBSCRIBE, "")
import numpy as np import tensorflow as tf from tensorflow.python.ops import rnn, rnn_cell import pickle from sklearn.cross_validation import train_test_split from sklearn.metrics import confusion_matrix, roc_auc_score, precision_score, recall_score import logging import common logger = common.init_logging('rnn_notMNIST.log') logger.info('Loading pickled vecs...') data = pickle.load(open('notMNIST_data.pickle', 'rb')) Xdata = np.array([img[1] for img in data]) ydata = np.array([img[2] for img in data]) logger.info('Train Test Split...') train_x, test_x, train_y, test_y = train_test_split(Xdata, ydata) train_x = np.array(train_x[:500]) train_y = np.array(train_y[:500]) test_x = np.array(test_x[:500]) test_y = np.array(test_y[:500]) ytrain_sing = np.argmax(train_y, 1) ytest_sing = np.argmax(test_y, 1) hm_epochs = 5 n_classes = 10 batch_size = 128
import time import struct from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR from common import init_logging, read_bytes, shorten, PLEN_BUF_SIZE logger = init_logging() # run server server = socket(AF_INET, SOCK_STREAM) server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) server.bind(('', 9000)) server.listen(500) logger.info('server running...') def handle(conn, addr): """ Handle each connected client. """ logger.info('connected to {0}'.format(addr)) time.sleep(1) # delay # read payload payload_len_buf = read_bytes(conn, PLEN_BUF_SIZE) payload_len = struct.unpack('<L', payload_len_buf)[0] payload_buf = read_bytes(conn, payload_len) # shorten url and send it back short_url = shorten(payload_buf) payload_len = struct.pack('<L', len(short_url)) conn.sendall(payload_len + short_url) conn.close()
def init_logging(): common.init_logging() print "Started logging"
import inspect import logging import os.path import subprocess import struct import sys import time import tempfile import tpm_exec from uuid import UUID sys.path.append(os.path.dirname(__file__)) from tpm_initialize import get_mod_from_pem # Logging boiler plate logger = common.init_logging('vtpmmgr') logger.setLevel(logging.INFO) # ./utils/encaik -ek ~/tmp/LLSRC-tci/scripts/llsrc-vtpm-host0_pubek.pem -ik ~/tmp/LLSRC-tci/scripts/llsrc-vtpm-host0_pubek.pem -ok key.blob -oak key.aes # cd /home/rudd/tmp/tpm4720/libtpm # VTPM Command Ordinals. Taken from Xen's stubdoms/vtpmmgr/vtpm_manager.h VTPM_ORD_GROUP_LIST = 0x02000101 VTPM_ORD_GROUP_NEW = 0x02000102 VTPM_ORD_GROUP_DEL = 0x02000103 VTPM_ORD_GROUP_ACTIVATE = 0x02000104 VTPM_ORD_GROUP_SHOW = 0x02000107 VTPM_ORD_VTPM_LIST = 0x02000201 VTPM_ORD_VTPM_NEW = 0x02000204
def main(): parser = optparse.OptionParser(usage=usage) actions = [ optparse.make_option( "-a", "--change-admin-password", action="store_true", dest="change_admin_password", default=False, help="Change password from only the admin users to the given --password password ", ), optparse.make_option( "-m", "--change-mails", action="store_true", dest="change_mails", default=False, help="Change password from all users to the given --mail mail", ), optparse.make_option( "-p", "--change-password", action="store_true", dest="change_password", default=False, help="Change password from all users to the given --password password including the admin user (-a)", ), optparse.make_option( "-s", "--run-script", action="store_true", dest="run_script", default=False, help="Run a wrapper around bin/instance run <SCRIPT> (given via --script) to remove any security in a zope2/plone site", ), ] modifiers = [ optparse.make_option("--mail", action="store", dest="mail", default="*****@*****.**", help="New mail"), optparse.make_option("--password", action="store", dest="password", default="secret", help="New password"), optparse.make_option("--script", action="store", dest="script", help="script to use"), optparse.make_option( "-c", "--config", action="store", dest="zope_conf", default=get_default_zope_conf(), help="Zope configuration file to use", ), optparse.make_option( "-u", "--user", action="store", dest="user", default=DEFAULT_USER, help="Admin user to use instead of %s." % DEFAULT_USER, ), optparse.make_option("-l", "--site-id", action="store", dest="site_id", default="plone", help="Plone Site id"), optparse.make_option( "--script-args", action="store", dest="script_args", default="", help="Arguments to give to the script if any", ), ] flags = [ optparse.make_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Be verbose") ] actions_group = optparse.OptionGroup(parser, "Actions") modifiers_group = optparse.OptionGroup(parser, "Modifiers") flags_group = optparse.OptionGroup(parser, "Flags") [ [group.add_option(o) for o in opts] for group, opts in [(actions_group, actions), (modifiers_group, modifiers), (flags_group, flags)] ] [parser.add_option_group(group) for group in [actions_group, modifiers_group, flags_group]] (options, args) = parser.parse_args() command_options = {"zope_conf": options.zope_conf, "user": options.user} common.init_logging(options.verbose) if options.change_mails: app, plone = common.get_live(options.zope_conf, options.site_id, options.user) commands.change_mails(app, plone, options.mail) if options.change_admin_password: app, plone = common.get_live(options.zope_conf, options.site_id, options.user) admin, password = options.user, options.password commands.change_admin_password(app, plone, admin, password) if options.change_password: app, plone = common.get_live(options.zope_conf, options.site_id, options.user) admin, password = options.user, options.password commands.change_admin_password(app, plone, admin, password) commands.change_password(app, plone, password) if options.run_script: commands.run_script(options.zope_conf, options.site_id, options.user, options.script, options.script_args)
import logging from bcs import BCS from bucket import Bucket # modules should import __all__ = ["bcs", "bucket", "object"] from common import NotImplementException from common import HTTPException from common import CurlHTTPC from common import PyCurlHTTPC from common import HttplibHTTPC from common import system from common import md5_for_file from common import init_logging # init_logging(logging.INFO, True, log_file_path='log/bcs.log') init_logging() logger = logging.getLogger("pybcs")
def init_logging(set_level=logging.INFO, console=True, log_file_path=None): ''' we can use: httpc.init_logging(logging.ERROR) ''' common.init_logging(logger, set_level, console, log_file_path)
material are those of the author(s) and do not necessarily reflect the views of the Assistant Secretary of Defense for Research and Engineering. Copyright 2017 Massachusetts Institute of Technology. The software/firmware is provided to you on an As-Is basis Delivered to the US Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work. ''' import common logger = common.init_logging('keylime_sqlite') import os import sqlite3 import json class KeylimeDB(): db_filename = None # in the form key, SQL type cols_db = None # these are the columns that contain json data and need marshalling json_cols_db = None # in the form key : default value exclude_db = None def __init__(self, dbname, cols_db, json_cols_db, exclude_db):
#coding: utf-8 #file : httpc_test_client.py #author : ning #date : 2012-03-07 20:47:45 import urllib, urllib2 import os, sys import re, time import logging import argparse from common import init_logging, shorten from httpc import * init_logging(logger, logging.INFO) tmp_file = 'test_pyhttpc.data' def _test_http_client(http_client_class, url, add_header, local_file): c = http_client_class() body = file(local_file).read() rst = {} rst['get'] = c.get(url, add_header) ##rst['head'] = c.head(url) bad!!!!!!!!!!! rst['put'] = c.put(url, body, add_header) rst['post'] = c.post(url, body, add_header) rst['post_multipart'] = c.post_multipart(url, local_file, 'file1', {'k':'v'}, add_header) rst['post_multipart_only_field']= c.post_multipart(url, None, None, {'k':'v'}, add_header) rst['post_multipart_only_file'] = c.post_multipart(url, local_file, 'file2', {}, add_header)