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

Commit

Permalink
support connect through env-var, close #11
Browse files Browse the repository at this point in the history
  • Loading branch information
shengxiang committed Apr 11, 2016
1 parent cf65a1d commit 725f1d9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 5 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
CHANGES
=======

* add ext
* add android recorder structure
* modify name
* merge from ssx
* split record to sub package
* add new favicon, close #7
* finish part of add_listener, add cloudtest log support
* merge sxx
* add refresh button to web ide
* merge from ssx
* merge from ssx
* add recorder runner
* add strutils.py in order to fix zh-simple encoding
* use self defined logging module instead of standlib logging
* merge code in company
* add save screen button
* prepare two position for console
* add how to design images and code storage to todo.md
* support stop run in browser
* add mouse move detect, change save debug code to no debug code
* change to python auto close blockly
* use canvas to show screen
* rename AirtestX to AuTo eXpress
* rename project
* generate py scripts
* handle touch event, find clicked object
* windows add screen_cv2 & make window foreground before capturing
* windows capture entire screen to avoid failing on opengl programs
* redirect output to webide
* use images before & after the click to find out the step
* handle touch input in background
* merge sxx
* recorder capture image in background
* add screen in webide
* record api change & merge sxx
* use ctypes instead of win32ui for screenshot
* add debug step by step support
* add simple python intepreter: python -matx run <filename>
* add websocket for atx webide
* add image_search variable and properties for android
* fix win32ui+tk.mainloop hangup
* add record command
* add record command
* add get properties for android
* merge ssx

1.0.7
-----

* add it inorder to pass
* add WatchItem
* update changelog
* resolution add assert check
* update documentation
* add update generate
* record test
* support save workspace
* add atx auto code converter
* update args ... match sphinx
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ ATX毕竟是一个python库,给出代码的例子可能更好理解一些
d = atx.connect()
```

通过设置相应的环境变量也可以设置连接参数,用来方便持续集成

目前支持4个环境变量

```sh
ATX_ADB_SERIALNO
ATX_ADB_HOST
ATX_ADB_PORT
ATX_PLATFORM 默认是 android
```

```sh
$ python -c 'import atx; atx.connect('EFF153')

# 等价写法
$ export ATX_ADB_SERIALNO="EFF153"
$ python -c 'import atx; atx.connect()'
```

* App的起停

```py
Expand Down Expand Up @@ -332,8 +351,6 @@ click(20, 30)
### 其他接口




## 批量运行脚本
推荐用unittest, 它是python自身的一个测试框架(其他出色的也有nose, pytest) 等等,看个人喜好

Expand Down
3 changes: 2 additions & 1 deletion atx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from __future__ import absolute_import

import os
import sys
import signal

Expand All @@ -31,7 +32,7 @@ def connect(*args, **kwargs):
Raises:
SyntaxError, EnvironmentError
"""
platform = kwargs.pop('platform', 'android')
platform = kwargs.pop('platform', os.getenv('ATX_PLATFORM') or 'android')

cls = None
if platform == 'android':
Expand Down
12 changes: 10 additions & 2 deletions atx/device/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
'package'])


def getenv(name, default_value=None, type=str):
try:
return type(os.getenv(name)) or default_value
except:
return default_value


class AndroidDevice(DeviceMixin, UiaDevice):
def __init__(self, serialno=None, **kwargs):
"""Initial AndroidDevice
Expand All @@ -60,8 +67,9 @@ def __init__(self, serialno=None, **kwargs):
Raises:
EnvironmentError
"""
self._host = kwargs.get('host', '127.0.0.1')
self._port = kwargs.get('port', 5037)
serialno = serialno or getenv('ATX_ADB_SERIALNO') or None
self._host = kwargs.get('host', getenv('ATX_ADB_HOST', '127.0.0.1'))
self._port = kwargs.get('port', getenv('ATX_ADB_PORT', 5037, type=int))
self._adb = adb.Adb(serialno, self._host, self._port)
serialno = self._adb.device_serial()

Expand Down

0 comments on commit 725f1d9

Please sign in to comment.