예제 #1
0
#!/usr/bin/env python
"""
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from cgi_tools import force_C_locale, set_resource_limits, set_app_code, \
                      http_server_error


def cgi_main():
    http_server_error("test script, failing on purpose")


if __name__ == "__main__":
    set_app_code(2001)
    set_resource_limits(walltime=3)
    force_C_locale()
    cgi_main()
예제 #2
0
#!/usr/bin/env python
"""
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from cgi_tools import force_C_locale, set_resource_limits, set_app_code


def cgi_main():
    print "Content-Type: text/plain"
    print
    print "Hello World, cgi_tools imported!"


if __name__ == "__main__":
    set_app_code(2000)
    set_resource_limits(walltime=3)
    force_C_locale()
    cgi_main()
예제 #3
0
    # Cleanup
    shutil.rmtree(d)

    # Send plain text output
    if plain_output:
        print ("Content-Type: text/html")
        print ("")
        print (file_list.encode('ascii','ignore'))
        return


    # Send pretty HTML output
    print ("Content-Type: text/html")
    print ("")

    tmpl = Template(html_tmpl)
    html = tmpl.render(language=language,
                       script=script, stdin=stdin,
                       results=html_file_list)
    print (html.encode('ascii','ignore'))


if __name__ == "__main__":
    set_app_code(459)
    # note:max file size must be the same (or larger)
    # to the 'ulimit -f' set in port-a-script.sh
    # (otherwise the script will fail with 'ulimit -f: permission denied')
    set_resource_limits(walltime=4,filesize=100*1024)
    force_C_locale()
    cgi_main()
예제 #4
0
      <br/>

      Output Format: {{ fmt_string }}
      <br/>
      <br/>

      Result:
       {% if date_ok %}
         <b><code>{{date_result}}</code></b>
       {% else %}
         Failed to run date:
         <b><code>{{ date_error }}</b></code>
       {% endif %}
      </body>
    </html>
    """
    tmpl = Template(html_tmpl)
    html = tmpl.render(delta=delta,
                       fmt_string=fmt_string,
                       date_ok=date_ok,
                       date_result=date_result,
                       date_error=date_error)
    print(html)


if __name__ == "__main__":
    set_app_code(124)
    set_resource_limits(walltime=4)
    force_C_locale()
    cgi_main()
예제 #5
0
#!/usr/bin/env python
"""
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from cgi_tools import force_C_locale, set_resource_limits, set_app_code, \
                      http_bad_request_error


def cgi_main():
    http_bad_request_error("test script, failing on purpose")


if __name__ == "__main__":
    set_app_code(2003)
    set_resource_limits(walltime=3)
    force_C_locale()
    cgi_main()
예제 #6
0
    return text


def cgi_main():
    """
    Main script: get CGI parameters, return HTML content.
    """

    text = parse_cgi_params()

    #note: these counts are different than wc's definition
    #      of chars/lines/words
    chars = len(text)
    lines = len(text.split('\n'))
    words = len(text.split())

    print("Content-Type: text/plain")
    print("")
    print("%d characters" % chars)
    print("%d words" % words)
    print("%d lines" % lines)
    print("\n\nText Below:\n")
    print(text)


if __name__ == "__main__":
    set_app_code(125)
    set_resource_limits(walltime=4)
    force_C_locale()
    cgi_main()
예제 #7
0
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from __future__ import print_function
import sys, cgi, math
from cgi_tools import force_C_locale, set_resource_limits, set_app_code


def waste_time():
    """use %100 of the CPU for a really long time"""
    for i in xrange(0, sys.maxint):
        a = math.sqrt(i)


def cgi_main():
    waste_time()

    print("Content-Type: text/plain")
    print("")
    print("If you see this message, the script failed")


if __name__ == "__main__":
    set_app_code(123)
    # Allow 10 seconds of wall-time, and 1 second of cputime.
    set_resource_limits(walltime=10, cputime=1)
    force_C_locale()
    cgi_main()
예제 #8
0
#!/usr/bin/env python
"""
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from cgi_tools import force_C_locale, set_resource_limits, set_app_code


def cgi_main():
    print "Content-Type: text/plain"
    print
    print "Hello World, cgi_tools imported!"


if __name__ == "__main__":
    set_app_code(122)
    set_resource_limits(walltime=3)
    force_C_locale()
    cgi_main()