Commit 004f5b3c authored by carlosperate's avatar carlosperate
parent 82394c5c
#!/usr/bin/python #!/usr/bin/python2.7
# Compresses the core Blockly files into a single JavaScript file. # Compresses the core Blockly files into a single JavaScript file.
# #
# Copyright 2012 Google Inc. # Copyright 2012 Google Inc.
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
import errno, glob, httplib, json, os, re, subprocess, sys, threading, urllib import errno, glob, httplib, json, os, re, subprocess, sys, threading, urllib
def import_path(fullpath): def import_path(fullpath):
"""Import a file with full path specification. """Import a file with full path specification.
Allows one to import from any directory, something __import__ does not do. Allows one to import from any directory, something __import__ does not do.
...@@ -51,7 +52,7 @@ def import_path(fullpath): ...@@ -51,7 +52,7 @@ def import_path(fullpath):
filename, ext = os.path.splitext(filename) filename, ext = os.path.splitext(filename)
sys.path.append(path) sys.path.append(path)
module = __import__(filename) module = __import__(filename)
reload(module) # Might be out of date reload(module) # Might be out of date.
del sys.path[-1] del sys.path[-1]
return module return module
...@@ -253,8 +254,8 @@ class Gen_compressed(threading.Thread): ...@@ -253,8 +254,8 @@ class Gen_compressed(threading.Thread):
if json_data.has_key('serverErrors'): if json_data.has_key('serverErrors'):
errors = json_data['serverErrors'] errors = json_data['serverErrors']
for error in errors: for error in errors:
print 'SERVER ERROR: %s' % target_filename print('SERVER ERROR: %s' % target_filename)
print error['error'] print(error['error'])
elif json_data.has_key('errors'): elif json_data.has_key('errors'):
errors = json_data['errors'] errors = json_data['errors']
for error in errors: for error in errors:
...@@ -321,7 +322,7 @@ class Gen_compressed(threading.Thread): ...@@ -321,7 +322,7 @@ class Gen_compressed(threading.Thread):
print('Size changed from %d KB to %d KB (%d%%).' % ( print('Size changed from %d KB to %d KB (%d%%).' % (
original_kb, compressed_kb, ratio)) original_kb, compressed_kb, ratio))
else: else:
print 'UNKNOWN ERROR' print('UNKNOWN ERROR')
class Gen_langfiles(threading.Thread): class Gen_langfiles(threading.Thread):
...@@ -338,7 +339,7 @@ class Gen_langfiles(threading.Thread): ...@@ -338,7 +339,7 @@ class Gen_langfiles(threading.Thread):
try: try:
return (max(os.path.getmtime(src) for src in srcs) > return (max(os.path.getmtime(src) for src in srcs) >
min(os.path.getmtime(dest) for dest in dests)) min(os.path.getmtime(dest) for dest in dests))
except OSError, e: except OSError as e:
# Was a file not found? # Was a file not found?
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
# If it was a source file, we can't proceed. # If it was a source file, we can't proceed.
...@@ -363,7 +364,7 @@ class Gen_langfiles(threading.Thread): ...@@ -363,7 +364,7 @@ class Gen_langfiles(threading.Thread):
'--input_file', 'msg/messages.js', '--input_file', 'msg/messages.js',
'--output_dir', 'msg/json/', '--output_dir', 'msg/json/',
'--quiet']) '--quiet'])
except (subprocess.CalledProcessError, OSError), e: except (subprocess.CalledProcessError, OSError) as e:
# Documentation for subprocess.check_call says that CalledProcessError # Documentation for subprocess.check_call says that CalledProcessError
# will be raised on failure, but I found that OSError is also possible. # will be raised on failure, but I found that OSError is also possible.
print('Error running i18n/js_to_json.py: ', e) print('Error running i18n/js_to_json.py: ', e)
...@@ -387,7 +388,7 @@ class Gen_langfiles(threading.Thread): ...@@ -387,7 +388,7 @@ class Gen_langfiles(threading.Thread):
(file.endswith(('keys.json', 'synonyms.json', 'qqq.json')))] (file.endswith(('keys.json', 'synonyms.json', 'qqq.json')))]
cmd.extend(json_files) cmd.extend(json_files)
subprocess.check_call(cmd) subprocess.check_call(cmd)
except (subprocess.CalledProcessError, OSError), e: except (subprocess.CalledProcessError, OSError) as e:
print('Error running i18n/create_messages.py: ', e) print('Error running i18n/create_messages.py: ', e)
sys.exit(1) sys.exit(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment