예제 #1
0
	def __init__(self):
		prevdir = os.curdir
		if not os.path.isdir("../logs/"):
			os.mkdir("../logs/")
		os.chdir("../logs/")
		logfilename = str(datetime.datetime.now()) + ".log"
		logging.basicconfig(filename=logfilename, level=logging.debug)
		logging.debug("starting ampy!")
예제 #2
0
    def __init__(self, segLib="jieba"):
	logging.basicconfig(format='%(asctime)s : %(threadName)s : %(levelname)s : %(message)s', level=logging.INFO)
	self.titles = [] # titles to be matched
	self.segTitles = [] # titles inserted stopper

	self.stopwords = set()
	self.similarity = 1.

	if segLib == "jieba":
	    self.useJieba = True
	    logging.info("[Mather]: Select jieba for word segment.")
예제 #3
0
import logging as l
 l.basicconfig(filename="mylogs.txt", level=l.ERROR)
try:
    a=10
    b=20
    c=a/b
except Exception as e:
    l.exception(e)
else:
    print("The result of division=",c)
    
    
예제 #4
0
# -*- coding: utf-8 -*-

import tensorflow as tf
import logging
from .layer import bi_lstm, lstm, linear
import shutil
import os
from tqdm import tqdm
from .util import evaluate_batch, evaluate, get_batch_dataset, get_record_parser
import numpy as np

logging.basicconfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)


class TextRNN:
    def __init__(self, config, batch=None, optimizer='Adam', graph=None):
        self.graph = graph if graph is not None else tf.Graph()
        with self.graph.as_default():
            self.config = config
            self.bilstm_hidden_size = config.bilstm_hidden_size
            self.singlelstm_hidden_size = config.singlelstm_hidden_size
            self.num_classes = config.num_classes
            self.batch_size = config.batch_size
            self.sequence_length = config.max_sequence_length
            self.vocab_size = config.vocab_size
            self.learning_rate = tf.Variable(config.learning_rate, trainable=False,
                                             name="learning_rate")  # ADD learning_rate
            self.dropout_keep_prob=config.drop_keep_pro
            self.learning_rate_decay_half_op = tf.assign(self.learning_rate, self.learning_rate * config.decay_rate_big)
            self.initializer = config.initializer
예제 #5
0
import logging
import os

import controller
from service.edge import Edgeservice

logging.basicconfig(level=loging.INFO)

local_mode = os.environ.get('APP_LOCALMODE', '')
if local_mode.lower() not in ('1', 'true'):
    import boto3

    import repository.aws.impl as aws_impl
    from service.uuid.impl import UuidImpl

    aws_access_key = os.envision.get('AWS_ACCESS_KEY')
    aws_secret_key = os.envision.get('AWS_SECRET_KEY')
    aws_region = os.envirom.get('AWS_REGION')

    aws_session = bot3.Session(
        aws_access_key_id=aws_access_key,
        aws_serect_access_key=aws_serect_key,
        region_name=aws_region,
    )

    aws_clients = {
        'greengrass':
        aws_impl.AwsGreengrassImpl(aws_session.client('greengrass')),
        'lot': aws_impl.AwsIotImpl(aws_session.client('iot')),
    }
예제 #6
0
    def t_backquote_content(self, t):
        r"[^`\\]+"
        t.lexer.string_value += t.value

    def t_backquote_end(self, t):
        r'`'
        t.value = t.lexer.string_value
        t.type = 'named_operator'
        t.lexer.string_value = none
        t.lexer.pop_state()
        return t

    def t_backquote_error(self, t):
        raise jsonpathlexererror('error on line %s, col %s while lexing backquoted operator: unexpected character: %s ' % (t.lexer.lineno, t.lexpos - t.lexer.latest_newline, t.value[0]))


    # counting lines, handling errors
    def t_newline(self, t):
        r'\n'
        t.lexer.lineno += 1
        t.lexer.latest_newline = t.lexpos

    def t_error(self, t):
        raise jsonpathlexererror('error on line %s, col %s: unexpected character: %s ' % (t.lexer.lineno, t.lexpos - t.lexer.latest_newline, t.value[0]))

if __name__ == '__main__':
    logging.basicconfig()
    lexer = jsonpathlexer(debug=true)
    for token in lexer.tokenize(sys.stdin.read()):
        print('%-20s%s' % (token.value, token.type))
예제 #7
0
파일: test.py 프로젝트: sykim122/MVNC
import gensim, logging
import sys
import os.path

logging.basicconfig(format='%(asctime)s : %(levelname)s : %(message)s',
                    level=logging.warning)

# load model from my corpus

#class MySentences(object):
#    def __init__(self, fname):
#        self.fname = fname

#    def __iter__(self):
#        for line in open(os.path.join(self.fname)):
#                yield line.split()

#sentences = MySentences('wiki.txt')
#model = gensim.models.Word2Vec(sentences, min_count=3, window=3)
#model.save('wiki_25loc_model')
#model = gensim.models.Word2Vec.load('wiki_25loc_model')
#print model

# load model from pretrained corpus

#model = gensim.models.Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
#model.save('GoogleNews_model')

#model = gensim.models.Word2Vec.load('freebase_model')

model = gensim.models.Word2Vec.load("enwiki.w2v.model")
    def main(self):
        import optparse

        parser = optparse.optionparser(usage="%prog [options]")
        parser.add_option("--nocleanup", dest="nocleanup", default=false, action="store_true",
                          help="leave moorecoinds and test.* datadir on exit or error")
        parser.add_option("--noshutdown", dest="noshutdown", default=false, action="store_true",
                          help="don't stop moorecoinds after the test execution")
        parser.add_option("--srcdir", dest="srcdir", default="../../src",
                          help="source directory containing moorecoind/moorecoin-cli (default: %default)")
        parser.add_option("--tmpdir", dest="tmpdir", default=tempfile.mkdtemp(prefix="test"),
                          help="root directory for datadirs")
        parser.add_option("--tracerpc", dest="trace_rpc", default=false, action="store_true",
                          help="print out all rpc calls as they are made")
        self.add_options(parser)
        (self.options, self.args) = parser.parse_args()

        if self.options.trace_rpc:
            import logging
            logging.basicconfig(level=logging.debug)

        os.environ['path'] = self.options.srcdir+":"+os.environ['path']

        check_json_precision()

        success = false
        try:
            if not os.path.isdir(self.options.tmpdir):
                os.makedirs(self.options.tmpdir)
            self.setup_chain()

            self.setup_network()

            self.run_test()

            success = true

        except jsonrpcexception as e:
            print("jsonrpc error: "+e.error['message'])
            traceback.print_tb(sys.exc_info()[2])
        except assertionerror as e:
            print("assertion failed: "+e.message)
            traceback.print_tb(sys.exc_info()[2])
        except exception as e:
            print("unexpected exception caught during testing: "+str(e))
            traceback.print_tb(sys.exc_info()[2])

        if not self.options.noshutdown:
            print("stopping nodes")
            stop_nodes(self.nodes)
            wait_moorecoinds()
        else:
            print("note: moorecoinds were not stopped and may still be running")

        if not self.options.nocleanup and not self.options.noshutdown:
            print("cleaning up")
            shutil.rmtree(self.options.tmpdir)

        if success:
            print("tests successful")
            sys.exit(0)
        else:
            print("failed")
            sys.exit(1)
sanity check:
  sum(1,2,3,4 balances) == 114*50

1/2/3 are shutdown, and their wallets erased.
then restore using wallet.dat backup. and
confirm 1/2/3/4 balances are same as before.

shutdown again, restore using importwallet,
and confirm again balances are correct.
"""

from test_framework.test_framework import moorecointestframework
from test_framework.util import *
from random import randint
import logging
logging.basicconfig(format='%(levelname)s:%(message)s', level=logging.info)

class walletbackuptest(moorecointestframework):

    def setup_chain(self):
        logging.info("initializing test directory "+self.options.tmpdir)
        initialize_chain_clean(self.options.tmpdir, 4)

    # this mirrors how the network was setup in the bash test
    def setup_network(self, split=false):
        # nodes 1, 2,3 are spenders, let's give them a keypool=100
        extra_args = [["-keypool=100"], ["-keypool=100"], ["-keypool=100"], []]
        self.nodes = start_nodes(4, self.options.tmpdir, extra_args)
        connect_nodes(self.nodes[0], 3)
        connect_nodes(self.nodes[1], 3)
        connect_nodes(self.nodes[2], 3)