B2G工具库
项目描述
B2G python工具库,和一些工具。
安装
要安装 b2g_util,只需运行以下命令。
注意:您可能需要添加 sudo 以获得更多权限,以便将其安装到您的系统中。
$ pip install -U b2g_util
并且,在安装之前,应该将 pip 和 setuptools 升级到最新版本。
$ sudo pip install -U pip setuptools
工具使用
有一些可用的b2g工具。
b2g_backup_restore_profile
b2g_check_versions
b2g_enable_certapps_devtools
b2g_flash_taskcluster
b2g_get_crashreports
b2g_quick_flash
b2g_reset_phone
b2g_shallow_flash
b2g_backup_restore_profile
注意:这是由于b2g没有备份/恢复配置文件的工具,因此是一个备份/恢复解决方案的工作区。
usage: b2g_backup_restore_profile [-h] [-s SERIAL] (-b | -r) [--sdcard]
[--no-reboot] [-p PROFILE_DIR]
[--skip-version-check] [-v]
Workaround for backing up and restoring Firefox OS profiles. (BETA)
optional arguments:
-h, --help show this help message and exit
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
-b, --backup Backup user profile. (default: False)
-r, --restore Restore user profile. (default: False)
--sdcard Also backup/restore SD card. (default: False)
--no-reboot Do not reboot B2G after backup/restore. (default:
False)
-p PROFILE_DIR, --profile-dir PROFILE_DIR
Specify the profile folder. (default: mozilla-profile)
--skip-version-check Turn off version check between backup profile and
device. (default: False)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
b2g_check_versions
usage: b2g_check_versions [-h] [--no-color] [-s SERIAL] [--log-text LOG_TEXT]
[--log-json LOG_JSON] [-v]
Check the version information of Firefox OS.
optional arguments:
-h, --help show this help message and exit
--no-color Do not print with color. NO_COLOR will overrides this
option. (default: False)
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
--log-text LOG_TEXT Text ouput. (default: None)
--log-json LOG_JSON JSON output. (default: None)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
b2g_enable_certapps_devtools
usage: b2g_enable_certapps_devtools [-h] [-s SERIAL] [--disable] [-v]
Enable/disable Certified Apps Debugging.
optional arguments:
-h, --help show this help message and exit
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
--disable Disable the privileges. (default: False)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
Please enable "ADB and Devtools" of device.
Ref:
- https://mdn.org.cn/en-US/docs/Tools/WebIDE
- https://mdn.org.cn/en-US/docs/Tools/WebIDE/Running_and_debugging_apps#Debugging_apps
b2g_flash_taskcluster
usage: b2g_flash_taskcluster [-h] [--credentials CREDENTIALS] [-n NAMESPACE]
[-d DEST_DIR] [-v]
The simple GUI tool for flashing B2G from Taskcluster.
optional arguments:
-h, --help show this help message and exit
--credentials CREDENTIALS
The credential JSON file
(default: /home/askeing/tc_credentials.json)
-n NAMESPACE, --namespace NAMESPACE
The namespace of task
-d DEST_DIR, --dest-dir DEST_DIR
The dest folder (default: current working folder)
-v, --verbose Turn on verbose output, with all the debug logger.
For more information of Taskcluster, see:
- http://docs.taskcluster.net/
- https://pypi.python.org/pypi/taskcluster_util
The tc_credentials.json Template:
{
"clientId": "",
"accessToken": "",
"certificate": {
"version":1,
"scopes":["*"],
"start":xxx,
"expiry":xxx,
"seed":"xxx",
"signature":"xxx"
}
}
临时凭证
您可以从https://auth.taskcluster.net/(使用具有LDAP账户的Persona)获取您的临时凭证。
临时凭证将保持有效31天。
或者,您可以直接运行 taskcluster_login 获取您的凭证。(注意:它将删除您的旧凭证文件。)
tc_credentials.json
您可以将凭证放入主目录下的 tc_credentials.json 文件中。
$ <YOUR_EDITOR> ~/tc_credentials.json
文件格式将是
{
"clientId": "<YOUR_CLIENTID>",
"accessToken": "<YOUR_ACCESSTOKEN>",
"certificate": <YOUR_CERTIFICATE>
}
b2g_get_crashreports
usage: b2g_get_crashreports [-h] [-s SERIAL] [-v]
Get the Crash Reports from Firefox OS Phone.
optional arguments:
-h, --help show this help message and exit
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
b2g_quick_flash
usage: b2g_quick_flash [-h] [-l] [-v]
Simply flash B2G into device. Ver. 0.0.1
optional arguments:
-h, --help show this help message and exit
-l, --list List supported devices and branches. (default: False)
-v, --verbose Turn on verbose output, with all the debug logger. (default:
False)
临时凭证
见 b2g_flash_taskcluster 会话。
b2g_reset_phone
usage: b2g_reset_phone [-h] [-s SERIAL] [-v]
Reset Firefox OS Phone.
optional arguments:
-h, --help show this help message and exit
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
b2g_shallow_flash
usage: b2g_shallow_flash [-h] [-s SERIAL] [-g GAIA] [-G GECKO]
[--keep-profile] [-v]
Workaround for shallow flash Gaia or Gecko into device.
optional arguments:
-h, --help show this help message and exit
-s SERIAL, --serial SERIAL
Directs command to the device or emulator with the
given serial number. Overrides ANDROID_SERIAL
environment variable. (default: None)
-g GAIA, --gaia GAIA Specify the Gaia package. (zip format) (default: None)
-G GECKO, --gecko GECKO
Specify the Gecko package. (tar.gz format) (default:
None)
--keep-profile Keep user profile of device. Only work with shallow
flash Gaia. (BETA) (default: False)
-v, --verbose Turn on verbose output, with all the debug logger.
(default: False)
开发
要开发 b2g_util,从Github 分支项目,并简单地
$ git clone https://github.com/<YOUR_ACCOUNT>/b2g-util-python.git
$ cd b2g-util-python
$ make dev-env
$ source env-python/bin/activate
或者,您可以运行测试
$ make test
您还可以创建文档,然后您可以通过打开 docs/index.html 来访问文档。
$ make docs
SSL InsecurePlatformWarning
如果在运行工具时出现以下错误信息,请安装 requests[security] 包。
InsecurePlatformWarning: A true SSLContext object is not available.
This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
使用pip安装包。请注意,这不是Python 2.7.9+版本所必需的。
pip install requests[security]
如果在安装 requests[security] 时出现 Setup脚本退出时出错:命令‘gcc’失败,退出状态1 错误,请安装 libffi-dev。(Ubuntu)
sudo apt-get install libffi-dev
其他问题
如果您遇到与 urllib3、SSL 或 tk 相关的任何问题,请安装以下包。(Ubuntu)
sudo apt-get install python python-dev python-setuptools libffi-dev libssl-dev python-tk
sudo easy_install pip
sudo pip install -U pip setuptools
sudo pip install -U requests
sudo pip install -U requests[security]
发布历史
0.0.19 (2016-03-04)
功能和改进
添加 b2g_quick_flash 的 D5833 支持
0.0.18 (2016-01-29)
功能和改进
启用 adb 进行开发工具调试
将 taskcluster_util 更新到 0.0.30
错误修复
修复 adb forward 的错误。
0.0.17 (2016-01-05)
功能和改进
将 taskcluster_util 更新到 0.0.27
0.0.16 (2015-12-24)
功能和改进
将 taskcluster_util 更新到 0.0.26
添加 b2g_quick_flash
0.0.15 (2015-11-30)
功能和改进
将 taskcluster_util 更新到 0.0.25
0.0.14 (2015-11-23)
功能和改进
将 taskcluster_util 更新到 0.0.24
0.0.13 (2015-11-02)
功能和改进
添加 b2g_flash_taskcluster
0.0.12 (2015-09-15)
功能和改进
为 AdbWrapper 的 pull 和 push 添加对文件路径中空格的支持。
将 pending/submitted 文件路径添加到 get_crashreports 的结果字典对象中。
0.0.11 (2015-09-10)
功能和改进
为 b2g_shallow_flash 添加保持配置文件的特征。
在备份配置文件时,从 pref.js 中删除 gecko.mstone 值。
0.0.10 (2015-09-09)
功能和改进
添加 b2g_shallow_flash 工具。
添加 adb remount 和 adb wait-for-device。
将解压缩器的函数修改为类方法。
0.0.9 (2015-09-09)
缺少一些文件...
0.0.8 (2015-09-07)
功能和改进
修改工具以提高其可重用性。
重构。
为 get_crashreports 添加 JSON 输出。
错误修复
删除未使用的导入。
将单引号字符串格式错误修复为双引号字符串格式。
0.0.7 (2015-08-20)
功能和改进
当文件夹已存在时,停止备份配置文件。
重构所有工具,将 prepare() 方法从 __init__() 移动到 run()。
为 backup_restore_profile 添加新参数 “–skip-version-check”。
提取 compare_version()、get_profile_path() 和 get_version_from_profile() 方法。
为创建文档添加文档字符串。
为 backup_restore_profile 和 adb_helper 添加单元测试。
更新 README。
错误修复
删除未使用的代码。
从下载器和解压缩器中删除记录器。
0.0.6 (2015-08-14)
功能和改进
在 b2g_backup_restore_profile 中使用 B2GHelper。
重构 check_versions。
重构 backup_restore_profile
错误修复
如果不需要重新启动,则跳过添加 enable_certapps_devtools 设置。
0.0.5 (2015-08-13)
功能和改进
添加 b2g_enable_certapps_devtools 工具。
为 Firefox OS 操作添加 B2GHelper 类。
错误修复
某些命令将停止设备而没有任何返回代码。例如,adb shell reboot recovery。
0.0.4 (2015-08-12)
功能和改进
添加 b2g_get_crashreports 工具
重构 ADBWrapper,当命令失败时将抛出异常。
在运行 adb shell 命令时从设备返回 stdout 和 return code。
错误修复
将备份/恢复参数设置为所需值,并将它们放入同一组。
重启 adbd 时等待片刻。
0.0.3 (2015-08-06)
功能和改进
添加 AdbHelper.get_serial() 方法以获取 adb 序列号。
修改 adb_helper 的类。
修改工具代码以提高其清晰度。
错误修复
修复当 adb 服务器没有启动时的 list index out of range 错误。
修复工具的记录器处理问题。
0.0.2 (2015-08-05)
- 重命名工具
为工具添加 b2g_ 前缀
编写 README 文件
0.0.1 (2015-08-05)
- 启动项目
基本 ADB 命令支持
b2g_backup_restore_profile 工具(解决方案)
b2g_check_versions 工具
b2g_reset_phone 工具
项目详情
b2g_util-0.0.19.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 863837a17c38c42a18ce9c280235e5e2bc0233171da1873f85f25bc9169cd4da |
|
MD5 | 6c5069f3f0b285b74d4da4985a52c94e |
|
BLAKE2b-256 | 284a8bb232992c5fbbd90627279d1e905001df5608873991b467e310c24f98bb |