How to use the airtest.base.getLogger function in airtest

To help you get started, we’ve selected a few airtest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NetEase / airtest / airtest / devsuit.py View on Github external
import os
import platform
import time
import threading
import json

import cv2
import aircv as ac

from . import base
from . import proto
from . import patch
from .image import sift as imtsift
from .image import template as imttemplate

log = base.getLogger('devsuit')

class DeviceSuit(object):
    def __init__(self, devtype, dev, logfile='log/airtest.log'):
        # print 'DEVSUIT_SERIALNO:', phoneno
        self.dev = dev
        # self.appname = appname
        self._devtype = devtype
        self._inside_depth = 0

        # default image search extentension and 
        self._image_exts = ['.jpg', '.png']
        self._image_dirs = ['.', 'image']

        self._rotation = None # 0,1,2,3
        self._tmpdir = 'tmp'
        self._click_timeout = 20.0 # if icon not found in this time, then panic
github NetEase / airtest / airtest / device / android.py View on Github external
'''

import json
import os
import re
import subprocess
import string
import StringIO
from functools import partial
from .adb.adbclient import AdbClient

from .. import patch, base
from .. import proto

DEBUG = os.getenv("AIRDEBUG")=="true"
log = base.getLogger('android')

__dir__ = os.path.dirname(os.path.abspath(__file__))

def str2any(s):
    if s.isdigit():
        return int(s)
    if s.lower() == 'true' or s.lower() == 'false':
        return s.lower() == 'true'
    return s

class Monitor(object):
    def __init__(self, serialno, pkgname):
        self._sno = serialno 
        self._pkg = pkgname
        def _adb(*args):
            return subprocess.check_output(['adb', '-s', self._sno] + list(args))
github NetEase / airtest / airtest / trash / android.py View on Github external
'''

import os
import time

from airtest import image
from airtest import patch
from airtest import base
from airtest import jsonlog

from com.dtmilano.android.viewclient import ViewClient 
from com.dtmilano.android.viewclient import adbclient

DEBUG = os.getenv("DEBUG")=="true"
 
log = base.getLogger('android')

def getMem(serialno, package):
    '''
    @param package(string): android package name
    @return float: the memory, unit MB
    '''
    command = 'adb -s %s shell dumpsys meminfo' % serialno
    mem_info = base.check_output(command).splitlines()
    try:
        xym_mem = filter(lambda x: package in x, mem_info)[0].split()[0]
        mem = float(xym_mem) / 1024
        log.info("mem_info:%s" % mem)
        return mem
    except IndexError:
        log.error("mem_info error")
        return 0
github NetEase / airtest / airtest / trash / ios.py View on Github external
# -*- coding: utf-8 -*-

'''
iphone and ipad
'''

import os
import time
from PIL import Image

# from airtest import patch
from airtest import image
from airtest import base
from appium import webdriver

log = base.getLogger('ios')

#@patch.record()
class IosDevice(object):
    def __init__(self):
        self._imgdir = None
        self._last_point = None
        self.url = 'http://127.0.0.1:4723/wd/hub'

        log.debug("IosDevice start connecting...it may take a minute")
        self.driver = self._connect()

        self.width, self.height = self._getShape()
        self._getShapeReal()
        log.debug('IosDevice connected: width:{width}, height:{height}'.format(
            width=self.width, height=self.height))
github NetEase / airtest / airtest / device / dummy.py View on Github external
# -*- coding: utf-8 -*-

'''
This is only for test airtest itself
'''

import os
import shutil
import airtest

from airtest import base
# from com.dtmilano.android.viewclient import ViewClient 
# from com.dtmilano.android.viewclient import adbclient

DEBUG = os.getenv("DEBUG")=="true"
log = base.getLogger('dummy')


class Device(object):
    def __init__(self, phoneno=None):
        self._snapshot = './default.png'
        self._text = ''
        self._click = None
        self._getCpu = False
        pass

    def snapshot(self, filename):
        ''' save screen snapshot '''
        log.debug('DUMMY take snapshot %s' %(filename))
        shutil.copyfile(self._snapshot, filename)

    def touch(self, x, y, duration=0.1):
github NetEase / airtest / airtest / patch.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
import threading

from functools import partial

from . import base

log = base.getLogger('patch')

def thread_safe(f):
    '''
    add thread lock for function

    @thread_safe
    def sayhi(name):
        print 'Hi', name
    '''
    lock = threading.Lock()
    def wrapper(*args, **kwargs):
        lock.acquire()
        ret = f(*args, **kwargs)
        lock.release()
        return ret
    return wrapper
github NetEase / airtest / airtest / device / ios.py View on Github external
'''
basic operation for a game(like a user does)
'''

import logging
logging.getLogger("paramiko").setLevel(logging.WARNING)

import subprocess
from appium import webdriver
from PIL import Image

from .. import base
from .. import patch
 
log = base.getLogger('ios')

class Monitor(object):
    def __init__(self, ip, appname):
        try:
            import paramiko
        except:
            raise RuntimeError("Require python-lib 'paramiko' installed")

        self._ssh = paramiko.client.SSHClient()
        self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self._ssh.connect(ip, username='root', password='alpine')
        self._ip = ip 
        self._name = appname
        def _sh(*args):
            cmd = args[0] if len(args) == 1 else subprocess.list2cmdline(args)
            stdin, out, err = self._ssh.exec_command(cmd)
github NetEaseGame / ATX / atx / unused-drivers / dummy.py View on Github external
# -*- coding: utf-8 -*-

'''
This is only for test airtest itself
'''

import os
import shutil
import airtest

from airtest import base
# from com.dtmilano.android.viewclient import ViewClient 
# from com.dtmilano.android.viewclient import adbclient

DEBUG = os.getenv("DEBUG")=="true"
log = base.getLogger('dummy')


class Device(object):
    def __init__(self, phoneno=None):
        self._snapshot = './default.png'
        self._text = ''
        self._click = None
        self._getCpu = False
        pass

    def snapshot(self, filename):
        ''' save screen snapshot '''
        log.debug('DUMMY take snapshot %s' %(filename))
        shutil.copyfile(self._snapshot, filename)

    def touch(self, x, y, duration=0.1):