summaryrefslogtreecommitdiffstats
path: root/tools/gypv8sh.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gypv8sh.py')
-rwxr-xr-xtools/gypv8sh.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py
index 7018db9..c45dbfd 100755
--- a/tools/gypv8sh.py
+++ b/tools/gypv8sh.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,16 +11,14 @@ Usage:
inputfile inputrelfile cxxoutfile jsoutfile
"""
-try:
- import json
-except ImportError:
- import simplejson as json
+import json
import optparse
import os
import subprocess
import sys
import shutil
+
def main ():
parser = optparse.OptionParser()
parser.set_usage(
@@ -42,13 +40,16 @@ def main ():
print cmd
if not opts.impotent:
try:
- subprocess.check_call(cmd, stdout=open(cxxoutfile, 'w'))
+ with open(cxxoutfile, 'w') as f:
+ subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f)
shutil.copyfile(inputfile, jsoutfile)
except Exception, ex:
- print ex
- os.remove(cxxoutfile)
- os.remove(jsoutfile)
- sys.exit(1)
+ if os.path.exists(cxxoutfile):
+ os.remove(cxxoutfile)
+ if os.path.exists(jsoutfile):
+ os.remove(jsoutfile)
+ raise
+
if __name__ == '__main__':
sys.exit(main())