Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

B2G Utilities

Project description

https://travis-ci.org/askeing/b2g-util-python.svg?branch=master

B2G python utilities library, and some tools.

Installation

To install b2g_util, simply running then following command.

Note: You might have to add sudo for getting more permission when install it into your system.

$ pip install -U b2g_util

And the pip and setuptools should be upgraded to latest version before install.

$ sudo pip install -U pip setuptools

Tools Usages

There are some available b2g tools.

  • b2g_backup_restore_profile

  • b2g_check_versions

  • b2g_enable_certapps_devtools

  • b2g_get_crashreports

  • b2g_reset_phone

  • b2g_shallow_flash

b2g_backup_restore_profile

Note: This is a workaround backup/restore solution due to b2g doesn’t have tool to backup/restore profile.

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://developer.mozilla.org/en-US/docs/Tools/WebIDE
- https://developer.mozilla.org/en-US/docs/Tools/WebIDE/Running_and_debugging_apps#Debugging_apps

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_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)

Development

To develop the b2g_util, fork project from Github and simply:

$ git clone https://github.com/<YOUR_ACCOUNT>/b2g-util-python.git
$ cd b2g-util-python
$ make dev-env
$ source env-python/bin/activate

Or you can run tests:

$ make test

You also can create the document, and then you can open docs/index.html to access the document.

$ make docs

Release History

0.0.11 (2015-09-10)

Features and Improvements

  • Add keep profile feature of b2g_shallow_flash.

  • Remove gecko.mstone value from pref.js when backup profile.

0.0.10 (2015-09-09)

Features and Improvements

  • Add b2g_shallow_flash tool.

  • Add adb remount and adb wait-for-device.

  • Modify the decompressor’s method to classmethod.

0.0.9 (2015-09-09)

  • missing some files…

0.0.8 (2015-09-07)

Features and Improvements

  • Modify tools for more reusable.

  • Refactoring.

  • Add JSON output for get_crashreports.

bugfixes

  • Remove unused import.

  • Fix the docstrings from single-quoted to double-quoted string format.

0.0.7 (2015-08-20)

Features and Improvements

  • Stop backup profil when the folder already exists.

  • Refactoring all tools, move prepare() method from __init__() to run().

  • Add new argument “–skip-version-check” for backup_restore_profile.

  • Extract compare_version(), get_profile_path(), and get_version_from_profile() methods.

  • Add docstring for creating the document.

  • Add unittest for backup_restore_profile, and adb_helper.

  • Update README.

bugfixes

  • Remove unused code.

  • Remove the logger from downloader and decompressor.

0.0.6 (2015-08-14)

Features and Improvements

  • Use B2GHelper in b2g_backup_restore_profile.

  • Refactoring the check_versions.

  • Refactoring the backup_restore_profile

bugfixes

  • Skip adding setting of enable_certapps_devtools when it doesn’t need to restart.

0.0.5 (2015-08-13)

Features and Improvements

  • Add b2g_enable_certapps_devtools tool.

  • Add B2GHelper class for Firefox OS operations.

bugfixes

  • some command will stop device with no returncode. e.g. adb shell reboot recovery.

0.0.4 (2015-08-12)

Features and Improvements

  • Add b2g_get_crashreports tool

  • Refactoring the ADBWrapper, it will raise exception when command failed.

  • Return stdout and return code from device when running adb shell command.

bugfixes

  • Set backup/restore arguments as required and put them into same group.

  • Wait a moment when restarting adbd.

0.0.3 (2015-08-06)

Features and Improvements

  • Added the method AdbHelper.get_serial() for getting the adb serial number

  • Modified the classes of adb_helper

  • Modified the code of tools for making them clear

bugfixes

  • Fixed the list index out of range when adb server doesn’t start

  • Fixed the logger handle issue of tools

0.0.2 (2015-08-05)

  • Rename the tools
    • Added the prefix b2g_ of tools

  • Write the README file

0.0.1 (2015-08-05)

  • Initiate the project
    • Basic ADB commands support

    • The b2g_backup_restore_profile (workaround) tool

    • The b2g_check_versions tool

    • The b2g_reset_phone tool

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page