コード例 #1
0
ファイル: faqwiz.py プロジェクト: olympu/ancient-pythons
 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()
コード例 #2
0
ファイル: faqwiz.py プロジェクト: Belxjander/Kirito
 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()
コード例 #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>")
コード例 #4
0
 def update_event(self, inp=-1):
     self.set_output_val(0, cgi.print_arguments())
コード例 #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>")
コード例 #6
0
ファイル: faqwiz.py プロジェクト: mcyril/ravel-ftn
"""Generic FAQ Wizard.
コード例 #7
0
"""Generic FAQ Wizard.
コード例 #8
0
ファイル: upload.py プロジェクト: ziposoft/ac1

# 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>")
コード例 #9
0
ファイル: halloween candy.py プロジェクト: zadfab/Backup
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())