Python wrapper for running instances of trisurf-ng
Samo Penic
2017-01-07 d50227ea034dae0fb6ee75a9a3941f786facaf16
Web interface improved. Accepts analysis?analysis_name as arguments.
2 files modified
17 ■■■■ changed files
networkedExample.py 7 ●●●● patch | view | raw | blame | history
trisurf/WebTrisurf.py 10 ●●●● patch | view | raw | blame | history
networkedExample.py
@@ -35,10 +35,13 @@
    print("here comes info on the args variable:")
    print(kwargs.get('args',None))
def testWebAnalysis(run, **kwargs):
    print("Simulations are located in "+run.Dir.fullpath())
    print("\n\nStatistics file:")
    print(run.Statistics.readText())
hosts=({'name':'natalie','address':'kabinet.penic.eu', 'runs':Runs, 'username':'samo', 'remotebasepath':'simulations-test/subdir/subdir'},
    {'name':'Hestia','address':'127.0.0.1', 'runs':Runs, 'username':'samo'})
analyses={'analysis1':analyze,}
analyses={'analysis1':analyze,'webReport':testWebAnalysis}
tsmgr.start(hosts, analyses=analyses)
trisurf/WebTrisurf.py
@@ -11,7 +11,7 @@
class TsWEB(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        parsed_path=urlparse(self.path)
        """    message_parts = [
        message_parts = [
                'CLIENT VALUES:',
                'client_address=%s (%s)' % (self.client_address, self.address_string()),
                'command=%s' % self.command,
@@ -30,14 +30,18 @@
        for name, value in sorted(self.headers.items()):
            message_parts.append('%s=%s' % (name, value.rstrip()))
        message_parts.append('')
        message = '<br>'.join(message_parts) """
        message = '<br>'.join(message_parts)
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"<h1>Trisurf-ng manager web interface</h1><hr>")
        oldstdout=sys.stdout
        process=subprocess.Popen (['/usr/bin/python3', sys.argv[0], '-s', '--html'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        if(parsed_path.path=='/analysis'):
            process=subprocess.Popen (['/usr/bin/python3', sys.argv[0], '--analysis', parsed_path.query, '--html'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        else:
            process=subprocess.Popen (['/usr/bin/python3', sys.argv[0], '-s', '--html'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr= process.communicate()
        output=stdout.decode('ascii')
        output=output+message
        output=output.replace('\n','<BR>')
        output=bytearray(output,'ascii')
        self.wfile.write(output)