Package: b2g_util
B2G python utilities library, and some tools.InstallationTo installb2g_util, simply running then following command.Note: You might have to addsudofor getting more permission when install it into your system.$pipinstall-Ub2g_utilAnd thepipandsetuptoolsshould be upgraded to latest version before install.$sudopipinstall-UpipsetuptoolsTools UsagesThere are some available b2g tools.b2g_backup_restore_profileb2g_check_versionsb2g_enable_certapps_devtoolsb2g_flash_taskclusterb2g_get_crashreportsb2g_quick_flashb2g_reset_phoneb2g_shallow_flashb2g_backup_restore_profileNote: This is a workaround backup/restore solution due to b2g doesn’t have tool to backup/restore profile.usage:b2g_backup_restore_profile[-h][-sSERIAL](-b|-r)[--sdcard][--no-reboot][-pPROFILE_DIR][--skip-version-check][-v]WorkaroundforbackingupandrestoringFirefoxOSprofiles.(BETA)optionalarguments:-h,--helpshowthishelpmessageandexit-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)-b,--backupBackupuserprofile.(default:False)-r,--restoreRestoreuserprofile.(default:False)--sdcardAlsobackup/restoreSDcard.(default:False)--no-rebootDonotrebootB2Gafterbackup/restore.(default:False)-pPROFILE_DIR,--profile-dirPROFILE_DIRSpecifytheprofilefolder.(default:mozilla-profile)--skip-version-checkTurnoffversioncheckbetweenbackupprofileanddevice.(default:False)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)b2g_check_versionsusage:b2g_check_versions[-h][--no-color][-sSERIAL][--log-textLOG_TEXT][--log-jsonLOG_JSON][-v]ChecktheversioninformationofFirefoxOS.optionalarguments:-h,--helpshowthishelpmessageandexit--no-colorDonotprintwithcolor.NO_COLORwilloverridesthisoption.(default:False)-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)--log-textLOG_TEXTTextouput.(default:None)--log-jsonLOG_JSONJSONoutput.(default:None)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)b2g_enable_certapps_devtoolsusage:b2g_enable_certapps_devtools[-h][-sSERIAL][--disable][-v]Enable/disableCertifiedAppsDebugging.optionalarguments:-h,--helpshowthishelpmessageandexit-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)--disableDisabletheprivileges.(default:False)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)Pleaseenable"ADB and Devtools"ofdevice.Ref:-https://developer.mozilla.org/en-US/docs/Tools/WebIDE-https://developer.mozilla.org/en-US/docs/Tools/WebIDE/Running_and_debugging_apps#Debugging_appsb2g_flash_taskclusterusage:b2g_flash_taskcluster[-h][--credentialsCREDENTIALS][-nNAMESPACE][-dDEST_DIR][-v]ThesimpleGUItoolforflashingB2GfromTaskcluster.optionalarguments:-h,--helpshowthishelpmessageandexit--credentialsCREDENTIALSThecredentialJSONfile(default:/home/askeing/tc_credentials.json)-nNAMESPACE,--namespaceNAMESPACEThenamespaceoftask-dDEST_DIR,--dest-dirDEST_DIRThedestfolder(default:currentworkingfolder)-v,--verboseTurnonverboseoutput,withallthedebuglogger.FormoreinformationofTaskcluster,see:-http://docs.taskcluster.net/-https://pypi.python.org/pypi/taskcluster_utilThetc_credentials.jsonTemplate:{"clientId":"","accessToken":"","certificate":{"version":1,"scopes":["*"],"start":xxx,"expiry":xxx,"seed":"xxx","signature":"xxx"}}Temporary CredentialsYou can get your temporary credentials fromhttps://auth.taskcluster.net/(using Persona with LDAP account).The temporary credentials will remain valid for 31 days.Or you can just runtaskcluster_loginto get your credentials. (Note: it will remove your old credentials file.)tc_credentials.jsonYou can put the credentials intotc_credentials.jsonfile under your home folder.$<YOUR_EDITOR>~/tc_credentials.jsonThe file format will be:{
            "clientId": "<YOUR_CLIENTID>",
            "accessToken": "<YOUR_ACCESSTOKEN>",
            "certificate": <YOUR_CERTIFICATE>
    }b2g_get_crashreportsusage:b2g_get_crashreports[-h][-sSERIAL][-v]GettheCrashReportsfromFirefoxOSPhone.optionalarguments:-h,--helpshowthishelpmessageandexit-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)b2g_quick_flashusage:b2g_quick_flash[-h][-l][-v]SimplyflashB2Gintodevice.Ver.0.0.1optionalarguments:-h,--helpshowthishelpmessageandexit-l,--listListsupporteddevicesandbranches.(default:False)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)Temporary CredentialsSeeb2g_flash_taskclustersession.b2g_reset_phoneusage:b2g_reset_phone[-h][-sSERIAL][-v]ResetFirefoxOSPhone.optionalarguments:-h,--helpshowthishelpmessageandexit-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)b2g_shallow_flashusage:b2g_shallow_flash[-h][-sSERIAL][-gGAIA][-GGECKO][--keep-profile][-v]WorkaroundforshallowflashGaiaorGeckointodevice.optionalarguments:-h,--helpshowthishelpmessageandexit-sSERIAL,--serialSERIALDirectscommandtothedeviceoremulatorwiththegivenserialnumber.OverridesANDROID_SERIALenvironmentvariable.(default:None)-gGAIA,--gaiaGAIASpecifytheGaiapackage.(zipformat)(default:None)-GGECKO,--geckoGECKOSpecifytheGeckopackage.(tar.gzformat)(default:None)--keep-profileKeepuserprofileofdevice.OnlyworkwithshallowflashGaia.(BETA)(default:False)-v,--verboseTurnonverboseoutput,withallthedebuglogger.(default:False)DevelopmentTo develop theb2g_util, fork project fromGithuband simply:$gitclonehttps://github.com/<YOUR_ACCOUNT>/b2g-util-python.git$cdb2g-util-python$makedev-env$sourceenv-python/bin/activateOr you can run tests:$maketestYou also can create the document, and then you can opendocs/index.htmlto access the document.$makedocsSSL InsecurePlatformWarningIf you got the following error message when running the tools, please installrequests[security]package.InsecurePlatformWarning:AtrueSSLContextobjectisnotavailable.Thispreventsurllib3fromconfiguringSSLappropriatelyandmaycausecertainSSLconnectionstofail.Formoreinformation,seehttps://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.Install package by pip install. Please note it’s not required for Python 2.7.9+.pipinstallrequests[security]If you gotSetup script exited with error: command ‘gcc’ failed with exit status 1error when installrequests[security], please installlibffi-dev. (Ubuntu)sudoapt-getinstalllibffi-devThe Other IssuesIf you meet any issues related to urllib3, SSL, or tk, please install following packages. (Ubuntu)sudoapt-getinstallpythonpython-devpython-setuptoolslibffi-devlibssl-devpython-tksudoeasy_installpipsudopipinstall-Upipsetuptoolssudopipinstall-Urequestssudopipinstall-Urequests[security]Release History0.0.19 (2016-03-04)Features and ImprovementsAdd D5833 supoort of b2g_quick_flash0.0.18 (2016-01-29)Features and ImprovementsEnable adb for dev tool debuggingUpdate taskcluster_util to 0.0.30bugfixesFix the bug of adb forward.0.0.17 (2016-01-05)Features and ImprovementsUpdate taskcluster_util to 0.0.270.0.16 (2015-12-24)Features and ImprovementsUpdate taskcluster_util to 0.0.26Add b2g_quick_flash0.0.15 (2015-11-30)Features and ImprovementsUpdate taskcluster_util to 0.0.250.0.14 (2015-11-23)Features and ImprovementsUpdate taskcluster_util to 0.0.240.0.13 (2015-11-02)Features and ImprovementsAdd b2g_flash_taskcluster0.0.12 (2015-09-15)Features and ImprovementsAdd space in filepath support for AdbWrapper’s pull and push.Add pending/submitted filepath into result dict object for get_crashreports.0.0.11 (2015-09-10)Features and ImprovementsAdd 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 ImprovementsAdd 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 ImprovementsModify tools for more reusable.Refactoring.Add JSON output for get_crashreports.bugfixesRemove unused import.Fix the docstrings from single-quoted to double-quoted string format.0.0.7 (2015-08-20)Features and ImprovementsStop 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.bugfixesRemove unused code.Remove the logger from downloader and decompressor.0.0.6 (2015-08-14)Features and ImprovementsUse B2GHelper in b2g_backup_restore_profile.Refactoring the check_versions.Refactoring the backup_restore_profilebugfixesSkip adding setting of enable_certapps_devtools when it doesn’t need to restart.0.0.5 (2015-08-13)Features and ImprovementsAddb2g_enable_certapps_devtoolstool.Add B2GHelper class for Firefox OS operations.bugfixessome command will stop device with no returncode. e.g. adb shell reboot recovery.0.0.4 (2015-08-12)Features and ImprovementsAddb2g_get_crashreportstoolRefactoring the ADBWrapper, it will raise exception when command failed.Return stdout and return code from device when running adb shell command.bugfixesSet 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 ImprovementsAdded the methodAdbHelper.get_serial()for getting the adb serial numberModified the classes of adb_helperModified the code of tools for making them clearbugfixesFixed thelist index out of rangewhen adb server doesn’t startFixed the logger handle issue of tools0.0.2 (2015-08-05)Rename the toolsAdded the prefixb2g_of toolsWrite the README file0.0.1 (2015-08-05)Initiate the projectBasic ADB commands supportTheb2g_backup_restore_profile(workaround) toolTheb2g_check_versionstoolTheb2g_reset_phonetool