Home | History | Annotate | Download | only in scripts
      1 #!/usr/bin/env monkeyrunner
      2 # Copyright 2010, The Android Open Source Project
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #     http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 from com.android.monkeyrunner import MonkeyRunner as mr
     16 
     17 import os
     18 import sys
     19 
     20 supported_formats = ['html', 'text', 'sdk-docs']
     21 
     22 if len(sys.argv) != 3:
     23   print 'help.py: format output'
     24   sys.exit(1)
     25 
     26 (format, saveto_path) = sys.argv[1:]
     27 
     28 if not format.lower() in supported_formats:
     29   print 'format %s is not a supported format' % format
     30   sys.exit(2)
     31 
     32 output = mr.help(format=format)
     33 if not output:
     34   print 'Error generating help format'
     35   sys.exit(3)
     36 
     37 dirname = os.path.dirname(saveto_path)
     38 try:
     39     os.makedirs(dirname)
     40 except:
     41     print 'oops'
     42     pass # It already existed
     43 
     44 fp = open(saveto_path, 'w')
     45 fp.write(output)
     46 fp.close()
     47 
     48 sys.exit(0)
     49