コード例 #1
0
def get_engine(engine_type=EngineType, port=None):
    """
        singleton instance , get the instance of GameEngine 。(only support unity or ue4 for now)
    :param engine_type:
    :param port: sdk forward port . if not set, the port will be set by Environment Variables
    :return: GameEngine instance
    """
    if get_engine.instance:
        return get_engine.instance
    local_port = None
    if env:
        result = _platform_forward(int(unity_sdk_port))
        local_port = result
    else:
        local_engine_port = os.environ.get("LOCAL_ENGINE_PORT",
                                           "53001")  # 本地模式时与engine forward的端口号
        res = forward(local_engine_port, unity_sdk_port)
        logger.info(res)
        local_port = int(local_engine_port)
    logger.info("host: {0} port: {1}".format(hostip, local_port))

    ui_device = uiauto.get_uiautomator()
    if engine_type == "unity":
        get_engine.instance = UnityEngine(hostip, local_port, ui_device)
        print("In get_engine, hostip is:" + hostip + " local_port is : " +
              str(local_port))
    elif engine_type == "ue4":
        get_engine.instance = UnRealEngine(hostip, local_port, ui_device)
    else:
        raise ValueError("No {0} engine type".format(engine_type))
    return get_engine.instance
コード例 #2
0
def get_device():
    """
        单例,多次获取的是同一个实例对象
        根据运行在本地还是wetest云端,创建不同的实现。在本地运行创建NativeDevice实现类,在wetest平台创建CloudDevice。

        创建Device类的时候,首先会启动UIAutomator服务(https://github.com/xiaocong/uiautomator)
    :return: Device实例
    """
    if get_device.instance:
        return get_device.instance

    import wpyscripts.uiautomator.uiautomator_manager as uiauto
    ui_device = uiauto.get_uiautomator()
    pkgname = os.environ.get("PKGNAME")
    launch_activity = os.environ.get("LAUNCHACTIVITY", None)
    serial = os.environ.get("ANDROID_SERIAL")
    if not serial:
        serial = os.environ.get("ADB_SERIAL")

    if env:
        get_device.instance = CloudDevice(serial, pkgname, launch_activity,
                                          ui_device)
    else:
        get_device.instance = NativeDevice(serial, ui_device)
    return get_device.instance
コード例 #3
0
ファイル: main.py プロジェクト: bbbuuuwww/wushangbin
def deal_window(package):
    while 1:
        cmd_ = subprocess.Popen(
            "adb shell dumpsys window windows | findstr mCurrentFocus",
            stdout=subprocess.PIPE,
            shell=True).stdout.read().decode()
        if package in cmd_:
            break
        device = ui.get_uiautomator()
        #print(device.dump(), type(device.dump()))
        reg = 'resource-id=\"(com.*?(?:button|))\".*?text=\"(?:允许|点击|下载|确定|通过|下一步|是|同意|完成|暂不|稍后)\"'
        ss = re.compile(reg)
        resourceid = ss.findall(device.dump())[0]
        device(resourceId=resourceid).click()
コード例 #4
0
ファイル: manager.py プロジェクト: YaleCheung/GAutomator
def get_device():
    """
        单例,多次获取的是同一个实例对象
        根据运行在本地还是wetest云端,创建不同的实现。在本地运行创建NativeDevice实现类,在wetest平台创建CloudDevice。

        创建Device类的时候,首先会启动UIAutomator服务(https://github.com/xiaocong/uiautomator)
    :return: Device实例
    """
    if get_device.instance:
        return get_device.instance

    import wpyscripts.uiautomator.uiautomator_manager as uiauto
    ui_device = uiauto.get_uiautomator()
    pkgname = os.environ.get("PKGNAME")
    launch_activity = os.environ.get("LAUNCHACTIVITY", None)
    serial = os.environ.get("ANDROID_SERIAL")
    if not serial:
        serial=os.environ.get("ADB_SERIAL")

    if env:
        get_device.instance = CloudDevice(serial, pkgname, launch_activity, ui_device)
    else:
        get_device.instance = NativeDevice(serial, ui_device)
    return get_device.instance
コード例 #5
0
'''
Created in 2016

@author: yifengcai

@summary: handle all qq and wx package operations
'''

import time

import wpyscripts.manager as manager
import wpyscripts.uiautomator.uiautomator_manager as m

uiauto = m.get_uiautomator()

logger = manager.get_logger()
device = manager.get_device()

QQ_PACKAGE_NAME = "com.tencent.mobileqq"
WX_PACKAGE_NAME = "com.tencent.mm"


def check_qq_wx_package():
    top_package = uiauto.info["currentPackageName"]
    logger.debug("top package is %s", top_package)

    if top_package == QQ_PACKAGE_NAME or top_package == WX_PACKAGE_NAME:
        return True
    else:
        return False
コード例 #6
0
ファイル: qqwx.py プロジェクト: YaleCheung/GAutomator
Tencent is pleased to support the open source community by making GAutomator available.
Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

"""

__author__ = 'yifengcai'

import time

import wpyscripts.manager as manager
import wpyscripts.uiautomator.uiautomator_manager as m

uiauto = m.get_uiautomator()

logger = manager.get_logger()
device = manager.get_device()


QQ_PACKAGE_NAME = "com.tencent.mobileqq"
WX_PACKAGE_NAME = "com.tencent.mm"


def check_qq_wx_package():
    top_package = uiauto.info["currentPackageName"]
    logger.debug("top package is %s", top_package)
    
    if top_package == QQ_PACKAGE_NAME or top_package == WX_PACKAGE_NAME:
        return True