Closed
Bug 620981
Opened 14 years ago
Closed 14 years ago
devicemanager.py needs to be updated with m-c and talos
Categories
(Testing :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: jmaher, Assigned: jmaher)
Details
(Whiteboard: [mobile_unittests])
Attachments
(3 files, 4 obsolete files)
12.91 KB,
patch
|
jmaher
:
review+
|
Details | Diff | Splinter Review |
8.96 KB,
patch
|
jmaher
:
review+
|
Details | Diff | Splinter Review |
1.77 KB,
patch
|
mcote
:
review+
|
Details | Diff | Splinter Review |
this is a bug to manage the merge of devicemanager.py. First round is automation/remote-testing, then mozilla-central.
Attachment #499320 -
Flags: review?(mcote)
Comment 1•14 years ago
|
||
Comment on attachment 499320 [details] [diff] [review]
remote-testing patch for master copy of devicemanager.py (1.0)
>- def launchProcess(self, cmd, outputFile = "process.txt", cwd = ''):
>+ def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = ''):
> cmdline = subprocess.list2cmdline(cmd)
> if (outputFile == "process.txt" or outputFile == None):
> outputFile = self.getDeviceRoot() + '/' + "process.txt"
> cmdline += " > " + outputFile
>+
>+ # Prepend our env to the command
>+ cmdline = ('%s ' % self.formatEnvString(env)) + cmdline
Personally I would have done
cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
since I found yours a bit hard to parse, but not a big deal.
> def poll(self, process):
> try:
>- if (self.processExist(process) == None):
>+ if (self.processExist(process) == ''):
> return None
> return 1
> except:
> return None
> return 1
Hm I noticed that processExist() will still return None if procList == None. processExist() should be fixed to always return the same value on error--if for some reason it fails to get a process list, poll will return 1!
>
> # iterates process list and returns pid if exists, otherwise ''
> def processExist(self, appname):
> pid = ''
>+
>+ #remove the environment variables in the cli if they exist
>+ parts = appname.split(' ')
>+ for p in parts:
>+ if (p is ''):
>+ parts.remove(p)
Why do you hate filter()? :P
>+
>+ if len(parts[0].strip('"').split('=')) > 1:
>+ envvars = parts[0].strip('"').split(',')
>+ for e in envvars:
>+ env = e.split('=')
>+ if (len(env) > 1):
>+ os.environ[env[0]] = str(env[1])
>+ appname = ' '.join(parts[1:])
>+
Uhhh I don't think we should be setting those environment variables locally, unless I'm missing something... please remove or justify.
>+ """
>+ Returns a properly formatted env string for the agent.
>+ Input - env, which is either None, '', or a dict
>+ Output - a quoted string of the form: '"envvar1=val1,envvar2=val2..."'
>+ If env is None or '' return '""' (empty quoted string)
>+ """
>+ def formatEnvString(self, env):
>+ if (env == None or env == ''):
>+ return '""'
>+
>+ envstr = '"'
>+ # TODO: I believe this is inefficient for large dicts
>+ for k, v in env.items():
>+ envstr += ('%s=%s,' % (k, v))
It is inefficient. Prefer env.iteritems().
>+
>+ # kill the trailing comma, add the last quote
>+ envstr = envstr.rstrip(',')
>+ envstr += '"'
>+
>+ return envstr
>+
Actually you can do all of that in one line:
envstr = '"' + ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems())) + '"'
And it eliminates the need to remove the trailing comma. Some people find that a bit hard to read, though I personally love map(), filter(), et al.
Of the above, I think processExist() should really be fixed to return consistent error values, and the os.environ() stuff should be removed. Both easy. Up to you if you want to change anything else.
r+ with those two changes.
Attachment #499320 -
Flags: review?(mcote) → review+
Assignee | ||
Comment 2•14 years ago
|
||
updated patch with all feedback incorporated
Assignee: nobody → jmaher
Attachment #499320 -
Attachment is obsolete: true
Attachment #499337 -
Flags: review+
Assignee | ||
Comment 3•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 4•14 years ago
|
||
updated patch with all devicemanager.py changes to date.
Attachment #499338 -
Flags: review?(ctalbert)
Assignee | ||
Comment 5•14 years ago
|
||
accidentally resolved this, this bug needs to be open for the 3 places devicemanager.py lives.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment on attachment 499338 [details] [diff] [review]
mozilla-central patch for master copy of devicemanager.py (1.0)
This looks good. Should we also take the Reuse socket address that Mark suggested in: https://bugzilla.mozilla.org/show_bug.cgi?id=612792#c6
as well on this patch?
r+ on this existing stuff.
Should we also take Mark's suggestion here, or do we want to go live with this since this is what's currently in production?
Attachment #499338 -
Flags: review?(ctalbert) → review+
Assignee | ||
Comment 7•14 years ago
|
||
updated with socket_reuse and filter(lambda...)
Attachment #499338 -
Attachment is obsolete: true
Attachment #499351 -
Flags: review+
Assignee | ||
Comment 8•14 years ago
|
||
fixed typo, ran manual tests of talos, unittests and a few tests around processExists()
Attachment #499351 -
Attachment is obsolete: true
Assignee | ||
Comment 9•14 years ago
|
||
updated callbackserver to implement reuse_address properly.
Attachment #499356 -
Attachment is obsolete: true
Attachment #499364 -
Flags: review+
Assignee | ||
Comment 10•14 years ago
|
||
second patch to get m-c changes into r-t.
Attachment #499369 -
Flags: review?(mcote)
Comment 11•14 years ago
|
||
Comment on attachment 499369 [details] [diff] [review]
remote-testing patch for master copy of devicemanager.py 2 (1.0)
Yessir, that would be an unconditional r+.
Attachment #499369 -
Flags: review?(mcote) → review+
Assignee | ||
Comment 12•14 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
Updated•7 years ago
|
Component: New Frameworks → General
You need to log in
before you can comment on or make changes to this bug.
Description
•