Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions b2g_js/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
import os
import codecs
import re
import subprocess

from marionette import Marionette


class CmdDispatcher(object):

_MSG_NO_CMD = 'No such command.'
_CMD_HELP = ':h'

_CMD_EXIT = ':q'
_CMD_WRITE_SOURCE_TO_FILE = ':w'
_CMD_SWITCH_SYNC_ASYNC = ':s'
_CMD_HELP = ':h'
_CMD_IMPORT_JS_COMPONENT = ':i'
_CMD_LAST_MARIONETTE_LOG = ':m'
_CMD_LIST_FRAMES = ':l'
_CMD_OPEN_FRAME = ':o'
_CMD_SWITCH_SYNC_ASYNC = ':s'
_CMD_WRITE_SOURCE_TO_FILE = ':w'

def __init__(self, runner, command):
self.super_runner = runner
Expand Down Expand Up @@ -61,6 +64,13 @@ def __call__(self):
else:
OpenFrameCmd(self.m, self.super_runner)

elif self.command.lower().startswith(self._CMD_LAST_MARIONETTE_LOG):
args = self.command.split()
if len(args) > 1:
ListLastMarionetteLog(args[1])
else:
ListLastMarionetteLog()

else:
print self._MSG_NO_CMD, self.command

Expand All @@ -70,8 +80,8 @@ def __init__(self):
self()

def __call__(self):
output_head_format = '{0:12s}{1:s}'
output_format = '{0:2s} {1:8s} {2:s}'
output_head_format = '{0:13s}{1:s}'
output_format = '{0:2s} {1:9s} {2:s}'
print output_head_format.format('#Commands', '#Description')
print output_format.format(CmdDispatcher._CMD_HELP, '', 'Print usage.')
print output_format.format(CmdDispatcher._CMD_EXIT, '', 'Exit.')
Expand All @@ -81,6 +91,7 @@ def __call__(self):
print output_format.format(CmdDispatcher._CMD_IMPORT_JS_COMPONENT, '<FILE>', 'Import javascript from file. List all components if no <FILE>.')
print output_format.format(CmdDispatcher._CMD_LIST_FRAMES, '', 'List all apps of b2g instance.')
print output_format.format(CmdDispatcher._CMD_OPEN_FRAME, '<KEYWORD>', 'Connect to the App iframe. Using # ID or App_URL as <KEYWORD>.')
print output_format.format(CmdDispatcher._CMD_LAST_MARIONETTE_LOG, '<LINES>', 'Print out last few lines of marionette log information.')
print output_format.format('', 'exit', 'Exit.')


Expand Down Expand Up @@ -180,3 +191,11 @@ def __call__(self):
pass
else:
self.runner.open_app(-1)

class ListLastMarionetteLog(object):
def __init__(self, number=5):
self.number = number
self()

def __call__(self):
print subprocess.Popen("adb logcat -d | grep \"MARIONETTE LOG\" |tail -" + str(self.number), stdout=subprocess.PIPE, shell=True).stdout.read()
8 changes: 4 additions & 4 deletions b2g_js/js_component/gaia_event_listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

function sniffer (e) {
function sniffer(e) {
var el = e.target;
var info = "\n";
info += "\tnodeName: " + el.nodeName + "\n";
Expand All @@ -19,13 +19,13 @@ function sniffer (e) {
for (var i = 0 ; i < attr.length ; i++) {
info += "\t->" + attr[i].name + "/" + attr[i].value + "\n";
}
console.log(info);
log(info);
}

function movesniffer(e) {
var touches = e.changedTouches;
for (var i = 0 ; i < touches.length ; i++) {
console.log("Touch Moves from " + touches[i].pageX + " " + touches[i].pageY);
log("Touch Moves from " + touches[i].pageX + " " + touches[i].pageY);
}
}

Expand All @@ -50,7 +50,7 @@ var GaiaEventListener = {
},

test: function() {
console.log("test SUCESSFULLY!!!!");
log("test SUCESSFULLY!!!!");
}

};