<NME> graphical-app-launcher.py
<BEF> #!/usr/bin/env python

import os
import subprocess

if __name__ == '__main__':
    if os.environ.has_key('GRAPHICAL_APP'):
        graphical_app = os.environ['GRAPHICAL_APP']
        process = subprocess.Popen(graphical_app, shell=True,
                                   stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        stdoutdata, stderrordata = process.communicate()
        if os.environ.has_key('ARGS'):
            extra_args = os.environ['ARGS']
            command = graphical_app + ' ' + extra_args
        else:
            command = graphical_app

        process = subprocess.Popen(command, shell=True,
                                   stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

        def print_return_code_and_shutdown(return_code):
            for line in process.stdout.readlines():
                sys.stdout.write(line)
            with open('/tmp/graphical-app.return_code', 'w') as fp:
                fp.write(str(return_code))
            subprocess.call(['sudo', 'supervisorctl', 'shutdown'],
                            stdout=subprocess.PIPE)
            sys.exit(return_code)

        def signal_handler(signum, frame):
            print_return_code_and_shutdown(128 + signum)
        signal.signal(signal.SIGTERM, signal_handler)

        while True:
            output = process.stdout.readline()
            if sys.version_info[0] >= 3:
                output = output.decode()
            if output == '' and process.poll() is not None:
                break
            print(output.rstrip())

        print_return_code_and_shutdown(process.returncode)

<MSG> Rename GRAPHICAL_APP to APP for brevity.

<DFF> @@ -4,8 +4,8 @@ import os
 import subprocess
 
 if __name__ == '__main__':
-    if os.environ.has_key('GRAPHICAL_APP'):
-        graphical_app = os.environ['GRAPHICAL_APP']
+    if os.environ.has_key('APP'):
+        graphical_app = os.environ['APP']
         process = subprocess.Popen(graphical_app, shell=True,
                                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
         stdoutdata, stderrordata = process.communicate()

{'addition_count': 2, 'commit_subject': 'Rename GRAPHICAL_APP to APP for brevity.', 'deletion_count': 2, 'file_extension': '.py', 'lang': 'py', 'license': 'apache-2.0', 'repo_name': 'thewtex/docker-opengl'}