Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: devil/devil/android/tools/screenshot.py

Issue 2998833002: Revert of [devil] Extract logging common behavior to its own module. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « devil/devil/android/tools/provision_devices.py ('k') | devil/devil/utils/logging_common.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Takes a screenshot from an Android device.""" 6 """Takes a screenshot from an Android device."""
7 7
8 import argparse 8 import argparse
9 import logging 9 import logging
10 import os 10 import os
11 import sys 11 import sys
12 12
13 if __name__ == '__main__': 13 if __name__ == '__main__':
14 sys.path.append(os.path.abspath(os.path.join( 14 sys.path.append(os.path.abspath(os.path.join(
15 os.path.dirname(__file__), '..', '..', '..'))) 15 os.path.dirname(__file__), '..', '..', '..')))
16 from devil.android import device_utils 16 from devil.android import device_utils
17 from devil.android.tools import script_common 17 from devil.android.tools import script_common
18 from devil.utils import logging_common
19 18
20 logger = logging.getLogger(__name__) 19 logger = logging.getLogger(__name__)
21 20
22 21
23 def main(): 22 def main():
24 # Parse options. 23 # Parse options.
25 parser = argparse.ArgumentParser(description=__doc__) 24 parser = argparse.ArgumentParser(description=__doc__)
26 logging_common.AddLoggingArguments(parser)
27 script_common.AddDeviceArguments(parser) 25 script_common.AddDeviceArguments(parser)
28 parser.add_argument('-f', '--file', metavar='FILE', 26 parser.add_argument('-f', '--file', metavar='FILE',
29 help='Save result to file instead of generating a ' 27 help='Save result to file instead of generating a '
30 'timestamped file name.') 28 'timestamped file name.')
29 parser.add_argument('-v', '--verbose', action='store_true',
30 help='Verbose logging.')
31 parser.add_argument('host_file', nargs='?', 31 parser.add_argument('host_file', nargs='?',
32 help='File to which the screenshot will be saved.') 32 help='File to which the screenshot will be saved.')
33 33
34 args = parser.parse_args() 34 args = parser.parse_args()
35
35 host_file = args.host_file or args.file 36 host_file = args.host_file or args.file
36 logging_common.InitializeLogging(args) 37
38 if args.verbose:
39 logging.getLogger().setLevel(logging.DEBUG)
37 40
38 devices = script_common.GetDevices(args.devices, args.blacklist_file) 41 devices = script_common.GetDevices(args.devices, args.blacklist_file)
39 42
40 def screenshot(device): 43 def screenshot(device):
41 f = None 44 f = None
42 if host_file: 45 if host_file:
43 root, ext = os.path.splitext(host_file) 46 root, ext = os.path.splitext(host_file)
44 f = '%s_%s%s' % (root, str(device), ext) 47 f = '%s_%s%s' % (root, str(device), ext)
45 f = device.TakeScreenshot(f) 48 f = device.TakeScreenshot(f)
46 print 'Screenshot for device %s written to %s' % ( 49 print 'Screenshot for device %s written to %s' % (
47 str(device), os.path.abspath(f)) 50 str(device), os.path.abspath(f))
48 51
49 device_utils.DeviceUtils.parallel(devices).pMap(screenshot) 52 device_utils.DeviceUtils.parallel(devices).pMap(screenshot)
50 return 0 53 return 0
51 54
52 55
53 if __name__ == '__main__': 56 if __name__ == '__main__':
54 sys.exit(main()) 57 sys.exit(main())
OLDNEW
« no previous file with comments | « devil/devil/android/tools/provision_devices.py ('k') | devil/devil/utils/logging_common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698