Beispiel #1
0
def image_rate(glab_path, image_path, size, color):
    if size not in test_sizes:
        return "[size error]"
    if color not in test_colors:
        return "[color error]"

    Timings.slow()
    mainw = connect_glab()
    if not mainw:
        mainw = start_glab(glab_path)
    else:
        if settings['run'] > RUN_LIMIT:
            close_glab(mainw)
            mainw = start_glab(glab_path)
            settings['run'] = 0

    if not mainw:
        return '[run error]'

    settings['run'] = settings['run'] + 1

    start_time = time.time()
    rate = get_color_rate(mainw, image_path, size, color)
    end_time = time.time()
    image = ImageDesc(image_path, size, color, rate)
    print(image.to_json() + ": " + str(end_time - start_time) + " sec")
    return image.to_json()
        def setUp(self):
            """Set some data and ensure the application is in the state we want"""
            Timings.slow()

            self.app = Application(backend="uia")
            self.app = self.app.start(wpf_app_1)

            self.dlg = self.app.WPFSampleApplication
            self.handle = self.dlg.handle
            self.ctrl = UIAElementInfo(self.handle)
        def setUp(self):
            """Set some data and ensure the application is in the state we want"""
            Timings.slow()

            self.app = Application(backend="uia")
            self.app = self.app.start(wpf_app_1)

            self.dlg = self.app.WPFSampleApplication
            self.handle = self.dlg.handle
            self.ctrl = UIAElementInfo(self.handle)
Beispiel #4
0
def folder_rate(glab_path, image_folder):
    Timings.slow()
    imgs = []
    valid_images = ['.jpg', '.gif', '.png', '.tga']
    for f in os.listdir(image_folder):
        ext = os.path.splitext(f)[1]
        if ext.lower() not in valid_images:
            continue
        imgs.append(f)

    mainw = connect_glab()
    if not mainw:
        mainw = start_glab(glab_path)
    if not mainw:
        return '[run error]'

    json_report = '{\n'
    json_report = json_report + '    "images":\n'
    json_report = json_report + '    [\n'
    total_rate = [0, 0]
    for img in imgs:
        for size in test_sizes:
            for color in test_colors:
                start_time = time.time()
                rate = get_color_rate(mainw, image_folder + img, size, color)
                end_time = time.time()
                image = ImageDesc(image_folder + img, size, color, rate)
                json_report = json_report + '        ' + image.to_json(
                ) + ',\n'

                print(image.to_json() + ": " + str(end_time - start_time) +
                      " sec")

                total_rate[0] = total_rate[0] + rate[0]
                total_rate[1] = total_rate[1] + rate[1]
    json_report = json_report[:-1]
    json_report = json_report + '    ],\n'
    json_report = json_report + '    "total_rate": ' + str(total_rate) + '\n'
    json_report = json_report + '}'
    return json_report
Beispiel #5
0
from pywinauto import findwindows, timings

from pathlib import Path
import pandas as pd
from datetime import date, datetime

from easytrader import grid_strategies, pop_dialog_handler, refresh_strategies
from easytrader.config import client
from easytrader.grid_strategies import IGridStrategy
from easytrader.log import logger
from easytrader.refresh_strategies import IRefreshStrategy
from easytrader.utils.misc import file2dict
from easytrader.utils.perf import perf_clock

from pywinauto.timings import Timings
Timings.slow()

if not sys.platform.startswith("darwin"):
    import pywinauto
    import pywinauto.clipboard


class IClientTrader(abc.ABC):
    @property
    @abc.abstractmethod
    def app(self):
        """Return current app instance"""
        pass

    @property
    @abc.abstractmethod