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

Side by Side Diff: pydir/if.py

Issue 689753002: Remove building llvm2ice.build_atts from Subzero build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues raised. Created 6 years, 1 month 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 | « Makefile.standalone ('k') | pydir/ifatts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python2
2
3 import argparse
4 import os
5 import sys
6
7 from utils import shellcmd
8
9 def main():
10 """Run the specified command only if conditions are met.
11
12 Two conditions are checked. First, the CONDITION must be true.
13 Secondly, all NEED names must be in the set of HAVE names.
14 If both conditions are met, the command defined by the remaining
15 arguments is run in a shell.
16 """
17 argparser = argparse.ArgumentParser(
18 description=' ' + main.__doc__,
19 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
20 argparser.add_argument('--cond', choices={'true', 'false'} , required=False,
21 default='true', metavar='CONDITION',
22 help='Condition to test.')
23 argparser.add_argument('--need', required=False, default=[],
24 action='append', metavar='NEED',
25 help='Needed name. May be repeated.')
26 argparser.add_argument('--have', required=False, default=[],
27 action='append', metavar='HAVE',
28 help='Name you have. May be repeated.')
29 argparser.add_argument('--echo-cmd', required=False,
30 action='store_true',
31 help='Trace the command before running.')
32 argparser.add_argument('--command', nargs=argparse.REMAINDER,
33 help='Command to run if attributes found.')
34
35 args = argparser.parse_args()
36
37 # Quit early if no command to run.
38 if not args.command:
39 raise RuntimeError("No command argument(s) specified for ifatts")
40
41 if args.cond == 'true' and set(args.need) <= set(args.have):
42 stdout_result = shellcmd(args.command, echo=args.echo_cmd)
43 if not args.echo_cmd:
44 sys.stdout.write(stdout_result)
45
46 if __name__ == '__main__':
47 main()
48 sys.exit(0)
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | pydir/ifatts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698