提交 93cd5745 编写于 作者: Y yejianwu

add file lock to adb_run

上级 cad35db5
...@@ -109,12 +109,13 @@ RUN apt-get install -y --no-install-recommends \ ...@@ -109,12 +109,13 @@ RUN apt-get install -y --no-install-recommends \
# Install tools # Install tools
RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com setuptools RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com setuptools
RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com tensorflow==1.4.0 \ RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com tensorflow==1.6.0 \
scipy \ scipy \
jinja2 \ jinja2 \
pyyaml \ pyyaml \
sh \ sh==1.12.14 \
pycodestyle pycodestyle==2.4.0 \
filelock
# Download tensorflow tools # Download tensorflow tools
RUN wget http://cnbj1-inner-fds.api.xiaomi.net/mace/tool/transform_graph && \ RUN wget http://cnbj1-inner-fds.api.xiaomi.net/mace/tool/transform_graph && \
......
import sh import falcon_cli
import filelock
import re import re
import sh
import time import time
import falcon_cli
################################ ################################
...@@ -85,12 +86,17 @@ def adb_run(serialno, ...@@ -85,12 +86,17 @@ def adb_run(serialno,
print( print(
"=====================================================================" "====================================================================="
) )
print("Run on device: %s, %s, %s" % (serialno, props["ro.board.platform"], lock_path = "/tmp/device-lock-%s" % serialno
print("Try to lock ", lock_path)
with filelock.FileLock(lock_path, timeout=3600):
print("Run on device: %s, %s, %s" % (serialno,
props["ro.board.platform"],
props["ro.product.model"])) props["ro.product.model"]))
sh.adb("-s", serialno, "shell", "rm -rf %s" % device_bin_path) sh.adb("-s", serialno, "shell", "rm -rf %s" % device_bin_path)
sh.adb("-s", serialno, "shell", "mkdir -p %s" % device_bin_path) sh.adb("-s", serialno, "shell", "mkdir -p %s" % device_bin_path)
print("Push %s to %s" % (host_bin_full_path, device_bin_full_path)) print("Push %s to %s" % (host_bin_full_path, device_bin_full_path))
sh.adb("-s", serialno, "push", host_bin_full_path, device_bin_full_path) sh.adb("-s", serialno, "push", host_bin_full_path,
device_bin_full_path)
print("Run %s" % device_bin_full_path) print("Run %s" % device_bin_full_path)
stdout_buff = [] stdout_buff = []
process_output = make_output_processor(stdout_buff) process_output = make_output_processor(stdout_buff)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册