Closed Bug 872212 Opened 12 years ago Closed 12 years ago

dmcli launchfennec "--mozenv" option broken

Categories

(Testing :: Mozbase, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Assigned: wlach)

Details

Attachments

(1 file, 1 obsolete file)

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
Attachment #749460 - Flags: review?(mcote)
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'
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 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+
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.

Attachment

General

Created:
Updated:
Size: