Beispiel #1
0
def submit(form):
  wgo_contest.folio_init("GIMP 10th Anniversary Contest Submission")
  
  image = 'images/gimp-splash.png'
  author = "Wilber Gimp"
  email = "*****@*****.**"

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  #xhtml.div(thumb, {"class": "splash-thumb", "style" : "float: right; margin-left: 1em;"})
  print xhtml.para("""Welcome to the www.gimp.org 10th Anniversary Splash Contest.
  From here you may submit images to be considered as candidates
  for a splash image.""")

  print xhtml.h2("Submit Your Image", {"class" : "subtitle"})

  cell = xhtml.table.cell
  row = xhtml.table.row

  thumb = wgo_contest.image_generate("Your Image Here", image, "Wilber", "*****@*****.**")

  fields = (xhtml.table.init({"cellspacing" : 0})
            + row(cell("Image File name:",     {"style" : "font-weight: bold"}) + cell(xhtml.input.file({"name" : "image"})))
            + row(cell("Title:",         {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "title"})))
            + row(cell("Artist's Name:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "author"})))
            + row(cell("Artist's Email:", {"style" : "font-weight: bold"}) + cell(xhtml.input.text({"name" : "email"})))
            + row(cell("Tutorial File name:",     {"style" : "font-weight: bold"}) + cell(xhtml.input.file({"name" : "tutorial"})))
            + row(cell(xhtml.input.hidden({"name" : "mode","value" : "preview"})) + cell(xhtml.input.submit({"name" : "preview", "value" : "PREVIEW"})))
            + xhtml.table.fini())
  
  form = xhtml.form(fields, {"enctype" : "multipart/form-data",
                             "method" : "post",
                             "action" : "contest.cgi",
                             "style" : "margin: 1.33em 0px; margin-left: 40px; margin-right: 40px;" })

  guidelines = (xhtml.para("Fill in the fields below, and click the "
                             + xhtml.input.submit({"value" : "PREVIEW", "disabled" : "disabled"})
                             + " button below."))

  print guidelines
  print form

  wgo_contest.folio_fini()
  return
Beispiel #2
0
def approved(form):
  wgo_contest.folio_init("GIMP 10th Anniversary Contest Submission Approved")

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  print xhtml.para("""Welcome to the www.gimp.org splash image contest. """
                   """From here you may submit images to be considered as candidates for a "splash" image.""")
  print xhtml.h2("Thank You!", {"class" : "subtitle"})
  print xhtml.para("Again, we offer No Promises on what may become of your image here.")
  
  name = os.path.basename(form.getvalue("name", ""))
  entry = wgo_contest.gallery_image(name)
  entry["title"] = xhtml.quote(form.getvalue("title", ""))
  entry["author"] = xhtml.quote(form.getvalue("author", ""))
  entry["email"] = xhtml.quote(form.getvalue("email", ""))

  tutorial_path = wgo_contest.spool_path(name, ".tut")

  image_path = wgo_contest.spool_path(name, ".png")
  thumb_path = wgo_contest.spool_path(name, "-t.png")
  thumb_path = wgo_contest.spool_path(name, "-t.jpg")
  
  image_file = wgo_contest.gallery_file(name, ".png")
  thumb_file = wgo_contest.gallery_file(name, "-t.png")
  thumb_file = wgo_contest.gallery_file(name, "-t.jpg")
  image_html = wgo_contest.gallery_path(name, ".html")
  thumb_html = wgo_contest.gallery_path(name, "-t.html")
  
  #print "/bin/cp -f '%s' '%s' '%s'<br />" % (image_path, thumb_path, wgo_contest.config.gallery_path)
  os.system("/bin/cp -f '%s' '%s' '%s' '%s'" % (tutorial_path, image_path, thumb_path, wgo_contest.config.gallery_path))

  entry.save()

  #print xhtml.div(entry.ashtml("image"), {"class" : "splash-image"})
  print entry.ashtml("image")

  print xhtml.para("You can " + xhtml.hyperlink("submit another image", {"href" : "/contest/contest.cgi"})
                  + " or "  + xhtml.hyperlink("view the gallery.", {"href" : "/contest/gallery.cgi?display=gallery"}))

  wgo_contest.folio_fini()
  return
Beispiel #3
0
def make_html(root,
              converge_plot,
              te_plot,
              tr_plot,
              spec_tot_plot,
              spec_plot,
              complete_message=['test'],
              errors=['test', 'test2']):
    '''
    Make an html file that collates all the results
    '''

    string = xhtml.begin(
        'Evaluation of how well the python run of %s succeeded' % root)

    string += xhtml.paragraph(
        'Provide an overview of whether the run of %s has succeeded' % root)

    string += xhtml.add_list(complete_message)

    string += xhtml.hline()
    string += xhtml.h2('Did the run converge?')
    # print(xhtml.image('file:./diag_%s/convergence.png' % root))
    string += xhtml.image('file:./diag_%s/convergence.png' % root)

    string += xhtml.paragraph(convergence_message)

    string += xhtml.paragraph(convergence2)
    # print('Test ',converge_plot)
    string += xhtml.image('file:%s' % (converge_plot))
    string += xhtml.hline()

    string += xhtml.h2('What do the temperatures look like?')
    string += xhtml.image('file:%s' % (te_plot))
    string += xhtml.image('file:%s' % (tr_plot))
    # string+=xhtml.image('file:./diag_%s/%s_t_e.png' % (root,root))
    # string+=xhtml.image('file:./diag_%s/%s_t_r.png' % (root,root))
    string += xhtml.hline()
    string += xhtml.h2(
        'What do the total spectra look like (somewhat smoothed)?')
    string += xhtml.image('file:%s' % (spec_tot_plot))
    string += xhtml.hline()
    string += xhtml.h2(
        'What do the final spectra look like (somewhat smoothed)?')
    string += xhtml.image('file:%s' % (spec_plot))
    string += xhtml.hline()

    string += xhtml.h2('Errors and Warnings')

    string += xhtml.paragraph(error_description)

    string += xhtml.preformat(errors)

    string += xhtml.hline()

    # Now add the parameter file so we can see what we have

    string += xhtml.h2('The parameter file used:')

    x = open(root + '.pf')
    lines = x.readlines()

    string += xhtml.add_list(lines)
    string += xhtml.hline()

    string += xhtml.end()

    # print(string)

    g = open(root + '.html', 'w')
    g.write(string)
Beispiel #4
0
    try: os.remove(thumb_path)
    except: pass

    print wgo.error(str(e))
    wgo_contest.folio_fini()
    return (1)

  wgo_contest.folio_init("GIMP 10th Anniversary Contest Preview")

  print xhtml.h1("GIMP 10th Anniversary Contest", {"class" : "heading"})
  print xhtml.para("""Welcome to the www.gimp.org 10th Anniversary Splash Contest. """
                   """From here you may submit images with tutorials to be considered as candidates
                   for a "splash" image.  We appreciate your participation, but we
                   offer No Promises on what may become of your image here.""")

  print xhtml.h2("Approve Your Image", {"class" : "subtitle"})

  form = xhtml.form(xhtml.input.submit({"name" : "approve", "value" : "APPROVE"})
                    + xhtml.input.hidden({"name" : "mode", "value" : "approve"})
                    + xhtml.input.hidden({"name" : "name", "value" : name})
                    + xhtml.input.hidden({"name" : "title", "value" : title})
                    + xhtml.input.hidden({"name" : "author", "value" : author})
                    + xhtml.input.hidden({"name" : "email", "value" : email}),
                    {"enctype" : "multipart/form-data", "method" : "post", "action" : "contest.cgi"})

  thumb = wgo_contest.image_generate(title, thumb_file, author, email)
    
  img = wgo_contest.image_generate(title, image_file, author, email)

  guidelines = (xhtml.para(xhtml.span(xhtml.div(thumb, {"class": "splash-thumb"}), {"style" : "float: right; margin-left: 1em;"})
                           + """Below is your image as we see it, in its original size surrounded
Beispiel #5
0
def make_html(logfile='test_sum.log', outfile=''):
    '''
    Create an html file using information in the log file

    History

    150901 ksl  fixed so that the htmlfile could be specified
    151112 ksl  Modified so that number of saturating stars could be printed out
            and so that only some of the columns in the table created by actor.actor_main
        were included in the html table that is part of the output.
    '''
    xsize = 800
    ysize = 400

    try:
        root = logfile[0:logfile.rindex('_sum')]
    except ValueError:
        root = logfile[0:logfile.rindex('.')]

    hstring = html.begin('Summary for %s' % root)

    x = open(logfile, 'r')
    x = x.readlines()
    expcount = 0
    for line in x:
        xline = line.strip()
        words = xline.split()
        if len(words) > 0:
            if words[0] == 'Header':
                expcount += 1
                xline = "<a name=\"EXP%04d\">%s</a>" % (
                    expcount, xline.replace('Header', ''))
                hstring = hstring + html.h2(xline)
            elif words[0] == 'Table':
                xxx = read_table(words[1])
                # Drop some columns, and reorder sligthly
                xxx = xxx['Visit', 'ExpNo', 'Target', 'RA', 'Dec', 'Config',
                          'Aper', 'Filter', 'SAMP-SEQ', 'NSAMP', 'Exptime',
                          'Repeats', 'ScanRate', 'Comment']
                ### make links from exposure number
                links = []

                for i in range(len(xxx)):
                    link = '<a href=#EXP%04d>%d</a>' % (i + 1, xxx['ExpNo'][i])
                    links.append(link)

                xxx.add_column(Column(data=links, name='Exp'), 1)
                xxx.remove_column('ExpNo')

                # Note: ksl.  I had troble getting the column names to form a
                # sincle record.  This is what worked in the end
                my_table = [xxx.colnames[:]]

                for one in xxx:
                    my_table.append(one)

                hstring = hstring + html.table(my_table)
            elif words[0] == 'Image':
                ximage = words[1]
                hstring = hstring + html.image(ximage, 'Bright stars image',
                                               xsize, ysize)
            else:
                if xline.startswith('Saturated'):
                    print(xline)
                    data = xline.split()[-5::2]
                    colors = ['green', 'blue', 'red']
                    for i in range(3):
                        if int(data[i]) == 0:
                            data[
                                i] = "<span style=\"color:grey\">%s</span>" % (
                                    data[i])
                        else:
                            data[
                                i] = "<span style=\"color:%s; font-weight:bold;\">%s</span>" % (
                                    colors[i], data[i])

                    hstring += html.paragraph(
                        'Saturated pixels in image:') + html.table(
                            [xline.split()[-6::2], data], width="200px")
                elif xline.startswith('Number saturated'):
                    data = xline.split()[-5::2]
                    colors = ['green', 'blue', 'red']
                    for i in range(3):
                        if int(data[i]) == 0:
                            data[
                                i] = "<span style=\"color:grey\">%s</span>" % (
                                    data[i])
                        else:
                            data[
                                i] = "<span style=\"color:%s; font-weight:bold;\">%s</span>" % (
                                    colors[i], data[i])

                    hstring += html.paragraph(
                        'Saturated stars in field:') + html.table(
                            [xline.split()[-6::2], data], width="200px")
                else:
                    hstring = hstring + html.paragraph(xline)
    hstring = hstring + html.end()

    # Create the html file
    if outfile == '':
        html_file = root + '.html'
    elif outfile.count('html') == 0:
        html_file = outfile + '.html'
    else:
        html_file = outfile

    print('test ', html_file)
    g = open(html_file, 'w')
    g.write(hstring)
    g.close()
Beispiel #6
0
def make_html(root,
              converge_plot,
              te_plot,
              tr_plot,
              spec_tot_plot,
              spec_plot,
              complete_message=['test'],
              errors=['test', 'test2']):
    '''
    Make an html file that collates all the results
    '''

    string = xhtml.begin('%s: How well did the Python run go?' % root)

    string += xhtml.paragraph(
        'Provide an overview of whether the run of %s has succeeded' % root)

    string += xhtml.add_list(complete_message)

    string += xhtml.hline()
    string += xhtml.h2('Did the run converge?')

    if os.path.isfile('./diag_%s/convergence.png' % root):
        string += xhtml.image('file:./diag_%s/convergence.png' % root)
    else:
        string += xhtml.paragraph(
            'There is no convergence plot. OK if no ionization cycles')

    string += xhtml.paragraph(convergence_message)

    string += xhtml.paragraph(convergence2)
    # print('Test ',converge_plot)
    string += xhtml.image('file:%s' % (converge_plot))
    string += xhtml.hline()

    string += xhtml.h2('What do the temperatures look like?')
    string += xhtml.image('file:%s' % (te_plot))
    string += xhtml.image('file:%s' % (tr_plot))
    # string+=xhtml.image('file:./diag_%s/%s_t_e.png' % (root,root))
    # string+=xhtml.image('file:./diag_%s/%s_t_r.png' % (root,root))
    string += xhtml.hline()
    string += xhtml.h2(
        'What do the total spectra look like (somewhat smoothed)?')

    if os.path.isfile(spec_tot_plot):
        string += xhtml.image('file:%s' % (spec_tot_plot))
    else:
        string += xhtml.paragraph(
            'There is no total spectrum plot. OK if no ionization cycles')

    string += xhtml.hline()
    string += xhtml.h2(
        'What do the final spectra look like (somewhat smoothed)?')
    if spec_plot != 'None':
        string += xhtml.image('file:%s' % (spec_plot))
    else:
        string += xhtml.paragraph(
            'There is no plot of a detailed spectrum, probably because detailed spectra were not created'
        )
    string += xhtml.hline()

    string += xhtml.h2('Errors and Warnings')

    string += xhtml.paragraph(error_description)

    string += xhtml.preformat(errors)

    string += xhtml.hline()

    # Now add the parameter file so we can see what we have

    string += xhtml.h2('The parameter file used:')

    x = open(root + '.pf')
    lines = x.readlines()

    string += xhtml.add_list(lines)
    string += xhtml.hline()

    string += xhtml.end()

    # print(string)

    g = open(root + '.html', 'w')
    g.write(string)
Beispiel #7
0
def error(text):
  return (xhtml.h2("Eeek! An error!", {"class" : "subtitle"}) + xhtml.para(text))