Exemplo n.º 1
0
 def do_debug(self):
     self.prologue("FAQ Wizard Debugging")
     form = cgi.FieldStorage()
     cgi.print_form(form)
     cgi.print_environ(os.environ)
     cgi.print_directory()
     cgi.print_arguments()
Exemplo n.º 2
0
 def do_debug(self):
     self.prologue("FAQ Wizard Debugging")
     form = cgi.FieldStorage()
     cgi.print_form(form)
     cgi.print_environ(os.environ)
     cgi.print_directory()
     cgi.print_arguments()
Exemplo n.º 3
0
    def errorResponse(self, exc):
        """If an Exception (exc) was thrown during the request handling process,
        respond to the client with this method instead of the standard response method.
        """
        self.setTemplateFilename(self.requestData["ERROR_TEMPLATE"])
        self.requestData["errorType"] = str(type(exc))
        self.requestData["errorMsg"] = str(exc)

        if self.requestData["ERROR_EMAIL"] is not None:
            msg = StringIO()
            msgTemplate = open(self.requestData["ERROR_EMAIL_TEMPLATE"])
            msg.write(msgTemplate.read() % self.requestData)

            # Add all the CGI debug information to the e-mail
            origStdout = sys.stdout
            sys.stdout = msg
            cgi.print_exception(exc)
            cgi.print_arguments()

            cgi.print_form(self.mForm)

            if self.req is None:
                # Looks like a direct CGI request, pull out information from environment then
                cgi.print_environ()
            else:
                # Looks like mod_python or other call, with request object included.  Derive environment from there
                print("<h3>Request Sub-Process Environment</h3>",
                      file=sys.stdout)
                print("<ul>", file=sys.stdout)
                self.req.add_common_vars()
                for key, value in self.req.subprocess_env.items():
                    print("<li>%s: %s</li>" % (key, value), file=sys.stdout)
                print("</ul>", file=sys.stdout)

            sys.stdout = origStdout

            server = smtplib.SMTP(Env.SMTP_HOST)
            errors = server.sendmail(Env.CDB_EMAIL,
                                     self.requestData["ERROR_EMAIL"],
                                     msg.getvalue())
            self.requestData["emailErrors"] = str(errors)
            server.quit()
        else:
            self.requestData["emailErrors"] = "No notification e-mail sent"

        if not self.disableResponse:
            # CGI Text Response Basics
            self.printTemplate()
        elif self.req is not None:
            # Mod Python call
            self.req.write("<pre>")
            self.req.write("<h3>ChemDB / System Error</h3>")
            self.req.write(
                """We apologize for the following system error. If the problem persists, please contact <a href="mailto:%(errorEmail)s">%(errorEmail)s</a>.<br><br>"""
                % {"errorEmail": Env.ERROR_EMAIL})
            self.req.write("<font color=red>")
            self.req.write(
                str(exc))  # write the error at the top of the current page
            self.req.write("</font></pre>")
Exemplo n.º 4
0
 def update_event(self, inp=-1):
     self.set_output_val(0, cgi.print_arguments())
Exemplo n.º 5
0

# Create instance of FieldStorage
form = cgi.FieldStorage()

# Get data from fields
name = form.getvalue('name')
dbg = form.getvalue('dbg')
path = form.getvalue('path')
if (name):
    name = "../data/" + os.path.basename(name)

print('Content-type:text/html\r\n\r\n'
      "<html>"
      "<head>"
      "<title>Hello - Second CGI Program</title></head><body><pre>")
cgi.print_arguments()
cgi.print_environ()
cgi.print_directory()

if (name == None):
    print('no name given')

else:
    if (savefile(name, path)):
        print("saved!")
    else:
        print("error!")

print("</pre></body></html>")
Exemplo n.º 6
0
"""Generic FAQ Wizard.
Exemplo n.º 7
0
"""Generic FAQ Wizard.
Exemplo n.º 8
0

# Create instance of FieldStorage
form = cgi.FieldStorage()


# Get data from fields
name = form.getvalue("name")
dbg = form.getvalue("dbg")
path = form.getvalue("path")
if name:
    name = "../data/" + os.path.basename(name)


print("Content-type:text/html\r\n\r\n" "<html>" "<head>" "<title>Hello - Second CGI Program</title></head><body><pre>")
cgi.print_arguments()
cgi.print_environ()
cgi.print_directory()


if name == None:
    print("no name given")

else:
    if savefile(name, path):
        print("saved!")
    else:
        print("error!")


print("</pre></body></html>")
Exemplo n.º 9
0
from math import ceil
houses = int(input("Enter no. of houses here :"))

print(ceil((2 / houses) * 100), "%")

#import antigravity
#print(antigravity)

import cgi
print(cgi.print_arguments())