Closed
Bug 872212
Opened 12 years ago
Closed 12 years ago
dmcli launchfennec "--mozenv" option broken
Categories
(Testing :: Mozbase, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: wlach, Assigned: wlach)
Details
Attachments
(1 file, 1 obsolete file)
2.23 KB,
patch
|
mcote
:
review+
|
Details | Diff | Splinter Review |
mozenv needs to be passed as a dictionary to the underlying implementation, but we have no way of doing this currently. Let's parse this argument as json and then do that. This will let us do things like easily launch fennec with network profiling enabled as follows:
dm launchfennec org.mozilla.fennec_wlach--mozenv '{ "NSPR_LOG_MODULES":"timestamp,nsHttp:5,nsSocketTransport:5,nsHostResolver:5","NSPR_LOG_FILE":"/mnt/sdcard/http.log"}' --url http://www.nytimes.com
Assignee | ||
Comment 1•12 years ago
|
||
Attachment #749460 -
Flags: review?(mcote)
Comment 2•12 years ago
|
||
So this works but strikes me as a bit awkward, in that environment variables only map to a small subset of JSON (as well as being somewhat annoying to type). What about just passing a space-separated list, as you would use at the beginning of the line when executing a function from the shell? E.g.
--mozenv 'NSPR_LOG_MODULES=timestamp,nsHttp:5,nsSocketTransport:5,nsHostResolver:5 NSPR_LOG_FILE=/mnt/sdcard/http.log'
Assignee | ||
Comment 3•12 years ago
|
||
I like this idea. Updated patch per your suggestion.
Attachment #749460 -
Attachment is obsolete: true
Attachment #749460 -
Flags: review?(mcote)
Attachment #750696 -
Flags: review?(mcote)
Comment 4•12 years ago
|
||
Comment on attachment 750696 [details] [diff] [review]
Updated patch per mcote's suggestion
Review of attachment 750696 [details] [diff] [review]:
-----------------------------------------------------------------
This is good with a few little changes.
::: mozdevice/mozdevice/dmcli.py
@@ +14,4 @@
> import mozdevice
> import mozlog
> import argparse
> +import json
No longer needed.
@@ +110,5 @@
> 'default': 'android.intent.action.VIEW' },
> { 'name': '--url', 'action': 'store' },
> { 'name': '--extra-args', 'action': 'store' },
> + { 'name': '--mozenv', 'action': 'store',
> + 'help': 'Gecko environment variables to set in "KEY1=VAL1;KEY2=VAL2" format' },
The code in launchfennec() below separates variables by whitespace (which I think is the correct approach), so the example format should be "KEY1=VAL1 KEY2=VAL2" (i.e. no semicolon).
@@ +322,5 @@
> + if args.mozenv:
> + mozEnv = {}
> + keyvals = args.mozenv.split()
> + for keyval in keyvals:
> + (key, val) = keyval.split("=")
So it seems that, on POSIXy systems at least, subsequent '=' characters in an environment variable assignment are treated as part of the value. For example, "FOO=BAR=BAZ" results in "FOO" being set to "BAR=BAZ".
You could replicate that behaviour here with '(key, _, val) = keyval.partition("=")'.
@@ +324,5 @@
> + keyvals = args.mozenv.split()
> + for keyval in keyvals:
> + (key, val) = keyval.split("=")
> + mozEnv[key] = val
> + print mozEnv
Debug print statement?
Attachment #750696 -
Flags: review?(mcote) → review+
Assignee | ||
Comment 5•12 years ago
|
||
Pushed with suggested changes: https://github.com/mozilla/mozbase/commit/42ba6a97c6010d61b30b0940992db3ac2b767c8b
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•