Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nox Android 模拟器校时脚本,放置在安装目录下的 bin 目录双击使用,每分钟同步一次模拟器与主机的时间
import subprocess
import time
from datetime import datetime as dt
import logging
logging.basicConfig(level=logging.DEBUG,
format='[%(asctime)s][%(levelname)s][%(funcName)-2s]-> %(message)s',
datefmt='%m-%d %H:%M:%S')
subprocess.call("nox_adb connect 127.0.0.1:52001",shell=False)
while True:
command = "nox_adb shell date -s \"%s\"" % dt.now().strftime("%Y%m%d.%H%M%S")
try:
r = subprocess.check_output(command, shell=True).decode("UTF-8").rstrip()
logging.info(r)
except subprocess.CalledProcessError:
logging.warning("Restarting ADB Server...")
subprocess.call("nox_adb kill-server",shell=False)
subprocess.call("nox_adb connect 127.0.0.1:52001",shell=False)
continue
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.