def start_module(selfURL): if not CGIdata.has_key("file"): menu.Menu() # HTML-Seite aufbauen error("no filename!") filename = urllib.unquote(CGIdata["file"]) menu.cfg.title = "Viewer [%s]" % filename menu.Menu() # HTML-Seite aufbauen if not os.path.isfile(filename): error("File [%s] does not exists!" % filename) print "<h3>%s</h3>" % filename print "<hr><pre>" f = file(filename, "r") while 1: line = f.readline() if line == "": break print line print "</pre><hr>" menu.print_footer()
def start_module(selfURL): menu.cfg.title = "SystemInfo" menu.Menu() SystemInfo() menu.print_footer()
def start_module( selfURL ): menu.cfg.title = "SystemInfo" menu.Menu() SystemInfo() menu.print_footer()
def start_module(selfURL): if CGIdata.has_key("cwd") and os.path.isdir(CGIdata["cwd"]): current_dir = CGIdata["cwd"] else: current_dir = "/" menu.cfg.css = "filebrowser.css" menu.cfg.title = "FileBrowser" menu.cfg.headings = head_script % {"current_dir": current_dir} menu.Menu() print html_start % {"current_dir": current_dir} #~ time.sleep(1) # Beim verwenden vom ThreadingServer wichtig! # Verz-Tabelle ausgeben FileBrowser(current_dir, selfURL) # Fussdaten ausgeben print html_end menu.print_footer()
def start_module( selfURL ): if CGIdata.has_key("cwd") and os.path.isdir( CGIdata["cwd"] ): current_dir = CGIdata["cwd"] else: current_dir = "/" menu.cfg.css = "filebrowser.css" menu.cfg.title = "FileBrowser" menu.cfg.headings = head_script % { "current_dir" : current_dir } menu.Menu() print html_start % { "current_dir" : current_dir } #~ time.sleep(1) # Beim verwenden vom ThreadingServer wichtig! # Verz-Tabelle ausgeben FileBrowser( current_dir, selfURL ) # Fussdaten ausgeben print html_end menu.print_footer()
def start_module(selfURL): menu.cfg.title = "console@" + str(os.uname()) menu.Menu() #~ # HTML-Pre Ausgeben #~ print htmlPre % { #~ "charset" : locale.getdefaultlocale()[1], #~ "uname" : os.uname() #~ } ## Konfiguration lesen cfg = config.Parser() cfg.set_section("console") maxHistoryLines = cfg.get("maxHistoryLines", "int") forceHTMLCompression = cfg.get("forceCompression") # Breite der Eingabe Zeile input_size = cfg.get("input size", "int") # Standartd Timeout in sek für jeden Befehl process_timeout = cfg.get("process timeout", "int") # ZusatzInfornationen Anzeigen verbose = cfg.get("verbose", "boolean") #~ MyOut = CompressedOut.AutoCompressedOut( forceHTMLCompression ) #~ print "<!-- Out-Compression:'%s' -->" % MyOut.get_mode() #~ for i in os.environ: print i,os.environ[i],"<br>" if CGIdata.has_key("stdout"): # Alte Ausgaben wieder anzeigen txt = CGIdata["stdout"] compressLen = len(txt) txt = decompress(txt) # Ausgaben dekomprimieren decompressLen = len(txt) MyOutConverter.put_data(txt) print txt.replace("\n", "<br>\n") else: compressLen = 0 decompressLen = 0 txt = "" ## Alte Verzeichnis wieder herstellen if CGIdata.has_key("current_dir") and os.path.isdir( CGIdata["current_dir"]): current_dir = CGIdata["current_dir"] # Ins alte Verzeichnis wechseln os.chdir(current_dir) else: current_dir = os.getcwd() ## Process Timeout Lesen und Anzeigen if CGIdata.has_key("timeout"): process_timeout = int(CGIdata["timeout"]) ## Befehl Ausführen if CGIdata.has_key("cmd"): command = CGIdata["cmd"] # Prompt mit Befehl anzeigen prompt = "<p><strong>%s>%s</strong></p>\n" % (current_dir, command) print prompt # Prompt auch in die History speichern MyOutConverter.put_data(prompt) print "<p><small>Process Timeout: %dsec.</small></p>" % process_timeout if command.startswith("cd "): # Verzeichnis wechsel destination_dir = command[3:] destination_dir = os.path.join(current_dir, destination_dir) destination_dir = os.path.normpath(destination_dir) if os.path.isdir(destination_dir): # Neuer Zielpfad existiert current_dir = destination_dir else: print "Directory [%s] does not exists<br>" % destination_dir else: # Befehl ausführen cmd(command, current_dir, process_timeout) # Neues, aktuelles Prompt anzeigen print "<strong>%s></strong>" % current_dir # Ausgaben kürzen und Komprimieren, damit der Client weniger Daten wieder zurück senden muß # Die Kompression zahlt sich nach zwei, drei Befehlen i.d.R. aus... stdout_raw = compress(cutLines(MyOutConverter.get_data(), maxHistoryLines)) #~ stdout_raw = MyOutConverter.get_data() if verbose: print "<p><small>compress: %d decompress: %d<br />" % (compressLen, decompressLen) print "(console - 'verbose mode')</small></p>" print console_form % { "self": selfURL, "stdout_raw": stdout_raw, "current_dir": current_dir, "input_size": input_size, "process_timeout": str(process_timeout) } menu.print_footer()
def start_module( selfURL ): menu.cfg.title = "console@" + str( os.uname() ) menu.Menu() #~ # HTML-Pre Ausgeben #~ print htmlPre % { #~ "charset" : locale.getdefaultlocale()[1], #~ "uname" : os.uname() #~ } ## Konfiguration lesen cfg = config.Parser() cfg.set_section("console") maxHistoryLines = cfg.get( "maxHistoryLines", "int" ) forceHTMLCompression = cfg.get( "forceCompression" ) # Breite der Eingabe Zeile input_size = cfg.get( "input size", "int" ) # Standartd Timeout in sek für jeden Befehl process_timeout = cfg.get( "process timeout", "int" ) # ZusatzInfornationen Anzeigen verbose = cfg.get( "verbose", "boolean" ) #~ MyOut = CompressedOut.AutoCompressedOut( forceHTMLCompression ) #~ print "<!-- Out-Compression:'%s' -->" % MyOut.get_mode() #~ for i in os.environ: print i,os.environ[i],"<br>" if CGIdata.has_key("stdout"): # Alte Ausgaben wieder anzeigen txt = CGIdata["stdout"] compressLen = len( txt ) txt = decompress( txt ) # Ausgaben dekomprimieren decompressLen = len( txt ) MyOutConverter.put_data( txt ) print txt.replace( "\n", "<br>\n" ) else: compressLen = 0 decompressLen = 0 txt = "" ## Alte Verzeichnis wieder herstellen if CGIdata.has_key("current_dir") and os.path.isdir( CGIdata["current_dir"] ): current_dir = CGIdata["current_dir"] # Ins alte Verzeichnis wechseln os.chdir( current_dir ) else: current_dir = os.getcwd() ## Process Timeout Lesen und Anzeigen if CGIdata.has_key("timeout"): process_timeout = int( CGIdata["timeout"] ) ## Befehl Ausführen if CGIdata.has_key("cmd"): command = CGIdata["cmd"] # Prompt mit Befehl anzeigen prompt = "<p><strong>%s>%s</strong></p>\n" % (current_dir, command) print prompt # Prompt auch in die History speichern MyOutConverter.put_data( prompt ) print "<p><small>Process Timeout: %dsec.</small></p>" % process_timeout if command.startswith("cd "): # Verzeichnis wechsel destination_dir = command[3:] destination_dir = os.path.join( current_dir, destination_dir ) destination_dir = os.path.normpath( destination_dir ) if os.path.isdir( destination_dir ): # Neuer Zielpfad existiert current_dir = destination_dir else: print "Directory [%s] does not exists<br>" % destination_dir else: # Befehl ausführen cmd( command, current_dir, process_timeout ) # Neues, aktuelles Prompt anzeigen print "<strong>%s></strong>" % current_dir # Ausgaben kürzen und Komprimieren, damit der Client weniger Daten wieder zurück senden muß # Die Kompression zahlt sich nach zwei, drei Befehlen i.d.R. aus... stdout_raw = compress( cutLines( MyOutConverter.get_data(), maxHistoryLines ) ) #~ stdout_raw = MyOutConverter.get_data() if verbose: print "<p><small>compress: %d decompress: %d<br />" % (compressLen, decompressLen) print "(console - 'verbose mode')</small></p>" print console_form % { "self" : selfURL, "stdout_raw" : stdout_raw, "current_dir" : current_dir, "input_size" : input_size, "process_timeout" : str( process_timeout ) } menu.print_footer()