Repository: climate
Updated Branches:
  refs/heads/master 96ab3eaf1 -> 1373563d2


CLIMATE-762


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/37d1f30f
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/37d1f30f
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/37d1f30f

Branch: refs/heads/master
Commit: 37d1f30f6644f1b23654b452030d2200b2909e66
Parents: 4cf79f3
Author: Michael Anderson <michaelanderson@Michaels-iMac.local>
Authored: Wed Jan 3 20:56:57 2018 -0500
Committer: Michael Anderson <michaelanderson@Michaels-iMac.local>
Committed: Wed Jan 3 20:56:57 2018 -0500

----------------------------------------------------------------------
 ocw-ui/backend/run_webservices.py | 37 ++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/37d1f30f/ocw-ui/backend/run_webservices.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/run_webservices.py 
b/ocw-ui/backend/run_webservices.py
index dae2567..d329736 100644
--- a/ocw-ui/backend/run_webservices.py
+++ b/ocw-ui/backend/run_webservices.py
@@ -16,11 +16,44 @@
 #
 ''' OCW UI Backend web services initialization. '''
 
+import os
+import sys
+
 from bottle import Bottle, response, static_file
-from local_file_metadata_extractors import lfme_app
+
 from directory_helpers import dir_app
-from rcmed_helpers import rcmed_app
+from local_file_metadata_extractors import lfme_app
 from processing import processing_app
+from rcmed_helpers import rcmed_app
+
+
+def link_to_frontend():
+    """
+    The backend expects a link to a directory called frontend at the same 
level.
+    Attempt to create one if it does not exist.
+    """
+    backend_path = os.path.dirname(os.path.realpath(__file__))
+    link_path = backend_path + '/frontend'
+    frontend_path = backend_path.replace('backend', 'frontend')
+
+    if not os.path.isdir(link_path):
+        print("Expected to find a linked directory to the frontend.")
+        print("Checking default location %s." % frontend_path)
+        if os.path.isdir(frontend_path):
+            print("Attempting to create linked directory to %s." % 
frontend_path)
+            os.symlink(frontend_path, link_path)
+        else:
+            print("Frontend directory not found in %s." % frontend_path)
+            print("Either install the frontend to the default directory "
+                  "or manually create a link in the backend directory called "
+                  "'frontend' to the directory where the front end is 
installed.")
+            return 1
+
+    return 0
+
+
+if link_to_frontend():
+    sys.exit(1)
 
 app = Bottle()
 app.mount('/lfme/', lfme_app)

Reply via email to