dm utility should support more devicemanager features



5 years ago
5 years ago


(Reporter: wlach, Assigned: dminor)



Firefox Tracking Flags

(Not tracked)


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


(1 attachment, 1 obsolete attachment)

: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 (
* clearlogcat (use
* isfile (use
* launchfennec (use

For more information on the dm client see here:

The source lives in mozbase under mozdevice:

For information on contributing to mozbase see here:

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.


5 years ago
Assignee: nobody → dminor

Comment 1

5 years ago
Created attachment 732868 [details] [diff] [review]
Initial implementation

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 :,
>+                                      '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):
>+    def isfile(self, path):
>+        if
>+            print "TRUE"
>+            return 0
>+        print "FALSE"
>+        return errno.ENOENT
>+    def launchfennec(self, appName, *args):
>+        try:
>+  , *args)
>+        except mozdevice.DMError as err:
>+            print('error: ' + str(err))
>+    def getip(self, *args):
>+        if args:
>+            try:  
>+                print(
>+            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+

Comment 3

5 years ago
Created attachment 732890 [details] [diff] [review]
Revised patch

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

Attachment #732890 - Flags: review?(wlachance) → review+

Comment 5

5 years ago
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.