Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

quick panel for selecting between devices, alter config to separate a…

…db loc and args, provide menu option for defining user config
  • Loading branch information...
commit 5a869f2f955ecda88adb5591e3d9122fc1f0e48d 1 parent bd7ae70
@dskinner dskinner authored
Showing with 93 additions and 3 deletions.
  1. +5 −2 ADBView.sublime-settings
  2. +40 −0 Main.sublime-menu
  3. +48 −1 adbview.py
View
7 ADBView.sublime-settings
@@ -1,6 +1,9 @@
{
- //ADB command and arguments that should be used.
- "adb_command": ["adb", "logcat"],
+ //ADB command location.
+ "adb_command": "adb",
+
+ //ADB arguments that should be used.
+ "adb_args": ["logcat"],
//Set to false to disable auto scroll of the ADB view
"adb_auto_scroll": false,
View
40 Main.sublime-menu
@@ -0,0 +1,40 @@
+[
+ {
+ "caption": "Preferences",
+ "mnemonic": "n",
+ "id": "preferences",
+ "children":
+ [
+ {
+ "caption": "Package Settings",
+ "mnemonic": "P",
+ "id": "package-settings",
+ "children":
+ [
+ {
+ "caption": "ADBView",
+ "children":
+ [
+ {
+ "command": "open_file",
+ "args": {"file": "${packages}/ADBView/ADBView.sublime-settings"},
+ "caption": "Settings – Default"
+ },
+ {
+ "command": "open_file",
+ "args": {"file": "${packages}/User/ADBView.sublime-settings"},
+ "caption": "Settings – User"
+ },
+ {
+ "command": "open_file",
+ "args": {"file": "${packages}/ADBView/README.creole"},
+ "caption": "README"
+ },
+ { "caption": "-" }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+]
View
49 adbview.py
@@ -27,6 +27,7 @@
import re
import threading
import traceback
+import telnetlib
def get_settings():
@@ -302,10 +303,56 @@ def is_visible(self):
class AdbLaunch(sublime_plugin.WindowCommand):
def run(self):
+ adb = get_setting("adb_command", "adb")
+ cmd = [adb, "devices"]
+ proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE)
+ out = proc.stdout.read()
+ # get list of device ids
+ self.devices = []
+ for line in out.split("\n"):
+ line = line.strip()
+ if line not in ["", "List of devices attached"]:
+ self.devices.append(re.sub(r"[ \t]*device$", "", line))
+ # build quick menu options displaying name, version, and device id
+ options = []
+ for device in self.devices:
+ # dump build.prop
+ cmd = [adb, "-s", device, "shell", "cat /system/build.prop"]
+ proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE)
+ build_prop = proc.stdout.read().strip()
+ # get name
+ product = "Unknown" # should never actually see this
+ if device.startswith("emulator"):
+ port = device.rsplit("-")[-1]
+ t = telnetlib.Telnet("localhost", port)
+ t.read_until("OK", 1000)
+ t.write("avd name\n")
+ product = t.read_until("OK", 1000)
+ t.close()
+ product = product.replace("OK", "").strip()
+ else:
+ product = re.findall(r"^ro\.product\.model=(.*)$", build_prop, re.MULTILINE)
+ if product:
+ product = product[0]
+ # get version
+ version = re.findall(r"ro\.build\.version\.release=(.*)$", build_prop, re.MULTILINE)
+ if version:
+ version = version[0]
+ else:
+ version = "x.x.x"
+ options.append("%s %s - %s" % (product, version, device))
+ self.window.show_quick_panel(options, self.on_done)
+
+ def on_done(self, picked):
+ if picked == -1:
+ return
+ device = self.devices[picked]
global adb_process
if adb_process != None and adb_process.poll() == None:
adb_process.kill()
- cmd = get_setting("adb_command", ["adb", "logcat"])
+ adb = get_setting("adb_command", "adb")
+ args = get_setting("adb_args", ["logcat"])
+ cmd = [adb, "-s", device] + args
print "running: %s" % cmd
adb_process = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE)
adb_view.open()
Please sign in to comment.
Something went wrong with that request. Please try again.