Home | History | Annotate | Download | only in script
      1 #!/usr/bin/env python
      2 #
      3 # Copyright 2017 - The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #     http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 #
     17 
     18 import datetime
     19 import platform
     20 import subprocess
     21 import sys
     22 
     23 
     24 def runCommand(cmd, description):
     25     """Runs given command, then prints output and error.
     26 
     27     Args:
     28         cmd: string, command to execute
     29         description: string, noun that describes the output of the command
     30     """
     31     print '=====', description, '====='
     32 
     33     returnCode = subprocess.call(cmd.split(' '))
     34     if returnCode != 0:
     35         print 'Error occured when executing following command:', cmd
     36         print 'Error code:', returnCode
     37 
     38 def main():
     39     # Get current date and time
     40     now = datetime.datetime.now()
     41     print '===== Current date and time =====\n', str(now)
     42     print '===== OS version =====\n', platform.platform()
     43     print '===== Python version =====\n', sys.version
     44 
     45     # Get pip version
     46     runCommand('pip --version', 'Pip version')
     47 
     48     # Get virtualenv version
     49     runCommand('virtualenv --version', 'Virtualenv version')
     50 
     51     # Get target device info with adb
     52     runCommand('adb shell getprop ro.build.fingerprint', 'Target device info [ro.build.fingerprint]')
     53 
     54 
     55 if __name__ == "__main__":
     56     main()
     57