Esempio n. 1
0
File: build.py Progetto: 317070/ppbe
        if len(merged) > 1000000: # The maximum file size for this web service is 1000 KB.
            print "\nPre-compressing using jsmin"
            merged = jsmin.jsmin(merged)
        print "\nIs being compressed using Closure Compiler Service."
        try:
            minimized = closure_ws.minimize(merged)
        except Exception, E:
            print "\nAbnormal termination."
            sys.exit("ERROR: Closure Compilation using Web service failed!\n%s" % E)
        if len(minimized) <= 2:
            print "\nAbnormal termination due to compilation errors."
            sys.exit("ERROR: Closure Compilation using Web service failed!")
        else:
            print '\nClosure Compilation using Web service has completed successfully.'
    elif use_compressor == "closure":
        minimized = closure.minimize(merged)      
    else: # fallback
        minimized = merged 
    print "Adding license file."
    minimized = file("license.txt").read() + minimized

    print "Writing to %s." % outputFilename
    file(outputFilename, "w").write(minimized)

    print "Done."

if __name__ == '__main__':
  opt = optparse.OptionParser(usage="%s [options] [config_file] [output_file]\n  Default config_file is 'full.cfg', Default output_file is 'OpenLayers.js'")
  opt.add_option("-c", "--compressor", dest="compressor", help="compression method: one of 'jsmin', 'minimize', 'closure_ws', 'closure', or 'none'", default="jsmin")
  (options, args) = opt.parse_args()
  if not len(args):
Esempio n. 2
0
        Replace the file at "path" location with the (newly built) file
        of the same name in the working directory
    """

    name = os.path.basename(filename)
    target = os.path.join(path, name)
    try:
        # Remove existing file
        os.remove(target)
    except:
        # Doesn't exist
        pass
    shutil.move(filename, path)


sourceDirectoryOpenLayers = "../gis/openlayers/lib"
configFilenameOpenLayers = "sahana.js.ol.cfg"
outputFilenameOpenLayers = "OpenLayers.js"
mergedOpenLayers = mergejs.run(sourceDirectoryOpenLayers, None,
                               configFilenameOpenLayers)
# Suppress strict-mode errors
minimizedOpenLayers = closure.minimize(
    mergedOpenLayers, extra_params="--strict_mode_input=false")
with openf(outputFilenameOpenLayers, "w") as outFile:
    #outFile.write(mergedOpenLayers)
    outFile.write(minimizedOpenLayers)

#os.system("terser OpenLayers.js -c -o OpenLayers.min.js")

move_to(outputFilenameOpenLayers, "../gis")