Ejemplo n.º 1
0
def tools_lib():
    import tools
    # setup
    t = tools.Tools('admin')  # Tools is not defined!
    yield t
    # teardown
    del t

    return tools.Tools('admin')
Ejemplo n.º 2
0
    def _init_data(self):
        self.tools = tools.Tools()
        self.dbname = "zgzcw"
        self.cache_collection = "tmp-url"
        self.data_collection = "data"
        self.log_collection = "log"
        """
        params:
            offset_time: 从当前时间多久前开始抓数据, 今天的比赛还没有出结果
            limit_day:   抓取多少天然后停止
        """
        self.offset_time = 3600 * 24 * 3
        self.limit_day = 365 * 5

        self.list_url = "http://cp.zgzcw.com/lottery/jchtplayvsForJsp.action?lotteryId=47&type=jcmini"
        self.bjop_url = "http://fenxi.zgzcw.com/"
        self.company_list = [
            "Interwetten", "竞彩官方(胜平负)", "威廉希尔", "伟德(直布罗陀)", "立博", "澳门",
            "Bet365", "香港马会"
        ]

        self.mongodb = self.tools.get_mongodb()
        self.tools.set_cache(self.dbname, self.cache_collection)
        self.db = self.mongodb[self.dbname][self.data_collection]
        self.logdb = self.mongodb[self.dbname][self.log_collection]
        self.tools.create_idx(self.db, ["bjop.url", "bjop.id"])
        self.tools.create_idx(self.logdb, ["date"])
Ejemplo n.º 3
0
 def startProcessMonitor(self):
     dbgTools = tools.Tools(self.debug, self.variables['verbose'])
     utils.dbgPrint("\n[*] Starting process monitor...", Fore.GREEN)
     utils.dbgPrint(
         "\n[*] Press Ctrl-C once and wait a few seconds to kill the process monitor...",
         Fore.GREEN)
     dbgTools.processMonitor()
Ejemplo n.º 4
0
 def startFileMonitor(self, command):
     dbgTools = tools.Tools(self.debug, self.variables['verbose'])
     utils.dbgPrint("\n[*] Starting file monitor...", Fore.GREEN)
     utils.dbgPrint(
         "\n[*] Press Ctrl-C once and wait for another exception to get caught, then the tool will exit cleanly.",
         Fore.GREEN)
     dbgTools.fileMonitor(command)
Ejemplo n.º 5
0
 def __init__(self, config, result_dir_ts):
     self.logger = logging.getLogger('browbeat.shaker')
     self.overcloudrc = get_overcloudrc()
     self.config = config
     self.result_dir_ts = result_dir_ts
     self.tools = tools.Tools(self.config)
     self.grafana = grafana.Grafana(self.config)
     self.elastic = elastic.Elastic(self.config, self.__class__.__name__.lower())
Ejemplo n.º 6
0
 def __init__(self):
     self.tools = tools.Tools()
     self.mongodb = self.tools.get_mongodb()
     self.dbname = "bilibili"
     self.cache_name = "cache"
     self.user_name = "users"
     self.log_name = "logs"
     self.tools.cache = self.mongodb[self.dbname][self.cache_name]
     self.user_db = self.mongodb[self.dbname][self.user_name]
Ejemplo n.º 7
0
 def __init__(self, config, hosts=None):
     self.logger = logging.getLogger('browbeat.rally')
     self.config = config
     self.tools = tools.Tools(self.config)
     self.grafana = grafana.Grafana(self.config)
     self.elastic = elastic.Elastic(self.config, self.__class__.__name__.lower())
     self.error_count = 0
     self.pass_count = 0
     self.test_count = 0
     self.scenario_count = 0
Ejemplo n.º 8
0
def tools_lib():
    import tools

    # setup
    t = tools.Tools('admin')
    yield t  # using yield instead of return, means you pass the yielded object (generator) to the test method
    # when the test method finishes the process continues at the method that yielded the object

    # teardown
    del t
Ejemplo n.º 9
0
 def __init__(self, config, result_dir_ts):
     self.logger = logging.getLogger('browbeat.yoda')
     self.config = config
     self.result_dir_ts = result_dir_ts
     self.tools = tools.Tools(self.config)
     self.grafana = grafana.Grafana(self.config)
     self.elastic = elastic.Elastic(self.config, self.__class__.__name__.lower())
     self.error_count = 0
     self.pass_count = 0
     self.test_count = 0
     self.scenario_count = 0
Ejemplo n.º 10
0
 def __init__(self, config):
     self.logger = logging.getLogger('browbeat.shaker')
     self.overcloudrc = get_overcloudrc()
     self.config = config
     self.tools = tools.Tools(self.config)
     self.grafana = grafana.Grafana(self.config)
     self.elastic = elastic.Elastic(self.config,
                                    self.__class__.__name__.lower())
     self.error_count = 0
     self.pass_count = 0
     self.test_count = 0
     self.scenario_count = 0
Ejemplo n.º 11
0
    def __init__(self):
        self.tools = tools.Tools()

        self.dbname = "zgzcw"
        self.cache_collection = "tmp-url"
        self.data_collection = "data"
        self.log_collection = "log"
        """
            params:
            offset_time: 从当前时间多久前开始抓数据, 今天的比赛还没有出结果
            limit_day: 抓取多少天然后停止
        """
        self.offset_time = 3600 * 24 * 5
        self.limit_day = 365 * 5
Ejemplo n.º 12
0
def AvvioBacktester():

    exchange = sys.argv[1]  #example: poloniex
    pair = sys.argv[2]  #example: 'BTC/ETH'

    risultato = []
    tool = tools.Tools()

    strat = strategy.StrategyTrendFollowing()

    strat.ExecuteTrendFollowing(exchange, pair, tool, risultato)

    a = sorted(risultato, key=lambda a_entry: a_entry[2])

    print(a)
Ejemplo n.º 13
0
    def __init__(self):
        self.tools = tools.Tools() #工具对象
        self.mongodb = self.tools.get_mongodb()
        self.dbname = "mh"
        self.cache_name = "mh-cache"
        self.list_name = "mh-list"
        self.subs_name = "mh-subs"
        self.pics_name = "mh-pics"
        self.list_url = "http://manhua.fzdm.com"  # 风之动漫网址

        self.db = self.mongodb[self.dbname]
        self.list_collection = self.db[self.list_name]
        self.pics_collection = self.db[self.pics_name]
        self.subs_collection = self.db[self.subs_name]
        self.tools.set_cache(self.dbname, self.cache_name)

        # 程序运行时间统计
        self.start = time.time()
        self.end = 0
Ejemplo n.º 14
0
    def __init__(self, config):
        #build the mapping (asset, name) --> datanodeID
        self.mapping_dict = {}
        self.asset_dict = config['asset_dict']
        self.shortname_dict = config['shortname_dict']
        with open(config["mapping_file"], 'r') as c:
            reader = csv.reader(c, delimiter=',')
            for row in reader:
                self.mapping_dict[(row[0], row[2])] = row[1]

        #Tool layer for timestamp conversions
        self.tools = tools.Tools()
    
        #Initialize session and test
        self.s = requests.Session()
        #user = input('User: '******'username']
        self.pw = config['password']
        self.base_url = config['base_url']
        r = self.s.get(self.base_url, auth=(self.user, self.pw))
        print("Response from server: ", r.status_code)
Ejemplo n.º 15
0
def analyze(
    enabled_tools,
    test_mode,
    path_to_analyze=None,
    files_list=None,
    results_dir=".",
    tools_path="./CC++_Tools",
):
    if path_to_analyze is None and files_list is None:
        log_err(
            "\teither a path to analyze, or "
            "a list of files must be passed to function 'analyze'.",
            ExitCode.PROGRAMMING_ERROR,
        )

    if not os.path.isdir(results_dir):
        log_err(
            "\tthe results path ( {} ) does not exists.",
            ExitCode.TARGET_DIR_NOT_FOUND,
            results_dir,
        )

    t = tools.Tools(tools_path)

    if enabled_tools:
        tool = t.get_tools()
        correct_tools = check_tools_correctness(tool, enabled_tools)
        t.set_enabled_tools(correct_tools)

    t.check_tools_existence()

    # Checking for analyzable files.
    if path_to_analyze is not None and not tools.list_of_files(
            path_to_analyze, tools.ACCEPTED_EXTENSIONS):
        log_err(
            "\tthe given path does not contain any of the supported files.\n"
            "\tBe sure to pass the right folder to analyze.",
            ExitCode.NO_SUPPORTED_FILES_FOUND,
        )

    output_dir = results_dir
    if test_mode:
        output_name = os.path.basename(os.path.normpath(results_dir))
    else:
        # The output folder in which all the output data will be placed
        output_name = datetime.datetime.now().strftime(
            "results_%Y.%m.%d_%H.%M.%S")

        output_dir = os.path.join(output_dir, output_name)

        # In case of an already existing path, add trailing '_'
        while os.path.exists(output_dir):
            output_dir = output_dir + "_"
        os.mkdir(output_dir)

    log_debug("\tOK, in output dir: {}", output_dir)
    if path_to_analyze is not None:
        log_debug("\tpathToAnalyze: {}", path_to_analyze)
    else:
        log_debug("\tfiles_list: {}", files_list)
    log_debug("")

    # RUNNING THE EXTERNAL TOOLS
    t.run_tools(path_to_analyze, files_list, output_dir)

    log_debug(
        "\tRAW RESULTS:\n"
        "TOKEI:\n {} "
        "\n\nRUST-CODE-ANALYSIS:\n {}"
        "\n\nCCCC:\n"
        "{}"
        "\n\nMI:\n {}"
        "\n\nHALSTEAD:\n {}\n",
        t.get_tool_output("tokei"),
        t.get_tool_output("rust-code-analysis"),
        t.get_tool_output("cccc"),
        t.get_tool_output("mi"),
        t.get_tool_output("halstead"),
    )

    formatted_outputs = t.get_output(test_mode)

    json_outputs = {}
    if test_mode:
        for tool in t.get_enabled_tools():
            output_final_name = (tool + "_" +
                                 pathlib.Path(path_to_analyze).name + ".json")
            path = os.path.join(output_dir, output_final_name)
            json_output = save_output(formatted_outputs[tool], path)
            json_outputs[tool] = json_output
    else:
        path = os.path.join(output_dir, output_name + ".json")
        json_output = save_output(formatted_outputs["all"], path)
        json_outputs["all"] = json_output

    print("Results have been written in folder: '" + output_name + "'")

    return json_outputs
Ejemplo n.º 16
0
import tools as t
import matplotlib as plt
plt.use('Agg')
from matplotlib import pyplot as plt

obj = t.Tools(1, 29)

half_mass_gas = obj.half_mass(0)
Ejemplo n.º 17
0
 def __init__(self):
     self.T = tools.Tools()
Ejemplo n.º 18
0
 def __init__(self):
     self.T = tools.Tools()
     self.now = int(time.time() * 1000)
     self.siteUrl = str('http://m.iptv807.com/')
Ejemplo n.º 19
0
def main():
    if len(sys.argv) != 5:
        logging.info(
            'please input args: car_path, road_path, cross_path, answerPath')
        exit(1)

    car_path = sys.argv[1]
    road_path = sys.argv[2]
    cross_path = sys.argv[3]
    answer_path = sys.argv[4]

    logging.info("car_path is %s" % (car_path))
    logging.info("road_path is %s" % (road_path))
    logging.info("cross_path is %s" % (cross_path))
    logging.info("answer_path is %s" % (answer_path))

    # to read input file
    # process
    # to write output file
    start = time.time()
    tool = tools.Tools(car_path, road_path, cross_path, answer_path)

    # 读各种数据
    road_list = tool.read_road()
    cross_list = tool.read_cross()
    carlist = tool.read_car()

    # 获取不同速度车的字典
    diff_speed_car_dict = tool.get_diff_speed_car_dict(carlist)

    # 获取速度列表
    diff_speed_list = list(diff_speed_car_dict.keys())

    # 新建一个地图类
    rcMap_test = base_class.RoadCrossMap(road_list, cross_list,
                                         diff_speed_list)

    # 获取不同速度的地图
    speed_dict = rcMap_test.init_map_of_diff_speed(diff_speed_list)

    all_answer_list = []

    # 对于每一种速度生成的地图而言
    for speed, edges in speed_dict.items():
        # 获取相同速度车字典
        same_speed_car_list = diff_speed_car_dict[speed]

        # 针对相同速度的车生成答案列表
        answerlist = tool.dijkstra(edges, same_speed_car_list, rcMap_test,
                                   diff_speed_list)

        # 增加到所有的文件列表后
        all_answer_list += answerlist

    # print(all_answer_list)

    tool.write_answer(all_answer_list)

    end = time.time()

    logging.info('Running time: %s Seconds' % (end - start))
Ejemplo n.º 20
0
Archivo: index.py Proyecto: slyzion/voz
    # obter resposta para o utilizador
    lista = []
    for i in obj:
        if i["question"] == text:
            lista.append(str(i["answer"]))

    # escolher qual a resposta a dar
    resp = ""
    if not lista:
        resp = "Não consigo responder"
    else:
        resp = str(random.choice(lista))
    
    # se resposta comecar com '&' executa comando correspondente
    if resp[0] == '&':
        tool = tools.Tools(resp)
        resp = tool.exec()
    

    # TTS da resposta
    print(resp)
    try:
        #print(1)
        filename = "voice.mp3"
        #print(2)
        tts = gTTS(resp, lang=lang, slow=False)
        #print(3)
        tts.save(filename)
        playsound(filename)
        #print(4)
        os.remove(filename)
Ejemplo n.º 21
0
        for key in self.temp_val:
            self.frame_temp_sp[key]=start_sp
            start_sp+=4

        start_sp=self.frame_size
        for key in self.formal_table:
            self.frame_temp_sp[key]=start_sp
            start_sp+=4




#当前函数作用域符号表
fun_table=Symbol_fun()

tools=tools.Tools()

def p_Program(p):
    'Progarm : DeclareStr'
    #print("Debug At Progarm...")

def p_DeclareStr(p):
    'DeclareStr : Declare TDeclare'
    #print("Debug At DeclareStr...")

def p_Declare(p):
    '''Declare : INT ID DeclareFun
               | INT ID DeclareType
               | VOID ID DeclareFun '''
    #print("Debug At Declare...")
    #print(p[2])
Ejemplo n.º 22
0
                      default=200,
                      type=int,
                      help="Basic height of ground surface")
    args.add_argument("-p",
                      "--power",
                      default=500,
                      type=int,
                      help="How much deeper bomb make crater?")
    args.add_argument("-r",
                      "--radius",
                      default=3,
                      type=int,
                      help="How wide crater be maked by bomb?")
    return args.parse_args()


if __name__ == '__main__':
    args = console()
    count = 10
    generator = generators.Bombing(args.face,
                                   start=args.surface,
                                   power=args.power,
                                   radius=args.radius,
                                   bombs=count)
    toolset = tools.Tools(args.face, [])
    print(min(generator.latest))
    layer = generator.generate(toolset)
    fname = p.abspath(p.join(p.dirname(__file__), 'test', 'bombed.layer'))
    generator.output(fname, layer)
    print("OK. See {}".format(fname))
Ejemplo n.º 23
0
 def __init__(self):
     self.T = tools.Tools()
     self.DB = db.DataBase()
Ejemplo n.º 24
0
 def __init__(self):
     self.scripts = DB.Scripts
     self.env = DB.Env
     self.session = DB.session
     self.resluts = DB.Resluts
     self.tool = tools.Tools()
Ejemplo n.º 25
0
 def __init__(self, config):
     self.shortname_dict = config['shortname_dict']
     self.tools = tools.Tools()
     self.db = SqliteDatabase('ebus_turku.db')
Ejemplo n.º 26
0
from plumbum import local
from functools import wraps
from bash import bash
import tools
import xmltool
from tee import StderrTee as errtee, StdoutTee as outtee
import xml.etree.ElementTree as xml


def get_env(var_name):
    return os.environ.get(var_name)


case_path = get_env("CASE_PATH")
system_version_id = int(get_env("SYSTEM_VERSION_ID"))
my_tool = tools.Tools()
xml_tool = xmltool.XmlTool()
work_pipe = get_env("work_pipe")
notify_pipe = get_env("notify_pipe")
# print(work_pipe)
# print(notify_pipe)


def set_check(ret):
    def my_wrap(f):
        @wraps(f)
        def log_f_as_called(*args, **kwargs):
            #cur_time = time.asctime()
            my_command = f'{f.__name__} {args} {kwargs}'
            cmd = f""":: [  BEGIN   ] :: Running '{my_command}'"""
            log(cmd)
Ejemplo n.º 27
0
 def __init__(self, master):
     self.master = master
     self.messages = {
         "add_main":
         False,
         "display_layers":
         False,
         "main_id":
         None,
         "add_part":
         False,
         "remove_main":
         False,
         "remove_part":
         False,
         "part_id":
         None,
         "draw_single":
         False,
         "draw_multiple":
         False,
         "spray":
         False,
         "which_button":
         0,
         "event":
         None,
         "draw_release":
         False,
         "play_anim":
         False,
         "stop_anim":
         False,
         "anim_playing":
         False,
         "drawing_enabled":
         True,
         "colors":
         [PEN_INIT_LEFT_COLOR, PEN_INIT_RIGHT_COLOR, PEN_INIT_LEFT_COLOR],
         "fps":
         FPS_INIT,
         "change_tool":
         False,
         "tool":
         PEN,
         "tool_cursor":
         "pencil",
         "pen_hover":
         False,
         "circle_hover":
         False,
         "tool_hover_color":
         None,
         "hover_id":
         None,
         "tool_leave":
         False,
         "draw_circle":
         False,
         "cell_size":
         CELL_INIT_SIZE,
         "cells_x":
         CELLS_X_INIT,
         "cells_y":
         CELLS_Y_INIT,
         "grid_max_x":
         GRID_MAX,
         "grid_max_y":
         GRID_MAX,
         "cursor_x":
         0,
         "cursor_y":
         0,
         "new_project":
         False,
         "create_new_project":
         False,
         "new_project_width":
         NEW_PROJECT_INIT_SIZE_X,
         "new_project_height":
         NEW_PROJECT_INIT_SIZE_Y,
         "anim_index":
         0,
         "export":
         False,
         "import_as_image":
         False,
         "import_as_layer":
         False,
         "save_project":
         False,
         "exit":
         False,
         "new_project_name":
         "New Project",
         "copy_from_image_id":
         None,
         "what_is_copied":
         None,
         "copy_from_part_id":
         None,
         "open_project":
         False,
         "show_help":
         False
     }
     self.menu_bar = am.AppMenu(master.master, self.messages)
     self.anim = an.Anim(master, self.messages, **ANIM_INIT)
     self.panel = pn.Panel(master, self.messages, **PANEL_INIT)
     self.grid = gd.Grid(master, self.panel, self.messages, **GRID_INIT)
     self.color_panel = cp.ColorPanel(master, self.messages)
     self.tools = ts.Tools(master, self.messages)
     self.width_var = StringVar(value=32)
     self.height_var = StringVar(value=30)
     self.name_var = StringVar(value="New Project")
Ejemplo n.º 28
0
 def __init__(self):
     self.T = tools.Tools()
     self.now = int(time.time() * 1000)
Ejemplo n.º 29
0
            if "download" in str(data_Dir):

                indirname = os.path.join(project_Dir, data_Dir) + "/"

            else:

                preprefix = os.path.join(project_Dir, data_Dir) + "/"

indirs = [indirname + x for x in os.listdir(indirname) if 'manifest' not in x]
indirs = sorted(indirs)
x = len(indirs)

ndirs = indirs[(j - 1) * int(x / s):j * int(x / s)]
bf = bam_fq.Bam_fq()
tl = tools.Tools()

for ndir in ndirs:
    print(ndir)
    ndir += '/'
    ubamfile = [
        ndir + x for x in os.listdir(ndir) if '.bam' in x and 'sorted' not in x
    ][0]
    prefix = preprefix + ubamfile.split('/')[-1].replace('.bam', '')

    print(ubamfile)
    print('sorting bam:')
    sbamfile = bf.bam_to_sorted_bam(ubamfile)
    sbamfile = ubamfile.replace('.bam', '.sorted.bam')
    bf.remove_file(ubamfile)
    print(sbamfile)