def __init__(self, ID, IP, servers_list): super(Server, self).__init__() self.id = int(ID) self.ip = str(IP) self.servers_list = servers_list self.myLogger = mylogger.Logger(self.ip) self.myByzantine = Byzantine_Behavior() self.myVoteManager = VoteManager(self.servers_list) self.behavior = "Unknown" self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) # list all REST URIs # if you add new URIs to the server, you need to add them here # API for Clients self.route('/', callback=self.index) self.post('/vote/attack', callback=self.post_vote_attack) self.post('/vote/retreat', callback=self.post_vote_retreat) self.post('/vote/byzantine', callback=self.post_vote_byzantine) # API for Scripts self.get('/serverlist', callback=self.get_serverlist) # API for Server Internals self.post('/propagate', callback=self.post_propagate) # we give access to the templates elements self.get('/lab4-html/<filename:path>', callback=self.get_template) # You can have variables in the URI, here's an example # self.post('/board/<element_id:int>/', callback=self.post_board) where post_board takes an argument (integer) called element_id thread = Thread(target=self.observer) thread.start()
def __init__(self, l=None, dbfile=None): if l is None: self.logger = mylogger.Logger().myLogger() else: self.logger = l if dbfile is None: conf = common.read_conf() self.dbfile = conf['dbfile'] else: self.dbfile = dbfile
def main(args): main_start_time = time.time() random.seed(args.seed) torch.manual_seed(args.seed) device = torch.device('cuda' if args.cuda else 'cpu') model_path = args.model if args.model else make_model_path(args) logger = mylogger.Logger(model_path + '.log', args.train) logger.log(' '.join(sys.argv) + '\n') if args.batch_size_valid > 0: batch_size_valid = args.batch_size_valid else: batch_size_valid = 1 if args.batch_method == 'continuous' else 60 dat = data.Data(args.data, args.batch_size, args.batch_method, device, sort=args.sort, logger=logger, is_conditional=args.cond, batch_size_valid=batch_size_valid) s2s = model.Seq2Seq(len(dat.i2w), args.dim, args.nlayers, args.dropout, is_conditional=args.cond, bidirectional_encoder=args.bidir, use_bridge=args.bridge, use_attention=args.attn, logger=logger).to(device) ctrl = control.Control(s2s, args.lr, args.bptt, args.interval, model_path=model_path, logger=logger) if args.train: ctrl.train(dat, args.epochs, args.shuffle) logger.log( time.strftime("%H:%M:%S", time.gmtime(time.time() - main_start_time))) else: ctrl.load_s2s() train_loss, train_sqxent = ctrl.evaluate(dat.train) valid_loss, valid_sqxent = ctrl.evaluate(dat.valid) print('train ppl: %.2f train sqxent: %.2f' % (math.exp(train_loss), train_sqxent)) print('valid ppl: %.2f valid sqxent: %.2f' % (math.exp(valid_loss), valid_sqxent))
def __init__(self, ID, IP, servers_list): super(Server, self).__init__() self.id = int(ID) self.ip = str(IP) self.servers_list = servers_list self.serverIndex = self.servers_list.index(self.ip) self.vectorClock = VectorClock(self.serverIndex, len(self.servers_list)) self.myLogger = mylogger.Logger(self.ip) self.blackboard = distributedboard.Blackboard(self.vectorClock, self.myLogger) self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) # list all REST URIs # if you add new URIs to the server, you need to add them here # API for Clients self.route('/', callback=self.index) self.get('/board', callback=self.get_board) self.post('/', callback=self.post_index) self.post('/board', callback=self.post_board) self.post('/board/<number>/', callback=self.post_board_ID) # API for Scripts self.get('/serverlist', callback=self.get_serverlist) self.get('/board/alldata',callback=self.get_board_data) # API for Server Internals self.post('/propagate', callback=self.post_propagate) self.post('/update_ctrl', callback=self.post_update_ctrl) # we give access to the templates elements self.get('/templates/<filename:path>', callback=self.get_template) # You can have variables in the URI, here's an example # self.post('/board/<element_id:int>/', callback=self.post_board) where post_board takes an argument (integer) called element_id # Lab3 Option Task!!!! self.get('/operation_log_size', callback=self.get_operation_log_size) thread = Thread(target=self.checkUpdatesOfOtherServers) thread.start()
def __init__(self, logger=None): if logger is None: self.logger = mylogger.Logger().myLogger() else: self.logger = logger
import mylogger test_logger = mylogger.Logger() print(test_logger) test_logger.error("This is an error") test_logger.error("This is another error") test_logger.warning("This is a warning") maybe_another_logger = mylogger.Logger() print(maybe_another_logger) test_logger = mylogger.Logger() test_logger = mylogger.Logger() print(test_logger)
config = configparser.ConfigParser() config.read('config.ini') pwd = configparser.ConfigParser() pwd.read('user.pwd') symbols = config['market']['symbols'] symbols = symbols.split(',') print('Tracking symbols:', symbols) iqthread = start_iqconnect(pwd['iqfeed']['productID'], pwd['iqfeed']['iq_user'], pwd['iqfeed']['iq_pass']) mylog = mylogger.Logger(pwd['telegram']['botToken'], pwd['telegram']['chatID'], config['system']['log_path']) db_queue = queue.Queue() iq_queue = queue.Queue() db = postgres.DatabaseConnection(db_queue, mylog) db.connect() listen = listener.Listener(iq_queue, db_queue, mylog, symbols) listen.start_listening() conn = connection.BarsConnection(iq_queue, mylog) conn.connect() sleep(2)
def crawler(start_date, end_date, symbol_txt, unix_period): s = mylogger.Logger() logger = s.myLogger(conf['logger']) logger.info('crawler.') Crawler().download(start_date, end_date, symbol_txt, unix_period)
def __init__(self, logger=None): if logger is None: self.logger = mylogger.Logger().myLogger() else: self.logger = logger self.dumper = BacktestDumper()
from dateutil.relativedelta import relativedelta import numpy as np import threading import numpy from argparse import ArgumentParser import common import mylogger from butler import bollingerband from www import tick from www import symbol from market import Market from mydb import MyDB from assets import Assets from backtest_dumper import BacktestDumper s = mylogger.Logger() logger = s.myLogger() def get_option(): argparser = ArgumentParser() argparser.add_argument('--symbol', type=str, help='Absolute/relative path to input file') argparser.add_argument('--start_date', type=str, help='Date of backtest start') argparser.add_argument('--end_date', type=str, help='Date of backtest end') argparser.add_argument('--period', type=str, help='for bitmex/minkabu_fx') argparser.add_argument('--brute_force', action='store_true',