Remove scripts that haven't yet been updated for python3.
That seems like a sign none of these are used. (Two of them haven't been touched since their initial import in 2009!) Test: treehugger Change-Id: I76042f6c8fab84669c83aa72cd0b5df13f01ed7c
This commit is contained in:
@@ -1,131 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2008 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
A faux Setup Wizard. Stuffs one or two usernames + passwords into the
|
||||
database on the device.
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.hexversion < 0x02040000:
|
||||
print "This script requires python 2.4 or higher."
|
||||
sys.exit(1)
|
||||
|
||||
import getpass
|
||||
import subprocess
|
||||
import time
|
||||
import sha
|
||||
|
||||
DB = "/data/data/com.google.android.googleapps/databases/accounts.db"
|
||||
|
||||
def RunCmd(args):
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
out = proc.stdout.read()
|
||||
if proc.wait():
|
||||
print
|
||||
print "failed: %s" % " ".join(args)
|
||||
return None
|
||||
return out
|
||||
|
||||
def GetProp(adb_flags, name):
|
||||
args = ("adb",) + adb_flags + ("shell", "su", "root",
|
||||
"/system/bin/getprop", name)
|
||||
return RunCmd(args)
|
||||
|
||||
def SetProp(adb_flags, name, value):
|
||||
args = ("adb",) + adb_flags + ("shell", "su", "root",
|
||||
"/system/bin/setprop", name, value)
|
||||
return RunCmd(args)
|
||||
|
||||
def DbExists(adb_flags):
|
||||
args = ("adb",) + adb_flags + ("shell", "su", "root",
|
||||
"/system/bin/ls", DB)
|
||||
result = RunCmd(args)
|
||||
if result is None: return None
|
||||
return "No such file" not in result
|
||||
|
||||
def main(argv):
|
||||
if len(argv) == 1:
|
||||
print ("usage: %s [adb flags] "
|
||||
"[<dasher address[:password]>] "
|
||||
"[<gmail address[:password]>]") % (argv[0],)
|
||||
sys.exit(2)
|
||||
|
||||
argv = argv[1:]
|
||||
|
||||
gmail = None
|
||||
dasher = None
|
||||
while argv and "@" in argv[-1]:
|
||||
addr = argv.pop()
|
||||
if "@gmail.com" in addr or "@googlemail.com" in addr:
|
||||
gmail = addr
|
||||
else:
|
||||
dasher = addr
|
||||
|
||||
adb_flags = tuple(argv)
|
||||
|
||||
while True:
|
||||
db = DbExists(adb_flags)
|
||||
if db is None:
|
||||
print "failed to contact device; will retry in 3 seconds"
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
if db:
|
||||
print
|
||||
print "GoogleLoginService has already started on this device;"
|
||||
print "it's too late to use this script to add accounts."
|
||||
print
|
||||
print "This script only works on a freshly-wiped device (or "
|
||||
print "emulator) while booting for the first time."
|
||||
print
|
||||
break
|
||||
|
||||
hosted_account = GetProp(adb_flags, "ro.config.hosted_account").strip()
|
||||
google_account = GetProp(adb_flags, "ro.config.google_account").strip()
|
||||
|
||||
if dasher and hosted_account:
|
||||
print
|
||||
print "A dasher account is already configured on this device;"
|
||||
print "can't add", hosted_account
|
||||
print
|
||||
dasher = None
|
||||
|
||||
if gmail and google_account:
|
||||
print
|
||||
print "A google account is already configured on this device;"
|
||||
print "can't add", google_account
|
||||
print
|
||||
gmail = None
|
||||
|
||||
if not gmail and not dasher: break
|
||||
|
||||
if dasher:
|
||||
SetProp(adb_flags, "ro.config.hosted_account", dasher)
|
||||
print "set hosted_account to", dasher
|
||||
if gmail:
|
||||
SetProp(adb_flags, "ro.config.google_account", gmail)
|
||||
print "set google_account to", gmail
|
||||
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
@@ -1,128 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2008 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
A faux Setup Wizard. Stuffs one or two usernames + passwords into the
|
||||
database on the device.
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.hexversion < 0x02040000:
|
||||
print "This script requires python 2.4 or higher."
|
||||
sys.exit(1)
|
||||
|
||||
import getpass
|
||||
import subprocess
|
||||
import time
|
||||
import sha
|
||||
|
||||
DB = "/data/data/com.google.android.googleapps/databases/accounts.db"
|
||||
|
||||
def RunCmd(args):
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
out = proc.stdout.read()
|
||||
if proc.wait():
|
||||
print
|
||||
print "failed: %s" % " ".join(args)
|
||||
return None
|
||||
return out
|
||||
|
||||
def GetProp(adb_flags, name):
|
||||
args = ("adb",) + adb_flags + ("shell", "/system/bin/getprop", name)
|
||||
return RunCmd(args)
|
||||
|
||||
def SetProp(adb_flags, name, value):
|
||||
args = ("adb",) + adb_flags + ("shell", "/system/bin/setprop", name, value)
|
||||
return RunCmd(args)
|
||||
|
||||
def DbExists(adb_flags):
|
||||
args = ("adb",) + adb_flags + ("shell", "/system/bin/ls", DB)
|
||||
result = RunCmd(args)
|
||||
if result is None: return None
|
||||
return "No such file" not in result
|
||||
|
||||
def main(argv):
|
||||
if len(argv) == 1:
|
||||
print ("usage: %s [adb flags] "
|
||||
"[<hosted address[:password]>] "
|
||||
"[<gmail address[:password]>]") % (argv[0],)
|
||||
sys.exit(2)
|
||||
|
||||
argv = argv[1:]
|
||||
|
||||
gmail = None
|
||||
hosted = None
|
||||
while argv and "@" in argv[-1]:
|
||||
addr = argv.pop()
|
||||
if "@gmail.com" in addr or "@googlemail.com" in addr:
|
||||
gmail = addr
|
||||
else:
|
||||
hosted = addr
|
||||
|
||||
adb_flags = tuple(argv)
|
||||
|
||||
while True:
|
||||
db = DbExists(adb_flags)
|
||||
if db is None:
|
||||
print "failed to contact device; will retry in 3 seconds"
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
if db:
|
||||
print
|
||||
print "GoogleLoginService has already started on this device;"
|
||||
print "it's too late to use this script to add accounts."
|
||||
print
|
||||
print "This script only works on a freshly-wiped device (or "
|
||||
print "emulator) while booting for the first time."
|
||||
print
|
||||
break
|
||||
|
||||
hosted_account = GetProp(adb_flags, "ro.config.hosted_account").strip()
|
||||
google_account = GetProp(adb_flags, "ro.config.google_account").strip()
|
||||
|
||||
if hosted and hosted_account:
|
||||
print
|
||||
print "A hosted account is already configured on this device;"
|
||||
print "can't add", hosted_account
|
||||
print
|
||||
hosted = None
|
||||
|
||||
if gmail and google_account:
|
||||
print
|
||||
print "A google account is already configured on this device;"
|
||||
print "can't add", google_account
|
||||
print
|
||||
gmail = None
|
||||
|
||||
if not gmail and not hosted: break
|
||||
|
||||
if hosted:
|
||||
SetProp(adb_flags, "ro.config.hosted_account", hosted)
|
||||
print "set hosted_account to", hosted
|
||||
if gmail:
|
||||
SetProp(adb_flags, "ro.config.google_account", gmail)
|
||||
print "set google_account to", gmail
|
||||
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2013 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""summarize and compare the component sizes in installed-files.txt."""
|
||||
|
||||
import sys
|
||||
|
||||
bin_size1 = {}
|
||||
bin_size2 = {}
|
||||
bin_sizes = [bin_size1, bin_size2]
|
||||
|
||||
file_sizes = {}
|
||||
|
||||
def PrintUsage():
|
||||
print "usage: " + sys.argv[0] + " filename [filename2]"
|
||||
print ""
|
||||
print " Input file is installed-files.txt from the build output directory."
|
||||
print " When only one input file is given, it will generate module_0.csv."
|
||||
print " When two input files are given, in addition it will generate"
|
||||
print " module_1.csv and comparison.csv."
|
||||
print ""
|
||||
print " The module_x.csv file shows the aggregated file size in each module"
|
||||
print " (eg bin, lib, app, ...)"
|
||||
print " The comparison.cvs file shows the individual file sizes side by side"
|
||||
print " from two different builds"
|
||||
print ""
|
||||
print " These files can be uploaded to Google Doc for further processing."
|
||||
sys.exit(1)
|
||||
|
||||
def ParseFile(install_file, idx):
|
||||
input_stream = open(install_file, 'r')
|
||||
for line in input_stream:
|
||||
# line = "25027208 /system/lib/libchromeview.so"
|
||||
line = line.strip()
|
||||
|
||||
# size = "25027208", name = "/system/lib/libchromeview.so"
|
||||
size, name = line.split()
|
||||
|
||||
# components = ["", "system", "lib", "libchromeview.so"]
|
||||
components = name.split('/')
|
||||
|
||||
# module = "lib"
|
||||
module = components[2]
|
||||
|
||||
# filename = libchromeview.so"
|
||||
filename = components[-1]
|
||||
|
||||
# sum up the file sizes by module name
|
||||
if module not in bin_sizes[idx]:
|
||||
bin_sizes[idx][module] = int(size)
|
||||
else:
|
||||
bin_sizes[idx][module] += int(size)
|
||||
|
||||
# sometimes a file only exists on one build but not the other - use 0 as the
|
||||
# default size.
|
||||
if idx == 0:
|
||||
file_sizes[name] = [module, size, 0]
|
||||
else:
|
||||
if name in file_sizes:
|
||||
file_sizes[name][-1] = size
|
||||
else:
|
||||
file_sizes[name] = [module, 0, size]
|
||||
|
||||
input_stream.close()
|
||||
|
||||
# output the module csv file
|
||||
output = open("module_%d.csv" % idx, 'w')
|
||||
total = 0
|
||||
for key in bin_sizes[idx]:
|
||||
output.write("%s, %d\n" % (key, bin_sizes[idx][key]))
|
||||
output.close()
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2 or len(sys.argv) > 3:
|
||||
PrintUsage()
|
||||
# Parse the first installed-files.txt
|
||||
ParseFile(sys.argv[1], 0)
|
||||
|
||||
# Parse the second installed-files.txt
|
||||
if len(sys.argv) == 3:
|
||||
ParseFile(sys.argv[2], 1)
|
||||
# comparison.csv has the following columns:
|
||||
# filename, module, size1, size2, size2-size1
|
||||
# eg: /system/lib/libchromeview.so, lib, 25027208, 33278460, 8251252
|
||||
output = open("comparison.csv", 'w')
|
||||
for key in file_sizes:
|
||||
output.write("%s, %s, %s, %s, %d\n" %
|
||||
(key, file_sizes[key][0], file_sizes[key][1],
|
||||
file_sizes[key][2],
|
||||
int(file_sizes[key][2]) - int(file_sizes[key][1])))
|
||||
output.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
# vi: ts=2 sw=2
|
||||
@@ -1,172 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (C) 2016 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Reset a USB device (presumbly android phone) by serial number.
|
||||
|
||||
Given a serial number, inspects connected USB devices and issues USB
|
||||
reset to the one that matches. Python version written by Than
|
||||
McIntosh, based on a perl version from Chris Ferris. Intended for use
|
||||
on linux.
|
||||
|
||||
"""
|
||||
|
||||
import fcntl
|
||||
import getopt
|
||||
import locale
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Serial number of device that we want to reset
|
||||
flag_serial = None
|
||||
|
||||
# Debugging verbosity level (0 -> no output)
|
||||
flag_debug = 0
|
||||
|
||||
USBDEVFS_RESET = ord("U") << (4*2) | 20
|
||||
|
||||
|
||||
def verbose(level, msg):
|
||||
"""Print debug trace output of verbosity level is >= value in 'level'."""
|
||||
if level <= flag_debug:
|
||||
sys.stderr.write(msg + "\n")
|
||||
|
||||
|
||||
def increment_verbosity():
|
||||
"""Increment debug trace level by 1."""
|
||||
global flag_debug
|
||||
flag_debug += 1
|
||||
|
||||
|
||||
def issue_ioctl_to_device(device):
|
||||
"""Issue USB reset ioctl to device."""
|
||||
|
||||
try:
|
||||
fd = open(device, "wb")
|
||||
except IOError as e:
|
||||
error("unable to open device %s: "
|
||||
"%s" % (device, e.strerror))
|
||||
verbose(1, "issuing USBDEVFS_RESET ioctl() to %s" % device)
|
||||
fcntl.ioctl(fd, USBDEVFS_RESET, 0)
|
||||
fd.close()
|
||||
|
||||
|
||||
# perform default locale setup if needed
|
||||
def set_default_lang_locale():
|
||||
if "LANG" not in os.environ:
|
||||
warning("no env setting for LANG -- using default values")
|
||||
os.environ["LANG"] = "en_US.UTF-8"
|
||||
os.environ["LANGUAGE"] = "en_US:"
|
||||
|
||||
|
||||
def warning(msg):
|
||||
"""Issue a warning to stderr."""
|
||||
sys.stderr.write("warning: " + msg + "\n")
|
||||
|
||||
|
||||
def error(msg):
|
||||
"""Issue an error to stderr, then exit."""
|
||||
sys.stderr.write("error: " + msg + "\n")
|
||||
exit(1)
|
||||
|
||||
|
||||
# invoke command, returning array of lines read from it
|
||||
def docmdlines(cmd, nf=None):
|
||||
"""Run a command via subprocess, returning output as an array of lines."""
|
||||
verbose(2, "+ docmdlines executing: %s" % cmd)
|
||||
args = shlex.split(cmd)
|
||||
mypipe = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
encoding = locale.getdefaultlocale()[1]
|
||||
pout, perr = mypipe.communicate()
|
||||
if mypipe.returncode != 0:
|
||||
if perr:
|
||||
decoded_err = perr.decode(encoding)
|
||||
warning(decoded_err)
|
||||
if nf:
|
||||
return None
|
||||
error("command failed (rc=%d): cmd was %s" % (mypipe.returncode, args))
|
||||
decoded = pout.decode(encoding)
|
||||
lines = decoded.strip().split("\n")
|
||||
return lines
|
||||
|
||||
|
||||
def perform():
|
||||
"""Main driver routine."""
|
||||
lines = docmdlines("usb-devices")
|
||||
dmatch = re.compile(r"^\s*T:\s*Bus\s*=\s*(\d+)\s+.*\s+Dev#=\s*(\d+).*$")
|
||||
smatch = re.compile(r"^\s*S:\s*SerialNumber=(.*)$")
|
||||
device = None
|
||||
found = False
|
||||
for line in lines:
|
||||
m = dmatch.match(line)
|
||||
if m:
|
||||
p1 = int(m.group(1))
|
||||
p2 = int(m.group(2))
|
||||
device = "/dev/bus/usb/%03d/%03d" % (p1, p2)
|
||||
verbose(1, "setting device: %s" % device)
|
||||
continue
|
||||
m = smatch.match(line)
|
||||
if m:
|
||||
ser = m.group(1)
|
||||
if ser == flag_serial:
|
||||
verbose(0, "matched serial %s to device "
|
||||
"%s, invoking reset" % (ser, device))
|
||||
issue_ioctl_to_device(device)
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
error("unable to locate device with serial number %s" % flag_serial)
|
||||
|
||||
|
||||
def usage(msgarg):
|
||||
"""Print usage and exit."""
|
||||
if msgarg:
|
||||
sys.stderr.write("error: %s\n" % msgarg)
|
||||
print """\
|
||||
usage: %s [options] XXYYZZ
|
||||
|
||||
where XXYYZZ is the serial number of a connected Android device.
|
||||
|
||||
options:
|
||||
-d increase debug msg verbosity level
|
||||
|
||||
""" % os.path.basename(sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""Command line argument parsing."""
|
||||
global flag_serial
|
||||
|
||||
try:
|
||||
optlist, args = getopt.getopt(sys.argv[1:], "d")
|
||||
except getopt.GetoptError as err:
|
||||
# unrecognized option
|
||||
usage(str(err))
|
||||
if not args or len(args) != 1:
|
||||
usage("supply a single device serial number as argument")
|
||||
flag_serial = args[0]
|
||||
|
||||
for opt, _ in optlist:
|
||||
if opt == "-d":
|
||||
increment_verbosity()
|
||||
|
||||
|
||||
set_default_lang_locale()
|
||||
parse_args()
|
||||
perform()
|
||||
Reference in New Issue
Block a user