Closed Bug 854525 Opened 11 years ago Closed 11 years ago

dm utility should support more devicemanager features

Categories

(Testing :: Mozbase, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Assigned: dminor)

Details

(Whiteboard: [good-first-bug][lang=python][mentor=wlach][mobile])

Attachments

(1 file, 1 obsolete file)

:mcote and I have been adding stuff to the dm utility for interacting with android/b2g devices piecemeal, but it probably makes sense to just add a bunch of stuff that would be useful all at once. Here's the extra commands that (offhand) I would like to see the "dm" utility support:

* reboot (https://mozbase.readthedocs.org/en/latest/mozdevice.html#mozdevice.DeviceManager.reboot)
* clearlogcat (use https://mozbase.readthedocs.org/en/latest/mozdevice.html#mozdevice.DeviceManager.recordLogcat)
* isfile (use https://mozbase.readthedocs.org/en/latest/mozdevice.html#mozdevice.DeviceManager.fileExists)
* launchfennec (use https://mozbase.readthedocs.org/en/latest/mozdevice.html#mozdevice.DroidADB.launchFennec)

For more information on the dm client see here:

http://wrla.ch/blog/2012/10/using-the-dm-utility-to-interact-with-android-or-firefoxos-devices/

The source lives in mozbase under mozdevice:

https://github.com/mozilla/mozbase/blob/master/mozdevice/mozdevice/dmcli.py

For information on contributing to mozbase see here:

https://wiki.mozilla.org/Auto-tools/Projects/MozBase

This is not especially urgent so I thought I'd add it as a good first bug. :) Please only take this bug if you have an Android device to test with and can get as far as running some basic commands using the utility on mozbase following the instructions above.
Assignee: nobody → dminor
Attached patch Initial implementation (obsolete) — Splinter Review
I've added the functions in the bug report and one more. It would be great to have feedback on what I've done so far and whether there is anything else that would be good to include.
Attachment #732868 - Flags: feedback?(wlachance)
Comment on attachment 732868 [details] [diff] [review]
Initial implementation

A few minor issues but in general looking good. If you can clean up the issues mentioned below, feel free to submit another patch and mark it as r?.

>+                          'clearlogcat': { 'function': lambda : self.dm.recordLogcat(),
>+                                      'min_args': 0,
>+                                      'max_args': 0,
>+                                      'help_args': '',
>+                                      'help': 'clear the logcat'
>+                                   },
>+                          'reboot': { 'function': self.reboot,
>+                                      'min_args': 0,
>+                                      'max_args': 2,
>+                                      'help_args': '[ipaddr] [port]',
>+                                      'help': 'reboot the device, optionally waiting for confirmation that it has rebooted'
>+                                   },

I don't think we want to expose ipaddr and port as arguments here, as that's an internal implementation detail. I guess we could add a rebootandwait command to reboot and wait for things to startup again.

(maximally preferable would be to be able to specify optional modifiers to individual commands, so we could do things like "dm reboot --wait", but that would require a pretty extensive rework of our command line parsing)

> 
>@@ -299,6 +329,31 @@ class DMCli(object):
>         else:
>             print 'Must use SUT transport to get SUT version.'
> 
>+    def reboot(self, *args):
>+        self.dm.reboot(*args)
>+
>+    def isfile(self, path):
>+        if self.dm.fileExists(path):
>+            print "TRUE"
>+            return 0
>+        print "FALSE"
>+        return errno.ENOENT
>+
>+    def launchfennec(self, appName, *args):
>+        try:
>+            self.dm.launchFennec(appName, *args)
>+        except mozdevice.DMError as err:
>+            print('error: ' + str(err))
>+
>+    def getip(self, *args):
>+        if args:
>+            try:  
>+                print(self.dm.getIP(list(args)))
>+            except mozdevice.DMError as err:
>+                print('error: ' + str(err))

I don't think we need/want to catch exceptions from commands. Better to just let things bubble up and get a noisy error and backtrace.
Attachment #732868 - Flags: feedback?(wlachance) → feedback+
Attached patch Revised patchSplinter Review
Revised as suggested. The reboot and wait didn't work with my panda, so I've left that out for now. Thanks.
Attachment #732868 - Attachment is obsolete: true
Attachment #732890 - Flags: review?(wlachance)
Comment on attachment 732890 [details] [diff] [review]
Revised patch

LGTM
Attachment #732890 - Flags: review?(wlachance) → review+
https://github.com/mozilla/mozbase/commit/602059a72763e53338def08dbea05ce714c26439
Status: NEW → RESOLVED
Closed: 11 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: