def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), configFileName) # holder for global variables and other parameters class prmz: pass try: prmz.DERIVATIVEGRID = config.get('search', 'DERIVATIVEGRID') prmz.DERIVATIVECOMPACT = config.get('search', 'DERIVATIVECOMPACT') prmz.SIZEGRID = config.get('search', 'SIZEGRID') prmz.SIZECOMPACT = config.get('search', 'SIZECOMPACT') except: loginfo('search startup', 'could not get image layout (size and derviative to use) from config file, using defaults', {}, {}) prmz.DERIVATIVEGRID = "Thumbnail" prmz.DERIVATIVECOMPACT = "Thumbnail" prmz.SIZEGRID = "100px" prmz.SIZECOMPACT = "100px" try: prmz.MAXMARKERS = int(config.get('search', 'MAXMARKERS')) prmz.MAXRESULTS = int(config.get('search', 'MAXRESULTS')) prmz.MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) prmz.MAXFACETS = int(config.get('search', 'MAXFACETS')) prmz.EMAILABLEURL = config.get('search', 'EMAILABLEURL') prmz.IMAGESERVER = config.get('search', 'IMAGESERVER') prmz.CSPACESERVER = config.get('search', 'CSPACESERVER') prmz.INSTITUTION = config.get('search', 'INSTITUTION') prmz.BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') prmz.BMAPPERDIR = config.get('search', 'BMAPPERDIR') prmz.BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') prmz.BMAPPERURL = config.get('search', 'BMAPPERURL') # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') prmz.LOCALDIR = config.get('search', 'LOCALDIR') prmz.SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') prmz.SEARCH_QUALIFIERS = [str(x) for x in prmz.SEARCH_QUALIFIERS] #prmz.FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') prmz.CSVPREFIX = config.get('search', 'CSVPREFIX') prmz.CSVEXTENSION = config.get('search', 'CSVEXTENSION') # prmz.TITLE = config.get('search', 'TITLE') prmz.SUGGESTIONS = config.get('search', 'SUGGESTIONS') #LAYOUT = config.get('search', 'LAYOUT') buttonoptions = config.get('search', 'BUTTONOPTIONS') prmz.BUTTONOPTIONS = json.loads(buttonoptions.replace('\n', '')) prmz.DEFAULTDISPLAY = config.get('search', 'DEFAULTDISPLAY') prmz.VERSION = getversion() except: loginfo('search startup', 'ERROR in configuration file %s' % path.join(settings.BASE_DIR, 'config/' + configFileName + '.cfg'), {}, {}) loginfo('search startup', 'this webapp will probably not work.', {}, {}) raise try: prmz.CSRECORDTYPE = config.get('search', 'CSRECORDTYPE') except: prmz.CSRECORDTYPE = 'cataloging' # default return prmz
def index(request): if request.path == '/': response = redirect('landing') return response appList = getapplist(request) if not request.user.is_authenticated: appList = [app for app in appList if app[0] in publicApps] context = {} context['version'] = appconfig.getversion() context['appList'] = appList context['labels'] = 'name file'.split(' ') context['apptitle'] = TITLE context['hostname'] = hostname context['device'] = devicetype(request) context['timestamp'] = time.strftime("%b %d %Y %H:%M:%S", time.localtime()) try: alert_config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'alert') context['ALERT'] = alert_config.get('alert', 'ALERT') context['MESSAGE'] = alert_config.get('alert', 'MESSAGE') except: context['ALERT'] = '' return render(request, 'listApps.html', context)
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), configFileName) try: DERIVATIVEGRID = config.get('search', 'DERIVATIVEGRID') DERIVATIVECOMPACT = config.get('search', 'DERIVATIVECOMPACT') SIZEGRID = config.get('search', 'SIZEGRID') SIZECOMPACT = config.get('search', 'SIZECOMPACT') except: print 'could not get image layout (size and derviative to use) from config file, using defaults' DERIVATIVEGRID = "Thumbnail" DERIVATIVECOMPACT = "Thumbnail" SIZEGRID = "100px" SIZECOMPACT = "100px" try: MAXMARKERS = int(config.get('search', 'MAXMARKERS')) MAXRESULTS = int(config.get('search', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) MAXFACETS = int(config.get('search', 'MAXFACETS')) EMAILABLEURL = config.get('search', 'EMAILABLEURL') IMAGESERVER = config.get('search', 'IMAGESERVER') CSPACESERVER = config.get('search', 'CSPACESERVER') INSTITUTION = config.get('search', 'INSTITUTION') BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') BMAPPERDIR = config.get('search', 'BMAPPERDIR') BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') BMAPPERURL = config.get('search', 'BMAPPERURL') # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') LOCALDIR = config.get('search', 'LOCALDIR') SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') SEARCH_QUALIFIERS = [unicode(x) for x in SEARCH_QUALIFIERS] FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') CSVPREFIX = config.get('search', 'CSVPREFIX') CSVEXTENSION = config.get('search', 'CSVEXTENSION') # TITLE = config.get('search', 'TITLE') SUGGESTIONS = config.get('search', 'SUGGESTIONS') LAYOUT = config.get('search', 'LAYOUT') try: VERSION = popen( "cd " + settings.BASE_PARENT_DIR + " ; /usr/bin/git describe --always").read().strip() if VERSION == '': # try alternate location for git (this is the usual Mac location) VERSION = popen( "/usr/local/bin/git describe --always").read().strip() except: VERSION = 'Unknown' except: raise print 'error in configuration file %s' % path.join( settings.BASE_PARENT_DIR, 'config/' + configFileName) print 'this webapp will probably not work.' return MAXMARKERS, MAXRESULTS, MAXLONGRESULTS, MAXFACETS, IMAGESERVER, BMAPPERSERVER, BMAPPERDIR, BMAPPERURL, BMAPPERCONFIGFILE, CSVPREFIX, CSVEXTENSION, LOCALDIR, SEARCH_QUALIFIERS, EMAILABLEURL, SUGGESTIONS, LAYOUT, CSPACESERVER, INSTITUTION, VERSION, FIELDDEFINITIONS, DERIVATIVECOMPACT, DERIVATIVEGRID, SIZECOMPACT, SIZEGRID
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), configFileName) # holder for global variables and other parameters class prmz: pass try: prmz.DERIVATIVEGRID = config.get('search', 'DERIVATIVEGRID') prmz.DERIVATIVECOMPACT = config.get('search', 'DERIVATIVECOMPACT') prmz.SIZEGRID = config.get('search', 'SIZEGRID') prmz.SIZECOMPACT = config.get('search', 'SIZECOMPACT') except: print 'could not get image layout (size and derviative to use) from config file, using defaults' prmz.DERIVATIVEGRID = "Thumbnail" prmz.DERIVATIVECOMPACT = "Thumbnail" prmz.SIZEGRID = "100px" prmz.SIZECOMPACT = "100px" try: prmz.MAXMARKERS = int(config.get('search', 'MAXMARKERS')) prmz.MAXRESULTS = int(config.get('search', 'MAXRESULTS')) prmz.MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) prmz.MAXFACETS = int(config.get('search', 'MAXFACETS')) prmz.EMAILABLEURL = config.get('search', 'EMAILABLEURL') prmz.IMAGESERVER = config.get('search', 'IMAGESERVER') prmz.CSPACESERVER = config.get('search', 'CSPACESERVER') prmz.INSTITUTION = config.get('search', 'INSTITUTION') prmz.BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') prmz.BMAPPERDIR = config.get('search', 'BMAPPERDIR') prmz.BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') prmz.BMAPPERURL = config.get('search', 'BMAPPERURL') # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') prmz.LOCALDIR = config.get('search', 'LOCALDIR') prmz.SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') prmz.SEARCH_QUALIFIERS = [unicode(x) for x in prmz.SEARCH_QUALIFIERS] #prmz.FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') prmz.CSVPREFIX = config.get('search', 'CSVPREFIX') prmz.CSVEXTENSION = config.get('search', 'CSVEXTENSION') # prmz.TITLE = config.get('search', 'TITLE') prmz.SUGGESTIONS = config.get('search', 'SUGGESTIONS') #LAYOUT = config.get('search', 'LAYOUT') buttonoptions = config.get('search', 'BUTTONOPTIONS') prmz.BUTTONOPTIONS = json.loads(buttonoptions.replace('\n', '')) prmz.DEFAULTDISPLAY = config.get('search', 'DEFAULTDISPLAY') prmz.VERSION = getversion() except: print 'ERROR in configuration file %s' % path.join(settings.BASE_PARENT_DIR, 'config/' + configFileName + '.cfg') print 'this webapp will probably not work.' raise try: prmz.CSRECORDTYPE = config.get('search', 'CSRECORDTYPE') except: prmz.CSRECORDTYPE = 'cataloging' # default return prmz
def test_setQuery(self): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), "toolbox") institution = config.get('info','institution') qualifier = '' location = '' updateType = 'inventory' query = dbqueries.setquery('inventory', location, qualifier) self.assertEqual('SELECT' in query, True)
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), configFileName) global MAXMARKERS global MAXRESULTS global MAXLONGRESULTS global MAXFACETS global EMAILABLEURL global IMAGESERVER global CSPACESERVER global INSTITUTION global BMAPPERSERVER global BMAPPERDIR global BMAPPERCONFIGFILE global LOCALDIR global SEARCH_QUALIFIERS global FIELDDEFINITIONS global CSVPREFIX global CSVEXTENSION global SUGGESTIONS global LAYOUT global VERSION try: MAXMARKERS = int(config.get('search', 'MAXMARKERS')) MAXRESULTS = int(config.get('search', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) MAXFACETS = int(config.get('search', 'MAXFACETS')) EMAILABLEURL = config.get('search', 'EMAILABLEURL') IMAGESERVER = config.get('search', 'IMAGESERVER') CSPACESERVER = config.get('search', 'CSPACESERVER') INSTITUTION = config.get('search', 'INSTITUTION') BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') BMAPPERDIR = config.get('search', 'BMAPPERDIR') BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') #SOLRSERVER = config.get('search', 'SOLRSERVER') #SOLRCORE = config.get('search', 'SOLRCORE') LOCALDIR = config.get('search', 'LOCALDIR') SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') CSVPREFIX = config.get('search', 'CSVPREFIX') CSVEXTENSION = config.get('search', 'CSVEXTENSION') #TITLE = config.get('search', 'TITLE') SUGGESTIONS = config.get('search', 'SUGGESTIONS') LAYOUT = config.get('search', 'LAYOUT') try: VERSION = popen("cd " + settings.BASE_PARENT_DIR + " ; /usr/bin/git describe --always").read().strip() if VERSION == '': # try alternate location for git (this is the usual Mac location) VERSION = popen("/usr/local/bin/git describe --always").read().strip() except: VERSION = 'Unknown' except: print 'error in configuration file %s' % path.join(settings.BASE_PARENT_DIR, 'config/' + configFileName) print 'this webapp will probably not work.'
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), configFileName) # holder for global variables and other parameters class prmz: pass try: prmz.DERIVATIVEGRID = config.get('search', 'DERIVATIVEGRID') prmz.DERIVATIVECOMPACT = config.get('search', 'DERIVATIVECOMPACT') prmz.SIZEGRID = config.get('search', 'SIZEGRID') prmz.SIZECOMPACT = config.get('search', 'SIZECOMPACT') except: print 'could not get image layout (size and derviative to use) from config file, using defaults' prmz.DERIVATIVEGRID = "Thumbnail" prmz.DERIVATIVECOMPACT = "Thumbnail" prmz.SIZEGRID = "100px" prmz.SIZECOMPACT = "100px" try: prmz.MAXMARKERS = int(config.get('search', 'MAXMARKERS')) prmz.MAXRESULTS = int(config.get('search', 'MAXRESULTS')) prmz.MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) prmz.MAXFACETS = int(config.get('search', 'MAXFACETS')) prmz.EMAILABLEURL = config.get('search', 'EMAILABLEURL') prmz.IMAGESERVER = config.get('search', 'IMAGESERVER') prmz.CSPACESERVER = config.get('search', 'CSPACESERVER') prmz.INSTITUTION = config.get('search', 'INSTITUTION') prmz.BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') prmz.BMAPPERDIR = config.get('search', 'BMAPPERDIR') prmz.BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') prmz.BMAPPERURL = config.get('search', 'BMAPPERURL') # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') prmz.LOCALDIR = config.get('search', 'LOCALDIR') prmz.SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') prmz.SEARCH_QUALIFIERS = [unicode(x) for x in prmz.SEARCH_QUALIFIERS] #prmz.FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') prmz.CSVPREFIX = config.get('search', 'CSVPREFIX') prmz.CSVEXTENSION = config.get('search', 'CSVEXTENSION') # prmz.TITLE = config.get('search', 'TITLE') prmz.SUGGESTIONS = config.get('search', 'SUGGESTIONS') #LAYOUT = config.get('search', 'LAYOUT') try: prmz.VERSION = popen("cd " + settings.BASE_PARENT_DIR + " ; /usr/bin/git describe --always").read().strip() if prmz.VERSION == '': # try alternate location for git (this is the usual Mac location) prmz.VERSION = popen("/usr/local/bin/git describe --always").read().strip() except: prmz.VERSION = 'Unknown' except: print 'error in configuration file %s' % path.join(settings.BASE_PARENT_DIR, 'config/' + configFileName) print 'this webapp will probably not work.' return prmz
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), configFileName) try: DERIVATIVEGRID = config.get('search', 'DERIVATIVEGRID') DERIVATIVECOMPACT = config.get('search', 'DERIVATIVECOMPACT') SIZEGRID = config.get('search', 'SIZEGRID') SIZECOMPACT = config.get('search', 'SIZECOMPACT') except: print 'could not get image layout (size and derviative to use) from config file, using defaults' DERIVATIVEGRID = "Thumbnail" DERIVATIVECOMPACT = "Thumbnail" SIZEGRID = "100px" SIZECOMPACT = "100px" try: MAXMARKERS = int(config.get('search', 'MAXMARKERS')) MAXRESULTS = int(config.get('search', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) MAXFACETS = int(config.get('search', 'MAXFACETS')) EMAILABLEURL = config.get('search', 'EMAILABLEURL') IMAGESERVER = config.get('search', 'IMAGESERVER') CSPACESERVER = config.get('search', 'CSPACESERVER') INSTITUTION = config.get('search', 'INSTITUTION') BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') BMAPPERDIR = config.get('search', 'BMAPPERDIR') BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') BMAPPERURL = config.get('search', 'BMAPPERURL') # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') LOCALDIR = config.get('search', 'LOCALDIR') SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') SEARCH_QUALIFIERS = [unicode(x) for x in SEARCH_QUALIFIERS] FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') CSVPREFIX = config.get('search', 'CSVPREFIX') CSVEXTENSION = config.get('search', 'CSVEXTENSION') # TITLE = config.get('search', 'TITLE') SUGGESTIONS = config.get('search', 'SUGGESTIONS') LAYOUT = config.get('search', 'LAYOUT') try: VERSION = popen("cd " + settings.BASE_PARENT_DIR + " ; /usr/bin/git describe --always").read().strip() if VERSION == '': # try alternate location for git (this is the usual Mac location) VERSION = popen("/usr/local/bin/git describe --always").read().strip() except: VERSION = 'Unknown' except: raise print 'error in configuration file %s' % path.join(settings.BASE_PARENT_DIR, 'config/' + configFileName) print 'this webapp will probably not work.' return MAXMARKERS, MAXRESULTS, MAXLONGRESULTS, MAXFACETS, IMAGESERVER, BMAPPERSERVER, BMAPPERDIR, BMAPPERURL, BMAPPERCONFIGFILE, CSVPREFIX, CSVEXTENSION, LOCALDIR, SEARCH_QUALIFIERS, EMAILABLEURL, SUGGESTIONS, LAYOUT, CSPACESERVER, INSTITUTION, VERSION, FIELDDEFINITIONS, DERIVATIVECOMPACT, DERIVATIVEGRID, SIZECOMPACT, SIZEGRID
def initialize(cls, handleAuthNRequest, clearPasswordCache=False): if handleAuthNRequest: cls.handleAuthNRequest = handleAuthNRequest # this is a delegate method that gets called by our AuthN method if clearPasswordCache: cls.resetPasswordCache() cls.config = cspace.getConfig(path.dirname(__file__), CSPACE_AUTHN_CONFIG_FILENAME) if cspace.getConfigOptionWithSection(cls.config, CONFIGSECTION_AUTHN_INFO, CSPACE_AUTHN_OVERRIDE_PROPERTY) == "True": cls.overrideWithConfig = True else: cls.overrideWithConfig = False
def get_entity(request, entitytype, responsemimetype): """ Connects to CollectionSpace server, makes request to cspace-services RESTful API. Returns xml payload or images. :param request: :param entitytype: :param responsemimetype: :return: """ #config = cspace_django_site.getConfig() #connection = cspace.connection.create_connection(config, request.user) #(url, data, statusCode) = connection.make_get_request('cspace-services/%s' % image) #return HttpResponse(data, content_type='image/jpeg') config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'eloan') username = config.get('connect', 'username') password = config.get('connect', 'password') hostname = config.get('connect', 'hostname') realm = config.get('connect', 'realm') protocol = config.get('connect', 'protocol') port = config.get('connect', 'port') port = ':%s' % port if port else '' server = protocol + "://" + hostname + port passman = urllib2.HTTPPasswordMgr() passman.add_password(realm, server, username, password) authhandler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener) url = "%s/cspace-services/%s" % (server, entitytype) #print "<p>%s</p>" % url elapsedtime = 0 # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('eloan startup', '-', '%s' % server)) try: elapsedtime = time.time() f = urllib2.urlopen(url) data = f.read() elapsedtime = time.time() - elapsedtime except urllib2.URLError, e: if hasattr(e, 'reason'): print 'We failed to reach a server.' print 'Reason: ', e.reason else: print 'The server couldn\'t fulfill the request.' print 'Error code: ', e.code
def get_entity(request, entitytype, responsemimetype): """ Connects to CollectionSpace server, makes request to cspace-services RESTful API. Returns xml payload or images. :param request: :param entitytype: :param responsemimetype: :return: """ config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'eloan') username = config.get('connect', 'username') password = config.get('connect', 'password') hostname = config.get('connect', 'hostname') realm = config.get('connect', 'realm') protocol = config.get('connect', 'protocol') port = config.get('connect', 'port') port = ':%s' % port if port else '' server = protocol + "://" + hostname + port passman = urllib.request.HTTPPasswordMgr() passman.add_password(realm, server, username, password) authhandler = urllib.request.HTTPBasicAuthHandler(passman) opener = urllib.request.build_opener(authhandler) urllib.request.install_opener(opener) url = "%s/cspace-services/%s" % (server, entitytype) #loginfo('eloan', "<p>%s</p>" % url, {}, {}) elapsedtime = 0 # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('eloan startup', '-', '%s' % server)) try: elapsedtime = time.time() f = urllib.request.urlopen(url) data = f.read() elapsedtime = time.time() - elapsedtime except urllib.request.URLError as e: if hasattr(e, 'reason'): loginfo('eloan', 'We failed to reach a server.', {}, {}) loginfo('eloan', 'Reason: ', e.reason, {}) return HttpResponse(status=e.code) else: loginfo('eloan', 'The server couldn\'t fulfill the request.', {}, {}) loginfo('eloan', 'Error code: ', e.code, {}) else: return HttpResponse(data, content_type=responsemimetype)
def __init__(self): config = cspace.getConfig( path.join(settings.BASE_PARENT_DIR, 'config'), 'cinestats') self.DBNAME = config.get('connect', 'dbname') self.USER = config.get('connect', 'dbuser') self.PW = config.get('connect', 'dbpassword') self.SERVER = config.get('connect', 'servername') self.MODE = config.get('connect', 'sslmode') self.PORT = config.get('connect', 'port') # for psycopg2 self.connect_string = "host=%s port=%s dbname=%s user=%s password=%s sslmode=%s" % ( self.SERVER, self.PORT, self.DBNAME, self.USER, self.PW, self.MODE)
def test_setQuery(self): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), "testConnector") institution = config.get('info','institution') qualifier = '' location = '' updateType = 'inventory' query = dbconnector.setquery('inventory', location, qualifier, institution) elapsedtime = time.time() locations = dbconnector.getlocations(location, location, 10, config, updateType, institution) elapsedtime = time.time() - elapsedtime sys.stderr.write('all objects: %s :: %s\n' % (location, elapsedtime)) self.assertEqual(len(locations), 0)
def loadConfiguration(configFileName): config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, "config"), configFileName) # holder for global variables and other parameters class prmz: pass try: prmz.DERIVATIVEGRID = config.get("search", "DERIVATIVEGRID") prmz.DERIVATIVECOMPACT = config.get("search", "DERIVATIVECOMPACT") prmz.SIZEGRID = config.get("search", "SIZEGRID") prmz.SIZECOMPACT = config.get("search", "SIZECOMPACT") except: print "could not get image layout (size and derviative to use) from config file, using defaults" prmz.DERIVATIVEGRID = "Thumbnail" prmz.DERIVATIVECOMPACT = "Thumbnail" prmz.SIZEGRID = "100px" prmz.SIZECOMPACT = "100px" try: prmz.MAXMARKERS = int(config.get("search", "MAXMARKERS")) prmz.MAXRESULTS = int(config.get("search", "MAXRESULTS")) prmz.MAXLONGRESULTS = int(config.get("search", "MAXLONGRESULTS")) prmz.MAXFACETS = int(config.get("search", "MAXFACETS")) prmz.EMAILABLEURL = config.get("search", "EMAILABLEURL") prmz.IMAGESERVER = config.get("search", "IMAGESERVER") prmz.CSPACESERVER = config.get("search", "CSPACESERVER") prmz.INSTITUTION = config.get("search", "INSTITUTION") prmz.BMAPPERSERVER = config.get("search", "BMAPPERSERVER") prmz.BMAPPERDIR = config.get("search", "BMAPPERDIR") prmz.BMAPPERCONFIGFILE = config.get("search", "BMAPPERCONFIGFILE") prmz.BMAPPERURL = config.get("search", "BMAPPERURL") # SOLRSERVER = config.get('search', 'SOLRSERVER') # SOLRCORE = config.get('search', 'SOLRCORE') prmz.LOCALDIR = config.get("search", "LOCALDIR") prmz.SEARCH_QUALIFIERS = config.get("search", "SEARCH_QUALIFIERS").split(",") prmz.SEARCH_QUALIFIERS = [unicode(x) for x in prmz.SEARCH_QUALIFIERS] # prmz.FIELDDEFINITIONS = config.get('search', 'FIELDDEFINITIONS') prmz.CSVPREFIX = config.get("search", "CSVPREFIX") prmz.CSVEXTENSION = config.get("search", "CSVEXTENSION") # prmz.TITLE = config.get('search', 'TITLE') prmz.SUGGESTIONS = config.get("search", "SUGGESTIONS") # LAYOUT = config.get('search', 'LAYOUT') prmz.VERSION = getversion() except: print "error in configuration file %s" % path.join(settings.BASE_PARENT_DIR, "config/" + configFileName) print "this webapp will probably not work." return prmz
def initialize(cls, handleAuthNRequest, clearPasswordCache=False): if handleAuthNRequest: cls.handleAuthNRequest = handleAuthNRequest # a delegate method that gets called by our AuthN method if clearPasswordCache: cls.resetPasswordCache() cls.config = cspace.getConfig(path.dirname(__file__), CSPACE_AUTHN_CONFIG_FILENAME) if cspace.getConfigOptionWithSection(cls.config, CONFIGSECTION_AUTHN_INFO, CSPACE_AUTHN_OVERRIDE_PROPERTY) \ == "True": cls.overrideWithConfig = True else: cls.overrideWithConfig = False
def configure_common_tools(context, request, action, webappconfig): context['serverlabel'] = webappconfig.get('info', 'serverlabel') context['serverlabelcolor'] = webappconfig.get('info', 'serverlabelcolor') context['institution'] = webappconfig.get('info', 'institution') context['apptitle'] = webappconfig.get(action, 'apptitle') context['version'] = appconfig.getversion() context['device'] = devicetype(request) context['timestamp'] = time.strftime("%b %d %Y %H:%M:%S", time.localtime()) context['labels'] = 'name file'.split(' ') try: alert_config = getConfig(os.path.join(settings.BASE_DIR, 'config'), 'alert') context['ALERT'] = alert_config.get('alert', 'ALERT') context['MESSAGE'] = alert_config.get('alert', 'MESSAGE') except: context['ALERT'] = '' return context
def __init__(self): config = cspace.getConfig(path.dirname(__file__), "cinefiles") self.DBNAME = config.get("connect", "dbname") self.USER = config.get("connect", "dbuser") self.PW = config.get("connect", "dbpassword") self.SERVER = config.get("connect", "servername") self.MODE = config.get("connect", "sslmode") self.PORT = config.get("connect", "port") # for psycopg2 self.connect_string = "host=%s port=%s dbname=%s user=%s password=%s sslmode=%s" % ( self.SERVER, self.PORT, self.DBNAME, self.USER, self.PW, self.MODE, )
def index(request): context = {} context['version'] = appconfig.getversion() context['labels'] = 'name file'.split(' ') context['apptitle'] = TITLE context['hostname'] = hostname context['device'] = devicetype(request) context['timestamp'] = time.strftime("%b %d %Y %H:%M:%S", time.localtime()) html = '' topLocs = sorted(locMap.keys()) for i, l in enumerate(topLocs): #cols = int(math.log(objectCounts[l],2)/3) cols = makeBin(objectCounts[l]) if cols == 0: cols = 1 html += f'<div class="box col{cols}"><div class="show left" data-loc="{l}">{l}</div><div class="right">{objectCounts[l]}</div>' # % (cols,l,objectCounts[l],cols,l) sublocs = sorted(locMap[l].keys()) html += '''<div class="bottom" id="%s" style="display:none">''' % l for subloc in sublocs: combined = l + ' ' + subloc locCount = len(roomCounts[combined]) html += '''<div class="show bottom" data-loc="%s"> %s %s ''' % ( combined, subloc, locMap[l][subloc]) html += '''<div class="locdetail" id="%s" style="display:none;"><i>%s</i>:<br/>%s locs, %s objs</div></div>''' % ( combined, combined, locCount, locMap[l][subloc]) html += '</div></div>' context['html'] = html try: alert_config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'alert') context['ALERT'] = alert_config.get('alert', 'ALERT') context['MESSAGE'] = alert_config.get('alert', 'MESSAGE') except: context['ALERT'] = '' return render(request, 'vp.html', context)
# global variables from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'publicsearch') MAXMARKERS = int(config.get('search', 'MAXMARKERS')) MAXRESULTS = int(config.get('search', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('search', 'MAXLONGRESULTS')) MAXFACETS = int(config.get('search', 'MAXFACETS')) IMAGESERVER = config.get('search', 'IMAGESERVER') BMAPPERSERVER = config.get('search', 'BMAPPERSERVER') BMAPPERDIR = config.get('search', 'BMAPPERDIR') BMAPPERCONFIGFILE = config.get('search', 'BMAPPERCONFIGFILE') BMAPPERURL = config.get('search', 'BMAPPERURL') SOLRSERVER = config.get('search', 'SOLRSERVER') SOLRCORE = config.get('search', 'SOLRCORE') LOCALDIR = config.get('search', 'LOCALDIR') DROPDOWNS = config.get('search', 'DROPDOWNS').split(',') SEARCH_QUALIFIERS = config.get('search', 'SEARCH_QUALIFIERS').split(',') TITLE = config.get('search', 'TITLE') # still need to move this into a config file. # could be the same one as above, or a different one. PARMS = { # this first one is special 'keyword': ['Keyword', 'true', 'a keyword search value, please', 'text', ''],
from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from django.template import RequestContext from django.http import HttpResponse, HttpResponseRedirect from django import forms from operator import itemgetter from common import cspace # we use the config file reading function from cspace_django_site import settings from cspace_django_site.main import cspace_django_site mainConfig = cspace_django_site.getConfig() config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'ireports') JRXMLDIRPATTERN = config.get('connect', 'JRXMLDIRPATTERN') # alas, there are many ways the XML parsing functionality might be installed. # the following code attempts to find and import the best... try: from xml.etree.ElementTree import tostring, parse, Element, fromstring print("running with xml.etree.ElementTree") except ImportError: try: from lxml import etree print("running with lxml.etree") except ImportError: try: # normal cElementTree install import cElementTree as etree
from common.utils import setDisplayType, setConstants, loginfo from common.utils import setupGoogleMap, setupBMapper, computeStats, setupCSV, setupKML, setup4PDF # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') #loginfo('internal','%s :: %s :: %s' % ('internal portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER)), {}, {}) # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'internal') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) def direct(request): return redirect('search/') @login_required() def search(request): if request.method == 'GET' and request.GET != {}: context = {'searchValues': request.GET} context = doSearch(context, prmz, request) else:
def test_connection(self): # No module level setUp function, so just run this first config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), "testConnector") self.assertEqual(dbconnector.testDB(config), "OK")
# global variables from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, "config"), "search") MAXMARKERS = int(config.get("search", "MAXMARKERS")) MAXRESULTS = int(config.get("search", "MAXRESULTS")) MAXLONGRESULTS = int(config.get("search", "MAXLONGRESULTS")) MAXFACETS = int(config.get("search", "MAXFACETS")) IMAGESERVER = config.get("search", "IMAGESERVER") BMAPPERSERVER = config.get("search", "BMAPPERSERVER") BMAPPERDIR = config.get("search", "BMAPPERDIR") BMAPPERCONFIGFILE = config.get("search", "BMAPPERCONFIGFILE") SOLRSERVER = config.get("search", "SOLRSERVER") SOLRCORE = config.get("search", "SOLRCORE") LOCALDIR = config.get("search", "LOCALDIR") DROPDOWNS = config.get("search", "DROPDOWNS").split(",") SEARCH_QUALIFIERS = config.get("search", "SEARCH_QUALIFIERS").split(",") # still need to move this into a config file. # could be the same one as above, or a different one. PARMS = { # this first one is special "keyword": ["Keyword", "true", "a keyword search value, please", "text", ""], # the rest are mapping the solr field names to django form labels and fields "csid": ["id", "true", "", "id", ""], "accession": ["Object Number", "true", "", "objectnumber_s", ""], "objectname": ["Object Name", "true", "", "objectname_txt", ""],
from django import forms from cspace_django_site.main import cspace_django_site from common.utils import writeCsv, doSearch, setupGoogleMap, setupBMapper, computeStats, setupCSV, setup4Print, setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') print 'Configuration for common successfully read' # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'internal') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('internal portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER))) def direct(request): return redirect('search/') @login_required() def search(request): if request.method == 'GET' and request.GET != {}:
# appLayout[app][role]['nextstate'] = row[6] f.close() return appLayout except IOError: message = 'Could not read (or maybe parse) rows from %s' % parmFile return message, -1 except: raise # global variables config = cspace.getConfig(os.path.join(settings.BASE_DIR, 'config'), 'toolbox') APPDIR = os.path.join(settings.BASE_DIR, 'toolbox', config.get('info', 'appdir')) institution = config.get('info', 'institution') deployment = config.get('info', 'serverlabel') connect_string = config.get('connect', 'connect_string') schemacolor1 = config.get('info', 'schemacolor1') deploymentcolor = config.get('info', 'serverlabelcolor') APPS = getapplist(APPDIR, institution, deployment) APPS['json'] = ['JSON'] try: suggestions = config.get('connect', 'suggestions') except: suggestions = None appLayout = definefields(
from PIL import Image from PIL.ExifTags import TAGS import csv import codecs import re import json import logging from xml.sax.saxutils import escape from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path, listdir from os.path import isfile, isdir, join config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'uploadmedia') TEMPIMAGEDIR = config.get('files', 'directory') JOBDIR = path.join(TEMPIMAGEDIR, '%s') SERVERINFO = { 'serverlabelcolor': config.get('info', 'serverlabelcolor'), 'serverlabel': config.get('info', 'serverlabel') } if isdir(TEMPIMAGEDIR): print "Using %s as working directory for images and metadata files" % TEMPIMAGEDIR else: raise Exception("working directory %s does not exist. this webapp will not work!" % TEMPIMAGEDIR) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__)
def test_connection(self): # No module level setUp function, so just run this first config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), "testConnector") self.assertEqual(connector.testDB(config), "OK")
# global variables from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'eloan') MAXMARKERS = int(config.get('eloan', 'MAXMARKERS')) MAXRESULTS = int(config.get('eloan', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('eloan', 'MAXLONGRESULTS')) MAXFACETS = int(config.get('eloan', 'MAXFACETS')) IMAGESERVER = config.get('eloan', 'IMAGESERVER') BMAPPERSERVER = config.get('eloan', 'BMAPPERSERVER') BMAPPERDIR = config.get('eloan', 'BMAPPERDIR') BMAPPERCONFIGFILE = config.get('eloan', 'BMAPPERCONFIGFILE') SOLRSERVER = config.get('eloan', 'SOLRSERVER') SOLRCORE = config.get('eloan', 'SOLRCORE') SOLRQUERYPARAM = config.get('eloan', 'SOLRQUERYPARAM') LOCALDIR = config.get('eloan', 'LOCALDIR') DROPDOWNS = config.get('eloan', 'DROPDOWNS').split(',') SEARCH_QUALIFIERS = config.get('eloan', 'SEARCH_QUALIFIERS').split(',') PARMS = { # this first one is special 'keyword': ['Keyword', 'true', 'a keyword search value, please', 'text', ''], # the rest are mapping the solr field names to django form labels and fields 'csid': ['id', 'true', '', 'id', ''], 'accession': ['Specimen ID', 'true', '', 'accessionnumber_txt', ''],
import re import time import urllib from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import setConstants from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from grouputils import find_group, create_group, add2group, delete_from_group, setup_solr_search from cspace_django_site import settings from os import path from .models import AdditionalInfo config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'grouper') # read common config file common = 'common' prmz = loadConfiguration(common) print 'Configuration for %s successfully read' % common groupConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'grouper') prmz.FIELDDEFINITIONS = groupConfig.get('grouper', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override / add a couple parameters for this app prmz.MAXRESULTS = int(groupConfig.get('grouper', 'MAXRESULTS'))
from common.utils import doSearch, setConstants, loginfo from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace from cspace_django_site import settings from os import path from .models import AdditionalInfo loginfo('imagebrowser', 'imagebrowser startup', {}, {}) # read common config file common = 'common' prmz = loadConfiguration(common) loginfo('imagebrowser', 'Configuration for %s successfully read' % common, {}, {}) searchConfig = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'imagebrowser') prmz.FIELDDEFINITIONS = searchConfig.get('imagebrowser', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override these two values if they were set above prmz.MAXRESULTS = int(searchConfig.get('imagebrowser', 'MAXRESULTS')) prmz.TITLE = searchConfig.get('imagebrowser', 'TITLE') # @login_required() def images(request): context = setConstants({}, prmz, request)
from common.utils import writeCsv, doSearch, setupGoogleMap, setupBMapper, computeStats, setupCSV, setup4Print, setup4PDF from common.utils import setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file adhocprmz = loadConfiguration('common') print 'Configuration for common successfully read' # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'adhocreports') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') adhocprmz = loadFields(fielddefinitions, adhocprmz) # nb: we override the app title here with the one configured for ad hoc reports adhocprmz.TITLE = config.get('search', 'TITLE') # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info( '%s :: %s :: %s' % ('ad hoc reports startup', '-', '%s | %s | %s' % (adhocprmz.SOLRSERVER, adhocprmz.IMAGESERVER, adhocprmz.BMAPPERSERVER))) def direct(request): return redirect('search/')
def loadConfig(cls): result = cspace.getConfig(path.dirname(__file__), "main") return result
from PIL import Image from PIL.ExifTags import TAGS import csv import codecs import re import json import logging from os import path, listdir from os.path import isfile, isdir, join from xml.sax.saxutils import escape from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, "config"), "uploadmedia") TEMPIMAGEDIR = config.get("files", "directory") POSTBLOBPATH = config.get("info", "postblobpath") BATCHPARAMETERS = config.get("info", "batchparameters") BATCHPARAMETERS = BATCHPARAMETERS.replace(".cfg", "") SERVERINFO = { "serverlabelcolor": config.get("info", "serverlabelcolor"), "serverlabel": config.get("info", "serverlabel"), } INSTITUTION = config.get("info", "institution") FIELDS2WRITE = "name size objectnumber date creator contributor rightsholder imagenumber handling approvedforweb".split( " " ) if isdir(TEMPIMAGEDIR): print "Using %s as working directory for images and metadata files" % TEMPIMAGEDIR else:
# # http://localhost:8000/suggest/?q=1-200&elementID=ob.objno1 # # returns json like: # # [{"value": "1-200"}, {"value": "1-20000"}, {"value": "1-200000"}, ... {"value": "1-200025"}, {"s": "object"}] from django.http import HttpResponse from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings from publicsearch.appconfig import PARMS import solr config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'suggestsolr') SOLRSERVER = config.get('connect', 'SOLRSERVER') SOLRCORE = config.get('connect', 'SOLRCORE') # create a connection to a solr server s = solr.SolrConnection(url='%s/%s' % (SOLRSERVER, SOLRCORE)) import sys, json, re import cgi import cgitb cgitb.enable() # for troubleshooting def solrtransaction(q, elementID):
__author__ = 'jblowe' import os import re import time from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from search.utils import doSearch, setConstants, loginfo from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path from operator import itemgetter config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'locviewer') connect_string = config.get('connect', 'connect_string') MAXMARKERS = int(config.get('locviewer', 'MAXMARKERS')) MAXRESULTS = int(config.get('locviewer', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('locviewer', 'MAXLONGRESULTS')) IMAGESERVER = config.get('locviewer', 'IMAGESERVER') # CSPACESERVER = config.get('locviewer', 'CSPACESERVER') SOLRSERVER = config.get('locviewer', 'SOLRSERVER') SOLRCORE = config.get('locviewer', 'SOLRCORE') TITLE = config.get('locviewer', 'TITLE') # SUGGESTIONS = config.get('locviewer', 'SUGGESTIONS') #LAYOUT = config.get('locviewer', 'LAYOUT') import sys, json, re
import os import re import time import logging from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import doSearch, setConstants, loginfo from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'imaginator') # read common config file common = 'common' prmz = loadConfiguration(common) print 'Configuration for %s successfully read' % common searchConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'imaginator') prmz.FIELDDEFINITIONS = searchConfig.get('imaginator', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override a couple parameters for this app prmz.MAXRESULTS = int(searchConfig.get('imaginator', 'MAXRESULTS')) prmz.TITLE = searchConfig.get('imaginator', 'TITLE')
if row[4] == 'dropdown': appLayout[app][varname][columns[5]] = getDropdowns(row[5]) f.close() return appLayout except IOError: message = 'Could not read (or maybe parse) rows from %s' % parmFile return message, -1 except: raise # global variables config = cspace.getConfig(os.path.join(settings.BASE_PARENT_DIR, 'config'), 'toolbox') APPDIR = os.path.join(settings.BASE_PARENT_DIR, 'toolbox', config.get('info', 'appdir')) institution = config.get('info','institution') deployment = config.get('info','serverlabel') APPS = getAppList(APPDIR, institution, deployment) try: suggestions = config.get('connect','suggestions') except: suggestions = None appLayout = defineFields(os.path.join(settings.BASE_PARENT_DIR, 'toolbox', APPDIR, 'layout.csv'), suggestions) try: VERSION = os.popen("cd " + settings.BASE_PARENT_DIR + " ; /usr/bin/git describe --always").read().strip() if VERSION == '': # try alternate location for git (this is the usual Mac location)
from django.shortcuts import render, render_to_response from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path from operator import itemgetter from search.utils import loginfo from common import cspace # we use the config file reading function from cspace_django_site import settings from cspace_django_site.main import cspace_django_site mainConfig = cspace_django_site.getConfig() config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'authorityeditor') TITLE = config.get('info', 'TITLE') # alas, there are many ways the XML parsing functionality might be installed. # the following code attempts to find and import the best... try: from xml.etree.ElementTree import tostring, parse, Element, fromstring print("running with xml.etree.ElementTree") except ImportError: try: from lxml import etree print("running with lxml.etree") except ImportError: try: # normal cElementTree install import cElementTree as etree
from os import path import time from cspace_django_site.main import cspace_django_site from common import cspace from common import appconfig from common.utils import devicetype config = cspace_django_site.getConfig() hostname = cspace.getConfigOptionWithSection(config, cspace.CONFIGSECTION_AUTHN_CONNECT, cspace.CSPACE_HOSTNAME_PROPERTY) TITLE = 'Applications Available' landingConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'landing') hiddenApps = landingConfig.get('landing', 'hiddenApps').split(',') publicApps = landingConfig.get('landing', 'publicApps').split(',') def getapplist(request): appList = [app for app in settings.INSTALLED_APPS if not "django" in app and not app in hiddenApps] appList.sort() appList = [(app,path.join(settings.WSGI_BASE, app)) for app in appList] return appList def index(request): appList = getapplist(request) if not request.user.is_authenticated():
import os import re import time import logging from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import doSearch, setConstants, loginfo from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path from .models import AdditionalInfo config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'imaginator') # read common config file common = 'common' prmz = loadConfiguration(common) print 'Configuration for %s successfully read' % common searchConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'imaginator') prmz.FIELDDEFINITIONS = searchConfig.get('imaginator', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override a couple parameters for this app prmz.MAXRESULTS = int(searchConfig.get('imaginator', 'MAXRESULTS'))
from common.utils import setupGoogleMap, setupBMapper, computeStats, setupCSV, setup4PDF from common.utils import setup4Print, setDisplayType # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') loginfo('publicsearch', 'Configuration for common successfully read', {}, {}) # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'search') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('publicsearch portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER))) def direct(request): return redirect('publicsearch/') def accesscontrolalloworigin(stuff2return): response = HttpResponse(stuff2return) response["Access-Control-Allow-Origin"] = "*"
__author__ = 'jblowe' import os import re import time from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from search.utils import doSearch, setConstants, loginfo from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path from operator import itemgetter config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'locationvisualizer') MAXMARKERS = int(config.get('locationvisualizer', 'MAXMARKERS')) MAXRESULTS = int(config.get('locationvisualizer', 'MAXRESULTS')) MAXLONGRESULTS = int(config.get('locationvisualizer', 'MAXLONGRESULTS')) IMAGESERVER = config.get('locationvisualizer', 'IMAGESERVER') # CSPACESERVER = config.get('locationvisualizer', 'CSPACESERVER') SOLRSERVER = config.get('locationvisualizer', 'SOLRSERVER') SOLRCORE = config.get('locationvisualizer', 'SOLRCORE') TITLE = config.get('locationvisualizer', 'TITLE') # SUGGESTIONS = config.get('locationvisualizer', 'SUGGESTIONS') #LAYOUT = config.get('locationvisualizer', 'LAYOUT') from common import cspace from cspace_django_site.main import cspace_django_site
# a django version of the autosuggest functionality implemented in the "legacy" CGI webapps" # # invoke as: # # http://localhost:8000/autosuggest/?q=1-200&elementID=ob.objno1 # # returns json like: # # [{"value": "1-200"}, {"value": "1-20000"}, {"value": "1-200000"}, ... {"value": "1-200025"}, {"s": "object"}] from django.http import HttpResponse from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'suggestpostgres') connect_string = config.get('connect', 'connect_string') institution = config.get('connect', 'institution') import sys, json, re import psycopg2 timeoutcommand = 'set statement_timeout to 500' def makeVocabTemplate(refname, term, expression): return """select displayname FROM vocabularyitems_common vc WHERE refname ilike '%%%%%s%%%%' and displayname %s ORDER BY %s LIMIT 30;""" % ( refname, expression, term)
import csv import codecs import re import json import logging from xml.sax.saxutils import escape import hashlib from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path, listdir from os.path import isfile, isdir, join config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'uploadtricoder') TRICODERDIR = config.get('files', 'directory') POSTBLOBPATH = config.get('info', 'postblobpath') TITLE = config.get('info', 'apptitle') FILEPATH = path.join(TRICODERDIR, '%s') SERVERINFO = { 'serverlabelcolor': config.get('info', 'serverlabelcolor'), 'serverlabel': config.get('info', 'serverlabel') } if isdir(TRICODERDIR): print "Using %s as working directory for tricoder files and metadata files" % (FILEPATH % 'input') else: print "working directory %s does not exist. this webapp will not work!" % (FILEPATH % 'input') print "using /tmp as a placeholder" TRICODERDIR = "/tmp" # Get an instance of a logger, log some startup info
) from common.utils import setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration("common") print "Configuration for common successfully read" # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, "config"), "internal") fielddefinitions = config.get("search", "FIELDDEFINITIONS") prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info( "%s :: %s :: %s" % ("internal portal startup", "-", "%s | %s | %s" % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER)) ) def direct(request): return redirect("search/")
from django.shortcuts import render from django.template import RequestContext from django.http import HttpResponse, HttpResponseRedirect from django import forms from operator import itemgetter from common.utils import loginfo from common import cspace # we use the config file reading function from cspace_django_site import settings from cspace_django_site.main import cspace_django_site from .models import AdditionalInfo mainConfig = cspace_django_site.getConfig() config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'ireports') JRXMLDIRPATTERN = config.get('connect', 'JRXMLDIRPATTERN') from xml.etree.ElementTree import tostring, parse, Element, fromstring TITLE = 'iReports Available' @login_required() def enumerateReports(): files = listdir("jrxml") jrxmlfiles = [] for f in files: if '.jrxml' in f: jrxmlfiles.append(f)
from django.shortcuts import render, HttpResponse import json from django.conf import settings from os import path from cspace_django_site.main import cspace_django_site from common import cspace config = cspace_django_site.getConfig() hostname = cspace.getConfigOptionWithSection(config, cspace.CONFIGSECTION_AUTHN_CONNECT, cspace.CSPACE_HOSTNAME_PROPERTY) TITLE = 'Applications Available' landingConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'landing') hiddenApps = landingConfig.get('landing', 'hiddenApps').split(',') loginRequiredApps = landingConfig.get('landing', 'loginRequiredApps').split(',') def getapplist(request): appList = [app for app in settings.INSTALLED_APPS if not "django" in app and not app in hiddenApps] appList.sort() appList = [(app,path.join(settings.WSGI_BASE, app)) for app in appList] return appList def index(request): appList = getapplist(request) if not request.user.is_authenticated():
from django.shortcuts import render, render_to_response from publicsearch.utils import doSearch, setConstants, loginfo MAXMARKERS = 65 MAXRESULTS = 1000 MAXLONGRESULTS = 50 IMAGESERVER = 'https://pahma-dev.cspace.berkeley.edu/pahma_project/imageserver' # no final slash SOLRSERVER = 'http://localhost:8983/solr' SOLRCORE = 'pahma-metadata' from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'imagebrowser') MAXMARKERS = config.get('imagebrowser', 'MAXMARKERS') MAXRESULTS = config.get('imagebrowser', 'MAXRESULTS') MAXLONGRESULTS = config.get('imagebrowser', 'MAXLONGRESULTS') IMAGESERVER = config.get('imagebrowser', 'IMAGESERVER') from common import cspace from cspace_django_site.main import cspace_django_site config = cspace_django_site.getConfig() TITLE = 'Image Browser' @login_required()
from common.utils import writeCsv, doSearch, setupGoogleMap, setupBMapper, computeStats, setupCSV, setup4Print, setup4PDF from common.utils import setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') print 'Configuration for common successfully read' # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'searchmedia') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('public portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER))) def direct(request): return redirect('search/') def search(request):
import csv import codecs import re import json import logging import datetime, time from os import path, listdir, stat from os.path import isfile, isdir, join from xml.sax.saxutils import escape from common import cspace # we use the config file reading function from common.utils import deURN from cspace_django_site import settings config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'csvimport') QUEUEDIR = config.get('files', 'directory') CODEPATH = path.join(settings.BASE_PARENT_DIR, 'csvimport') SERVERLABEL = config.get('info', 'serverlabel') SERVERLABELCOLOR = config.get('info', 'serverlabelcolor') INSTITUTION = config.get('info', 'institution') FIELDS2WRITE = 'job filename handling status'.split(' ') BATCHPARAMETERS = 'None' if isdir(QUEUEDIR): IMPORTDIR_MSG = "Using %s as working directory for csvimport files" % QUEUEDIR else: IMPORTDIR_MSG = "%s is not an existing directory, using /tmp instead for csvimport files" % QUEUEDIR QUEUEDIR = '/tmp' # raise Exception("csvImport working directory %s does not exist. this webapp will not work without it!" % QUEUEDIR)
import re import time import urllib from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import setConstants from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from grouputils import find_group, create_group, add2group, delete_from_group, setup_solr_search from cspace_django_site import settings from os import path from .models import AdditionalInfo config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'grouper') # read common config file common = 'common' prmz = loadConfiguration(common) print 'Configuration for %s successfully read' % common groupConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'grouper') prmz.FIELDDEFINITIONS = groupConfig.get('grouper', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override / add a couple parameters for this app prmz.MAXRESULTS = int(groupConfig.get('grouper', 'MAXRESULTS')) prmz.TITLE = groupConfig.get('grouper', 'TITLE')
__author__ = 'jblowe' # from django.contrib.auth.decorators import login_required from django.http import HttpResponse from common import cspace # we use the config file reading function from common.utils import loginfo from cspace_django_site import settings from os import path import urllib import time import logging import base64 import re config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'imageserver') username = config.get('connect', 'username') password = config.get('connect', 'password') hostname = config.get('connect', 'hostname') realm = config.get('connect', 'realm') protocol = config.get('connect', 'protocol') port = config.get('connect', 'port') port = ':%s' % port if port else '' server = protocol + "://" + hostname + port # see if watermarking is enabled try: watermark = config.get('info', 'watermark') watermark = True if (watermark.lower() in 'true yes on') else False watermark_image = config.get('info', 'watermarkimage')
# http://localhost:8000/suggest/?q=1-200&elementID=ob.objno1 # # returns json like: # # [{"value": "1-200"}, {"value": "1-20000"}, {"value": "1-200000"}, ... {"value": "1-200025"}, {"s": "object"}] from django.http import HttpResponse from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings from publicsearch.appconfig import PARMS import solr config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'suggestsolr') SOLRSERVER = config.get('connect', 'SOLRSERVER') SOLRCORE = config.get('connect', 'SOLRCORE') # create a connection to a solr server s = solr.SolrConnection(url='%s/%s' % (SOLRSERVER, SOLRCORE)) import sys, json, re import cgi import cgitb; cgitb.enable() # for troubleshooting def solrtransaction(q, elementID):
import csv import codecs import re import json import logging from xml.sax.saxutils import escape import hashlib from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path, listdir from os.path import isfile, isdir, join config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'uploadtricoder') TRICODERDIR = config.get('files', 'directory') POSTBLOBPATH = config.get('info', 'postblobpath') TITLE = config.get('info', 'apptitle') FILEPATH = path.join(TRICODERDIR, '%s') SERVERINFO = { 'serverlabelcolor': config.get('info', 'serverlabelcolor'), 'serverlabel': config.get('info', 'serverlabel') } if isdir(TRICODERDIR): print "Using %s as working directory for tricoder files and metadata files" % ( FILEPATH % 'input') else: print "working directory %s does not exist. this webapp will not work!" % ( FILEPATH % 'input') print "using /tmp as a placeholder"
from django import forms from cspace_django_site.main import cspace_django_site from common.utils import writeCsv, doSearch, setupGoogleMap, setupBMapper, computeStats, setupCSV, setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') print 'Configuration for common successfully read' # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'osteology') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('osteology portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER))) def gatherosteoparms(searchvalues): aggregate = [] search_keys = [] for key in searchvalues.keys(): if key == 'csrfmiddlewaretoken' : continue if searchvalues[key] == '': continue searchkey = key.replace('csc-osteology-','') search_keys.append(searchkey)
import re import time import urllib from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import setConstants from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from locationutils import find_items_in_cspace, setup_solr_search from cspace_django_site import settings from os import path from .models import AdditionalInfo config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'locationhistory') # read common config file common = 'common' prmz = loadConfiguration(common) print 'Configuration for %s successfully read' % common locationConfig = cspace.getConfig( path.join(settings.BASE_PARENT_DIR, 'config'), 'locationhistory') prmz.FIELDDEFINITIONS = locationConfig.get('locationhistory', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override / add a couple parameters for this app
from django import forms from cspace_django_site.main import cspace_django_site from common.utils import writeCsv, doSearch, setupGoogleMap, setupBMapper, computeStats, setupCSV, setDisplayType, setConstants, loginfo # from common.utils import CSVPREFIX, CSVEXTENSION from common.appconfig import loadFields, loadConfiguration from common import cspace # we use the config file reading function from .models import AdditionalInfo from cspace_django_site import settings # read common config file prmz = loadConfiguration('common') print 'Configuration for common successfully read' # on startup, setup this webapp layout... config = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'osteology') fielddefinitions = config.get('search', 'FIELDDEFINITIONS') prmz = loadFields(fielddefinitions, prmz) # Get an instance of a logger, log some startup info logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('osteology portal startup', '-', '%s | %s | %s' % (prmz.SOLRSERVER, prmz.IMAGESERVER, prmz.BMAPPERSERVER))) def direct(request): return redirect('search/') @login_required() def search(request): if request.method == 'GET' and request.GET != {}:
import random import logging import collections from django.contrib.auth.decorators import login_required from django.shortcuts import render, render_to_response from common.utils import doSearch, setConstants, loginfo from common.appconfig import loadConfiguration, loadFields, getParms from common import cspace # we use the config file reading function from cspace_django_site import settings from os import path from .models import AdditionalInfo config = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'curator') # read common config file common = 'common' prmz = loadConfiguration(common) loginfo('curator', 'Configuration for %s successfully read' % common, {}, {}) searchConfig = cspace.getConfig(path.join(settings.BASE_DIR, 'config'), 'curator') prmz.FIELDDEFINITIONS = searchConfig.get('curator', 'FIELDDEFINITIONS') # add in the the field definitions... prmz = loadFields(prmz.FIELDDEFINITIONS, prmz) # override a couple parameters for this app prmz.MAXRESULTS = int(searchConfig.get('curator', 'MAXRESULTS'))
# # returns json like: # # [{"value": "1-200"}, {"value": "1-20000"}, {"value": "1-200000"}, ... {"value": "1-200025"}, {"s": "object"}] from django.http import HttpResponse from os import path from common import cspace # we use the config file reading function from cspace_django_site import settings from search.appconfig import getParms import solr #solrConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'suggestsolr') searchConfig = cspace.getConfig(path.join(settings.BASE_PARENT_DIR, 'config'), 'search') SUGGESTIONS = searchConfig.get('search', 'SUGGESTIONS') FIELDDEFINITIONS = searchConfig.get('search', 'FIELDDEFINITIONS') FIELDS, PARMS, SEARCHCOLUMNS, SEARCHROWS, SOLRSERVER, SOLRCORE, TITLE, DEFAULTSORTKEY = getParms(path.join(settings.BASE_PARENT_DIR, 'config/' + FIELDDEFINITIONS)) # create a connection to a solr server s = solr.SolrConnection(url='%s/%s' % (SOLRSERVER, SOLRCORE)) import sys, json, re import cgi import cgitb; cgitb.enable() # for troubleshooting