Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

Commit

Permalink
remove log from base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shengxiang committed Mar 10, 2016
1 parent 6132ce6 commit 9035a56
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 38 deletions.
34 changes: 0 additions & 34 deletions atx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@
import logging
import threading


random.seed(time.time())
logging.basicConfig(format='%(asctime)s - %(levelname)s: %(message)s', level=logging.DEBUG)

def getLogger(name='root'):
return logging.getLogger(name)

log = getLogger('base')

def makedirs(dirname):
try:
os.makedirs(dirname)
except:
pass

def dirname(name):
if os.path.isabs(name):
return os.path.dirname(name)
Expand Down Expand Up @@ -67,10 +52,6 @@ def exec_cmd(*cmds, **kwargs):
return r.wait()
return 0

def check_output(cmd):
#log.debug('CHECK_OUTPUT, cmd: %s' %(cmd))
return subprocess.check_output(cmd, shell=True)

def random_name(name):
out = []
for c in name:
Expand All @@ -79,18 +60,3 @@ def random_name(name):
out.append(c)
return ''.join(out)


def wait_until(fn, interval=0.5, max_retry=10, args=(), kwargs={}):
'''
@return True(when found), False(when not found)
'''
log.debug('start wait func: %s', fn.__name__)
retry = 0
while retry < max_retry:
retry += 1
ret = fn(*args, **kwargs)
if ret:
return ret
log.debug('wait until: %s, sleep: %s', fn.__name__, interval)
time.sleep(interval)
return None
6 changes: 4 additions & 2 deletions atx/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import time
import threading
import warnings
import logging

import cv2
import numpy as np
Expand All @@ -21,14 +22,15 @@
from uiautomator import Device as UiaDevice
from PIL import Image

from atx import base
from atx import consts
from atx import errors
from atx import patch
from atx import logutils


log = logutils.getLogger(__name__) # base.getLogger('devsuit')
log.setLevel(logging.DEBUG)
FindPoint = collections.namedtuple('FindPoint', ['pos', 'confidence', 'method'])
log = base.getLogger('devsuit')

__dir__ = os.path.dirname(os.path.abspath(__file__))
__tmp__ = os.path.join(__dir__, '__cache__')
Expand Down
28 changes: 28 additions & 0 deletions atx/logutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
# coding: utf-8

import logging


_inited = {}

def getLogger(name):
logger = logging.getLogger(name)
if not _inited.get(name):
ch = logging.StreamHandler()
_inited[name] = ch
fmt = "%(asctime)s %(levelname)-8.8s [%(name)s:%(lineno)4s] %(message)s"
formatter = logging.Formatter(fmt)
ch.setFormatter(formatter)
logger.addHandler(ch)
return logger


if __name__ == '__main__':
log = getLogger('test')
log.setLevel(logging.DEBUG)
log.info("Hello")
log.debug("dd Hello")
log = getLogger('test')
log.warn("dd Hello")

4 changes: 2 additions & 2 deletions atx/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import threading
from functools import partial

from atx import base
from atx import logutils


log = base.getLogger('patch')
log = logutils.getLogger(__name__) #base.getLogger('patch')

def thread_safe(f):
'''
Expand Down

0 comments on commit 9035a56

Please sign in to comment.