import os
import subprocess
import sys

try:
    from flask import Flask
    import flask_login
    from flask_restless import APIManager
    from flask_sqlalchemy import SQLAlchemy
    import requests
except ImportError:
    INTERP = "venv/bin/python"

    if os.path.relpath(sys.executable, os.getcwd()) != INTERP:
        try:
            os.execl(INTERP, INTERP, *sys.argv)
        except OSError:
            sys.exit("Could not find virtual environment. Run `:~$ ./setup.sh`")
    else:
        sys.exit("Could not find requirements. Are they all included in requirements.txt? Run `:~$ ./setup.sh`")


application = Flask(__name__)


@application.route("/")
def index():
    return "Hello, world!"


@application.route("/update")
def update():
    subprocess.call(['git', 'fetch', 'origin'])
    subprocess.call(['git', 'pull'])
    subprocess.call(['mkdir', 'tmp'])
    subprocess.call(['touch', 'tmp/restart.txt'])


@application.route("/big_update")
def bigUpdate():
    subprocess.call(['./setup.sh'])


if __name__ == "__main__":
    application.run()

@@ -824,24 +824,37 @@
 ', 'pull'%5D)%0A
+    try:%0A    
     subproce
@@ -852,24 +852,30 @@
  subprocess.
+check_
 call(%5B'mkdir
@@ -881,24 +881,82 @@
 r', 'tmp'%5D)%0A
+    except subprocess.CalledProcessError, e:%0A        pass%0A
     subproce
@@ -993,16 +993,45 @@
 .txt'%5D)%0A
+    return %22Please restart.%22%0A
 %0A%0A@appli

Improve error catching logic for update