コード例 #1
0
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
コード例 #2
0
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)
コード例 #3
0
ファイル: appconfig.py プロジェクト: RjLi13/pahma_project
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
コード例 #4
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')
        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
コード例 #5
0
 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)
コード例 #6
0
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.'
コード例 #7
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')

        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
コード例 #8
0
ファイル: appconfig.py プロジェクト: RjLi13/pahma_project
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
コード例 #9
0
ファイル: authn.py プロジェクト: remillet/ucb_deployment_site
    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
コード例 #10
0
ファイル: eloanutils.py プロジェクト: RjLi13/ucjeps_project
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
コード例 #11
0
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)
コード例 #12
0
    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)
コード例 #13
0
    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)
コード例 #14
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
コード例 #15
0
    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
コード例 #16
0
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
コード例 #17
0
    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,
        )
コード例 #18
0
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)
コード例 #19
0
# 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', ''],
コード例 #20
0
ファイル: views.py プロジェクト: RjLi13/pahma_project
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
コード例 #21
0
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:
コード例 #22
0
 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")
コード例 #23
0
ファイル: appconfig.py プロジェクト: remillet/pahma_project
# 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", ""],
コード例 #24
0
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 != {}:
コード例 #25
0
            # 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(
コード例 #26
0
ファイル: utils.py プロジェクト: JulianJaffe/pahma_project
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__)

コード例 #27
0
 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")
コード例 #28
0
# 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', ''],
コード例 #29
0
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'))
コード例 #30
0
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)
コード例 #31
0
ファイル: views.py プロジェクト: jblowe/django_example_config
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/')
コード例 #32
0
ファイル: main.py プロジェクト: remillet/ucb_deployment_site
 def loadConfig(cls):
     result = cspace.getConfig(path.dirname(__file__), "main")
     return result
コード例 #33
0
ファイル: utils.py プロジェクト: aronr/cspace_django_project
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:
コード例 #34
0
#
# 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):
コード例 #35
0
ファイル: views.py プロジェクト: RjLi13/bampfa_project
__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
コード例 #36
0
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')
コード例 #37
0
ファイル: utils.py プロジェクト: jblowe/pahma_project
            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)
コード例 #38
0
ファイル: views.py プロジェクト: RjLi13/bampfa_project
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
コード例 #39
0
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():
コード例 #40
0
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'))
コード例 #41
0
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"] = "*"
コード例 #42
0
ファイル: views.py プロジェクト: RjLi13/bampfa_project
__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
コード例 #43
0
# 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)
コード例 #44
0
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
コード例 #45
0
)
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/")

コード例 #46
0
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)
コード例 #47
0
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():
コード例 #48
0
ファイル: views.py プロジェクト: HackTheHearst/pahma_project
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()
コード例 #49
0
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):
コード例 #50
0
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)
コード例 #51
0
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')
コード例 #52
0
__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')
コード例 #53
0
ファイル: views.py プロジェクト: HackTheHearst/pahma_project
# 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):
コード例 #54
0
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"
コード例 #55
0
ファイル: views.py プロジェクト: jblowe/django_example_config
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)
コード例 #56
0
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
コード例 #57
0
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 != {}:
コード例 #58
0
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'))
コード例 #59
0
ファイル: views.py プロジェクト: RjLi13/bampfa_project
#
# 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