Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Tool for manipulating naclports packages in python. | 5 """Tool for manipulating naclports packages in python. |
| 6 | 6 |
| 7 This tool can be used to for working with naclports packages. | 7 This tool can be used to for working with naclports packages. |
| 8 It can also be incorporated into other tools that need to | 8 It can also be incorporated into other tools that need to |
| 9 work with packages (e.g. 'update_mirror.py' uses it to iterate | 9 work with packages (e.g. 'update_mirror.py' uses it to iterate |
| 10 through all packages and mirror them on Google Cloud Storage). | 10 through all packages and mirror them on Google Cloud Storage). |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 if package.VERSION not in package.URL: | 90 if package.VERSION not in package.URL: |
| 91 PrintError('%s: uscan only works if VERSION is embedded in URL' % | 91 PrintError('%s: uscan only works if VERSION is embedded in URL' % |
| 92 package.NAME) | 92 package.NAME) |
| 93 return 0 | 93 return 0 |
| 94 | 94 |
| 95 temp_fd, temp_file = tempfile.mkstemp('naclports_watchfile') | 95 temp_fd, temp_file = tempfile.mkstemp('naclports_watchfile') |
| 96 try: | 96 try: |
| 97 with os.fdopen(temp_fd, 'w') as f: | 97 with os.fdopen(temp_fd, 'w') as f: |
| 98 uscan_url = package.URL.replace(package.VERSION, '(.+)') | 98 uscan_url = package.URL.replace(package.VERSION, '(.+)') |
| 99 uscan_url = uscan_url.replace('download.sf.net', 'sf.net') | 99 uscan_url = uscan_url.replace('download.sf.net', 'sf.net') |
| 100 util.Trace('uscan pattern: %s' % uscan_url) | 100 util.LogVerbose('uscan pattern: %s' % uscan_url) |
| 101 f.write("version = 3\n") | 101 f.write("version = 3\n") |
| 102 f.write("%s\n" % uscan_url) | 102 f.write("%s\n" % uscan_url) |
| 103 | 103 |
| 104 cmd = ['uscan', '--upstream-version', package.VERSION, '--package', | 104 cmd = ['uscan', '--upstream-version', package.VERSION, '--package', |
| 105 package.NAME, '--watchfile', temp_file] | 105 package.NAME, '--watchfile', temp_file] |
| 106 util.Trace(' '.join(cmd)) | 106 util.LogVerbose(' '.join(cmd)) |
| 107 rtn = subprocess.call(cmd) | 107 rtn = subprocess.call(cmd) |
| 108 finally: | 108 finally: |
| 109 os.remove(temp_file) | 109 os.remove(temp_file) |
| 110 | 110 |
| 111 return rtn | 111 return rtn |
| 112 | 112 |
| 113 | 113 |
| 114 def CmdPkgCheck(package, options): | 114 def CmdPkgCheck(package, options): |
| 115 """Verify dependency information for given package(s)""" | 115 """Verify dependency information for given package(s)""" |
| 116 # The fact that we got this far means the pkg_info is basically valid. | 116 # The fact that we got this far means the pkg_info is basically valid. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 installed_pkg_commands = ['contents', 'uninstall'] | 207 installed_pkg_commands = ['contents', 'uninstall'] |
| 208 | 208 |
| 209 all_commands = dict(base_commands.items() + pkg_commands.items()) | 209 all_commands = dict(base_commands.items() + pkg_commands.items()) |
| 210 | 210 |
| 211 epilog = "The following commands are available:\n" | 211 epilog = "The following commands are available:\n" |
| 212 for name, function in all_commands.iteritems(): | 212 for name, function in all_commands.iteritems(): |
| 213 epilog += ' %-12s - %s\n' % (name, function.__doc__) | 213 epilog += ' %-12s - %s\n' % (name, function.__doc__) |
| 214 | 214 |
| 215 parser = argparse.ArgumentParser(prog='naclports', description=__doc__, | 215 parser = argparse.ArgumentParser(prog='naclports', description=__doc__, |
| 216 formatter_class=argparse.RawDescriptionHelpFormatter, epilog=epilog) | 216 formatter_class=argparse.RawDescriptionHelpFormatter, epilog=epilog) |
| 217 parser.add_argument('-v', '--verbose', action='store_true', | 217 parser.add_argument('-v', '--verbose', dest='verbosity', action='count', |
| 218 help='Output extra information.') | 218 default=0, help='Output extra information.') |
| 219 parser.add_argument('-V', '--verbose-build', action='store_true', | 219 parser.add_argument('-V', '--verbose-build', action='store_true', |
| 220 help='Make builds verbose (e.g. pass V=1 to make') | 220 help='Make builds verbose (e.g. pass V=1 to make') |
| 221 parser.add_argument('--skip-sdk-version-check', action='store_true', | 221 parser.add_argument('--skip-sdk-version-check', action='store_true', |
| 222 help="Disable the NaCl SDK version check on startup.") | 222 help="Disable the NaCl SDK version check on startup.") |
| 223 parser.add_argument('--all', action='store_true', | 223 parser.add_argument('--all', action='store_true', |
| 224 help='Perform action on all known ports.') | 224 help='Perform action on all known ports.') |
| 225 parser.add_argument('--color', choices=('always', 'never', 'auto'), | 225 parser.add_argument('--color', choices=('always', 'never', 'auto'), |
| 226 help='Enabled color terminal output', default='auto') | 226 help='Enabled color terminal output', default='auto') |
| 227 parser.add_argument('-f', '--force', action='store_const', const='build', | 227 parser.add_argument('-f', '--force', action='store_const', const='build', |
| 228 help='Force building specified targets, ' | 228 help='Force building specified targets, ' |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 249 # environment variable. | 249 # environment variable. |
| 250 parser.add_argument('--debug', action='store_const', const=True, | 250 parser.add_argument('--debug', action='store_const', const=True, |
| 251 help='Build debug configuration (release is the default)') | 251 help='Build debug configuration (release is the default)') |
| 252 parser.add_argument('--arch', | 252 parser.add_argument('--arch', |
| 253 help='Set architecture to use when building (x86_64,' | 253 help='Set architecture to use when building (x86_64,' |
| 254 ' x86_32, arm, pnacl)') | 254 ' x86_32, arm, pnacl)') |
| 255 parser.add_argument('command', help="sub-command to run") | 255 parser.add_argument('command', help="sub-command to run") |
| 256 parser.add_argument('pkg', nargs='*', help="package name or directory") | 256 parser.add_argument('pkg', nargs='*', help="package name or directory") |
| 257 args = parser.parse_args(args) | 257 args = parser.parse_args(args) |
| 258 | 258 |
| 259 util.SetVerbose(args.verbose or os.environ.get('VERBOSE') == '1') | 259 if not args.verbosity and os.environ.get('VERBOSE') == '1': |
| 260 args.verbosity = 1 | |
| 261 | |
| 262 util.SetLogLevel(util.LOG_MESSAGE + args.verbosity) | |
|
binji
2015/03/17 19:28:11
LOG_MESSAGE makes it sound like a string. Maybe LO
| |
| 263 | |
| 260 if args.verbose_build: | 264 if args.verbose_build: |
| 261 os.environ['VERBOSE'] = '1' | 265 os.environ['VERBOSE'] = '1' |
| 262 else: | 266 else: |
| 263 if 'VERBOSE' in os.environ: | 267 if 'VERBOSE' in os.environ: |
| 264 del os.environ['VERBOSE'] | 268 del os.environ['VERBOSE'] |
| 265 if 'V' in os.environ: | 269 if 'V' in os.environ: |
| 266 del os.environ['V'] | 270 del os.environ['V'] |
| 267 | 271 |
| 268 if args.skip_sdk_version_check: | 272 if args.skip_sdk_version_check: |
| 269 util.MIN_SDK_VERSION = -1 | 273 util.MIN_SDK_VERSION = -1 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 return 1 | 333 return 1 |
| 330 except error.Error as e: | 334 except error.Error as e: |
| 331 PrintError(str(e)) | 335 PrintError(str(e)) |
| 332 return 1 | 336 return 1 |
| 333 | 337 |
| 334 return 0 | 338 return 0 |
| 335 | 339 |
| 336 | 340 |
| 337 if __name__ == '__main__': | 341 if __name__ == '__main__': |
| 338 sys.exit(main(sys.argv[1:])) | 342 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |