Changeset 13937 in genesis


Ignore:
Timestamp:
Jul 6, 2017, 9:10:48 AM (7 years ago)
Author:
rick
Message:

Add static files generating on update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r13936 r13937  
    14691469
    14701470
     1471def generate_static(output_dir, logging=True):
     1472  items = {'output_dir' : output_dir}
     1473  for node in get_hostlist():
     1474    items['node'] = node
     1475    items['wdir'] = "%(output_dir)s/%(node)s" % items
     1476    if not os.path.isdir(items['wdir']):
     1477      os.makedirs(items['wdir'])
     1478    datadump = get_yaml(node)
     1479    f = open("%(wdir)s/index.html" % items, "w")
     1480    f.write(generate_node_overview(items['node'], datadump))
     1481    f.close()
     1482    for config in files:
     1483      items['config'] = config
     1484      if logging: logger.info("## Generating %(node)s %(config)s" % items)
     1485      f = open("%(wdir)s/%(config)s" % items, "w")
     1486      f.write(generate_config(node, config, datadump))
     1487      f.close()
     1488
     1489
     1490
    14711491def process_cgi_request(environ=os.environ):
    14721492  """ When calling from CGI """
     
    14801500    output += subprocess.Popen([SVN, 'cleanup', "%s/.." % NODE_DIR], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
    14811501    output += subprocess.Popen([SVN, 'up', "%s/.." % NODE_DIR], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
     1502    generate_static(CACHE_DIR, False)
    14821503    output += "[INFO] All done, redirecting in 5 seconds"
    14831504    response_headers += [
     
    18751896      print_cgi_response(response_headers, output)
    18761897    elif sys.argv[1] == "static":
    1877       items = dict()
    1878       items['output_dir'] = sys.argv[2] if len(sys.argv) > 2 else "./static"
    1879       for node in get_hostlist():
    1880         items['node'] = node
    1881         items['wdir'] = "%(output_dir)s/%(node)s" % items
    1882         if not os.path.isdir(items['wdir']):
    1883           os.makedirs(items['wdir'])
    1884         datadump = get_yaml(node)
    1885         f = open("%(wdir)s/index.html" % items, "w")
    1886         f.write(generate_node_overview(items['node'], datadump))
    1887         f.close()
    1888         for config in files:
    1889           items['config'] = config
    1890           logger.info("## Generating %(node)s %(config)s" % items)
    1891           f = open("%(wdir)s/%(config)s" % items, "w")
    1892           f.write(generate_config(node, config, datadump))
    1893           f.close()
     1898      generate_static(sys.argv[2] if len(sys.argv) > 2 else "./static")
    18941899    elif sys.argv[1] == "wind-export":
    18951900      items = dict()
Note: See TracChangeset for help on using the changeset viewer.