Commit 8cfc1e39 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Merge branch 'upstream-cinemasci' into cinema-updates

# By Cinemasci Python Upstream
* upstream-cinemasci:
  cinemasci 2020-12-23 (c333df4d)
parents 69958644 8db627dc
Pipeline #207116 passed with stage
......@@ -105,6 +105,9 @@ class cdb:
mapping.append((parameterKey, filepaths))
return mapping
def get_parameter_names(self):
return self.parameternames
def parameter_exists(self, parameter):
"""Check if a parameter exists
"""
......
......@@ -11,6 +11,7 @@ from os import access
from os import R_OK
import pathlib
import json
import cinemasci
#
# global variables - can't seem to add an instance variable to the
......@@ -29,6 +30,34 @@ def set_install_path():
CinemaInstallPath = CinemaInstallPath.strip("/server")
CinemaInstallPath = "/" + CinemaInstallPath + "/viewers"
def verify_cinema_database( viewer, cdb, assetname ):
result = False
if viewer == "view":
# this is the default case
if assetname is None:
assetname = "FILE"
db = cinemasci.new("cdb", {"path": cdb})
db.read_data_from_file()
if db.parameter_exists(assetname):
result = True
else:
print("")
print("ERROR: Cinema viewer \'view\' is looking for a column named \'{}\', but the".format(assetname))
print(" the cinema database \'{}\' doesn't have one.".format(cdb))
print("")
print(" use \'--assetname <name>\' where <name> is one of these possible values")
print(" that were found in \'{}\':".format(cdb))
print("")
print(" \"" + ' '.join(db.get_parameter_names()) + "\"")
print("")
else:
result = True
return result
#
# CinemaSimpleReqestHandler
#
......@@ -193,14 +222,15 @@ def run_cinema_server( viewer, data, port, assetname="FILE"):
chdir(datadir)
set_install_path()
cin_handler = CinemaSimpleRequestHandler
cin_handler.base_path = cinemadir
cin_handler.verbose = False
cin_handler.viewer = viewer
cin_handler.assetname = assetname
with socketserver.TCPServer(("", port), cin_handler) as httpd:
urlstring = "{}:{}".format(localhost, port)
print(urlstring)
httpd.serve_forever()
if verify_cinema_database(viewer, cinemadir, assetname) :
set_install_path()
cin_handler = CinemaSimpleRequestHandler
cin_handler.base_path = cinemadir
cin_handler.verbose = False
cin_handler.viewer = viewer
cin_handler.assetname = assetname
with socketserver.TCPServer(("", port), cin_handler) as httpd:
urlstring = "{}:{}".format(localhost, port)
print(urlstring)
httpd.serve_forever()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment