Beispiel #1
0
    def _printPost(self):
        name = os.path.basename(self.fileName)
        outputFile = name.replace(".py",".ngc")
        form = cgi.FieldStorage()       
        if form['generation'].value == 'interactive':
             print "Content-Type: text/html"
             print
             html_header = self.postHead
             # add the tree control javascript stuff
             #html_header += HtmlTree.html_header_text
             utils.printHead('Hugomatic gcode', ('banner','nav','interactive','footer'),  extraText=html_header)
             utils.printBanner()
             utils.printPostNavBar(self.fileName)
             print "<h1>" + outputFile + "</h1><Pre>"
             #print '<h2>Source code: <a href="sourceView.py?src=' + name + '">' + name+'</a></h2>'
             old_out = sys.stdout
             sys.stdout = RedirectStdOut(old_out, True)
             # add hook to end program with a copyright notice
             atexit.register(printPostFooter)
        else:           
            print 'Content-Type: text/plain'
            print "Content-Disposition: attachment; filename=\"" + outputFile + "\""
            print
        
        print "( " + self.title + " )"
        print "( " + self.desc + " )"
        print
        
        callingFrame = inspect.currentframe().f_back.f_back
        for p in self.params:
            name = p['name'] 
            desc = p['desc']
            value = p['obj']

            
            newVal = None
            if type(value) == bool:
                if form.__contains__(name):
                    newVal = True
                else:
                    newVal = False
            else:
                if form.__contains__(name):
                    newVal = None
                    if type(value) == float:
                        newVal = float(form[name].value)
                    elif type(value) == int:
                            newVal = int(form[name].value)   
                    if form[name].filename:
                            newVal = self._uploadFile(form[name])            
                    if newVal == None:
                        # if the value has not changed, set newVal to the old one
                        newVal = form[name].value
            # assign the new value    
            callingFrame.f_globals[name] = newVal
            
            strV =  name + " = " + str(newVal) + ", "+ desc+ " default: "+ str(value)
            s2 = "( " + gcodeCommentEscape(strV) + ")"
            print s2
Beispiel #2
0
 def _interactive_post(self, name, output_file, form):
     print "Content-Type: text/html"
     print
     html_header = self.postHead
     # add the tree control javascript stuff
     #html_header += HtmlTree.html_header_text
     utils.printHead('Hugomatic gcode', ('banner','nav','interactive','footer'),  extraText=html_header)
     utils.printBanner()
     utils.printPostNavBar(self.fileName)
     print "<h1>" + output_file + "</h1><Pre>"
     #print '<h2>Source code: <a href="sourceView.py?src=' + name + '">' + name+'</a></h2>'
     old_out = sys.stdout
     sys.stdout = RedirectStdOut(old_out, True)
     # add hook to end program with a copyright notice
     if googleAppEngine == False:
         atexit.register(print_interactive_post_footer)