Beispiel #1
0
        excursion_slides = excursion_description['slides']
        # TODO: sort by name?
        for pos, slide in enumerate(excursion_slides):
            widgets.append({
                'name' : '%s__%s' % (slide['id'], pos),
                'description' : slide['id'],
            })
        return widgets

    def load_widget(self, reservation_id, widget_name, **kwargs):
        number = POS_REGEX.match(widget_name).groups()[0]
        obj = EXCURSION_REGEX.match(reservation_id)
        if not obj:
            return {
                'url' : url_for('vish.index', _external = True)
            }
        excursion_identifier = obj.groups()[0]

        return {
            'url' : 'http://vishub.org/excursions/%s.full#%s?uniq=true' % (excursion_identifier, number)
        }

register("ViSH", ['1.0'], __name__)

vish_blueprint = Blueprint('vish', __name__)
@vish_blueprint.route('/')
def index():
    return "Invalid reservation identifier"

register_blueprint(vish_blueprint, '/vish')
Beispiel #2
0
        if translations:
            return translations
        try:
            r = VIRTUAL_LABS.cached_session.get(self.translation_url)
            r.raise_for_status()
            translations_json = r.json()
        except Exception as e:
            traceback.print_exc()
            response = {'error': unicode(e)}
            VIRTUAL_LABS.rlms_cache['translations'] = response
            return response
        else:
            VIRTUAL_LABS.rlms_cache['translations'] = translations_json
            return translations_json

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict(name='default', description='Default widget')
        if self.height is not None:
            default_widget['height'] = self.height
        return [default_widget]


def populate_cache(rlms):
    rlms.get_translations(None)


VIRTUAL_LABS = register("Virtual labs", ['0.1'], __name__)
VIRTUAL_LABS.add_local_periodic_task("Retrieve translations",
                                     populate_cache,
                                     minutes=55)
Beispiel #3
0
        request.update(kwargs)
        response = self._request_post('/reserve', request)
        return {
            'reservation_id' : response['reservation_id'],
            'load_url' : response['load_url']
        }

    def load_widget(self, reservation_id, widget_name, **kwargs):
        response = self._request('/widget?widget_name=%s' % widget_name, headers = { 'X-G4L-reservation-id' : reservation_id })
        return {
            'url' : response['url']
        }

    def list_widgets(self, laboratory_id, **kwargs):
        widgets_json = self._request('/widgets?laboratory_id=%s' % urllib2.quote(laboratory_id))
        widgets = []
        for widget_json in widgets_json['widgets']:
            widget = {
                'name' : widget_json['name'],
                'description' : widget_json.get('description',''),
            }
            widgets.append(widget)

        return widgets

PLUGIN_NAME = "HTTP plug-in"
PLUGIN_VERSIONS = ['1.0']

register(PLUGIN_NAME, PLUGIN_VERSIONS, __name__)

Beispiel #4
0
    Using the http://en.wikipedia.org/wiki/ARC4 
    """
    # The key-scheduling algorithm (KSA)
    S = range(256)
    j = 0
    for i in xrange(256):
        j = ( j + S[i] + ord(key[i % len(key)]) ) % 256

        S[i], S[j] = S[j], S[i]

    # The pseudo-random generation algorithm (PRGA)
    i = 0
    j = 0
    output = []

    for c in data:
        i = (i + 1) % 256
        j = (j + S[i]) % 256

        S[i], S[j] = S[j], S[i]

        k = ord(c) ^ S[ (S[i] + S[j]) % 256]
        output.append( chr(k) )

    return ''.join(output)


register("FCEIA-UNR", ['1.0'], __name__)

            'url' : reservation_id
        }

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict( name = 'default', description = 'Default widget' )
        return [ default_widget ]

    def get_downloads(self, laboratory_id):
        return {
            'en_ALL': url_for('physicsaviary.physicsaviary_download', laboratory_id=laboratory_id, _external=True),
        }

def populate_cache(rlms):
    rlms.get_laboratories()

PHYSICSAVIARY = register("PhysicsAviary", ['1.0'], __name__)
PHYSICSAVIARY.add_local_periodic_task('Populating cache', populate_cache, hours = 15)

physicsaviary_blueprint = Blueprint('physicsaviary', __name__)

@physicsaviary_blueprint.route('/id/<path:laboratory_id>')
def physicsaviary_download(laboratory_id):
    laboratories, identifiers = get_laboratories()
    lab_data = identifiers.get(laboratory_id)
    if not lab_data:
        return "Not found", 404

    link = lab_data['link']
    generated = webpage2html.generate(index=link, keep_script=True, verbose=False)
    return generated.encode()
    def get_laboratories(self, **kwargs):
        return retrieve_labs()

    def reserve(self, laboratory_id, username, institution, general_configuration_str, particular_configurations, request_payload, user_properties, *args, **kwargs):
        url = 'http://lab.concord.org/embeddable.html#{0}'.format(urllib2.unquote(laboratory_id))
        response = {
            'reservation_id' : url,
            'load_url' : url
        }
        return response

def populate_cache():
    rlms = RLMS("{}")
    rlms.get_laboratories()

CONCORD = register("Concord", ['1.0'], __name__)
CONCORD.add_global_periodic_task('Populating cache', populate_cache, hours = 23)

def main():
    rlms = RLMS("{}")
    t0 = time.time()
    laboratories = rlms.get_laboratories()
    tf = time.time()
    print len(laboratories), (tf - t0), "seconds"
    for lab in laboratories[:5]:
        t0 = time.time()
        print rlms.reserve(lab.laboratory_id, 'tester', 'foo', '', '', '', '', locale = lang)
        tf = time.time()
        print tf - t0, "seconds"

if __name__ == '__main__':
Beispiel #7
0
        return None
            
    def reserve(self, laboratory_id, username, institution, general_configuration_str, particular_configurations, request_payload, user_properties, *args, **kwargs):
        return None

    def get_http_user(self):
        return self.http_user

    @app.route('/get_properties/<mself>')
    def get_properties(mself):
        # 
        # TODO: CSRF is not used here. Security hole
        # 
        
        http_user = mself.get_http_user()
    
        asasa
          




http_blueprint = Blueprint('http', __name__)
@http_blueprint.route('/')
def index():
    return "This is the index for HTTP"

register("HTTP", ['0.1'], __name__)
register_blueprint(http_blueprint, '/http')
Beispiel #8
0

    def load_widget(self, reservation_id, widget_name, **kwargs):
        return {
            'url' : reservation_id
        }

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict( name = 'default', description = 'Default widget' )
        return [ default_widget ]


def populate_cache(rlms):
    rlms.get_laboratories()

ACADEMO = register("Academo", ['1.0'], __name__)
ACADEMO.add_local_periodic_task('Populating cache', populate_cache, hours = 15)

DEBUG = ACADEMO.is_debug() or (os.environ.get('G4L_DEBUG') or '').lower() == 'true' or False
DEBUG_LOW_LEVEL = DEBUG and (os.environ.get('G4L_DEBUG_LOW') or '').lower() == 'true'

if DEBUG:
    print("Debug activated")

if DEBUG_LOW_LEVEL:
    print("Debug low level activated")

sys.stdout.flush()

if __name__ == '__main__':
    rlms = RLMS('{}')
        window.onload = function() {
            var labframe = document.getElementById("labframe").contentWindow;
            labframe.postMessage(message, "https://gateway.golabz.eu");
        };
    </script>

    <iframe id="labframe" border="0" src="https://gateway.golabz.eu/proxy/http://chemcollective.org/chem/jsvlab/vlab.html" style="width: 100%; height: 100%; border-size: 0px"></iframe>
</body>
</html>
"""


register_blueprint(chemcollective_blueprint, url='/chemcollective')

CHEMCOLLECTIVE = register("ChemCollective", ['1.0'], __name__)
CHEMCOLLECTIVE.add_local_periodic_task('Populating cache',
                                       populate_cache,
                                       hours=13)

DEBUG = CHEMCOLLECTIVE.is_debug() or (os.environ.get('G4L_DEBUG')
                                      or '').lower() == 'true' or False
DEBUG_LOW_LEVEL = DEBUG and (os.environ.get('G4L_DEBUG_LOW')
                             or '').lower() == 'true'

if DEBUG:
    print("Debug activated")

if DEBUG_LOW_LEVEL:
    print("Debug low level activated")
Beispiel #10
0
def register_fake():
    register("FakeRLMS", ['1.0'], __name__)
Beispiel #11
0
def register_fake():
    register("FakeRLMS", ['1.0'], __name__)
Beispiel #12
0
    try:
        tasks = []
        for lab in rlms.get_laboratories():
            for lang in LANGUAGES:
                tasks.append(_QueueTask(lab.laboratory_id, lang))

        _run_tasks(tasks)

        dbg("Finished")
    finally:
        ALL_LINKS = None
        sys.stdout.flush()
        sys.stderr.flush()

PHET = register("PhET", ['1.0'], __name__)
PHET.add_global_periodic_task('Populating cache', populate_cache, hours = 11)

DEBUG = PHET.is_debug() or (os.environ.get('G4L_DEBUG') or '').lower() == 'true' or False
DEBUG_LOW_LEVEL = DEBUG and (os.environ.get('G4L_DEBUG_LOW') or '').lower() == 'true'

if DEBUG:
    print("Debug activated")

if DEBUG_LOW_LEVEL:
    print("Debug low level activated")

sys.stdout.flush()

def main():
    with CacheDisabler():
        return labs

    def get_check_urls(self, laboratory_id):
        return [ laboratory_id ]

    def reserve(self, laboratory_id, username, institution, general_configuration_str, particular_configurations, request_payload, user_properties, *args, **kwargs):
        url = laboratory_id
        return {
            'reservation_id' : requests.utils.quote(url, ''),
            'load_url' : url
        }

def populate_cache():
    get_lab_listing()

QUVIS = register("QuVis", ['1.0'], __name__)
QUVIS.add_global_periodic_task('Populating cache', populate_cache, minutes = 55)

def main():
    rlms = RLMS("{}")
    laboratories = rlms.get_laboratories()
    print len(laboratories)
    print
    print laboratories[:10]
    print
    for lab in laboratories[:5]:
        print rlms.reserve(lab.laboratory_id, 'tester', 'foo', '', '', '', '')

if __name__ == '__main__':
    main()
        return {'url': create_url(reservation_id, locale)}

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict(name='default', description='Default widget')
        return [default_widget]


class VascakTaskQueue(QueueTask):
    RLMS_CLASS = RLMS


def populate_cache(rlms):
    rlms.get_laboratories()


VASCAK = register("Vascak", ['1.0'], __name__)
VASCAK.add_local_periodic_task('Populating cache', populate_cache, hours=23)

DEBUG = VASCAK.is_debug() or (os.environ.get('G4L_DEBUG')
                              or '').lower() == 'true' or False
DEBUG_LOW_LEVEL = DEBUG and (os.environ.get('G4L_DEBUG_LOW')
                             or '').lower() == 'true'

if DEBUG:
    print("Debug activated")

if DEBUG_LOW_LEVEL:
    print("Debug low level activated")

vascak_blueprint = Blueprint('vascak', __name__)
Beispiel #15
0
        translations = VIRTUAL_LABS.rlms_cache.get('translations')
        if translations:
            return translations
        try:
            r = VIRTUAL_LABS.cached_session.get(self.translation_url)
            r.raise_for_status()
            translations_json = r.json()
        except Exception as e:
            traceback.print_exc()
            response = {
                'error' : unicode(e)
            }
            VIRTUAL_LABS.rlms_cache['translations'] = response
            return response
        else:
            VIRTUAL_LABS.rlms_cache['translations'] = translations_json
            return translations_json

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict( name = 'default', description = 'Default widget')
        if self.height is not None:
            default_widget['height'] = self.height
        return [ default_widget ]


def populate_cache(rlms):
    rlms.get_translations(None)

VIRTUAL_LABS = register("Virtual labs", ['0.1'], __name__)
VIRTUAL_LABS.add_local_periodic_task("Retrieve translations", populate_cache, minutes = 55)
        ilab_labs = self._get_labs_data(use_cache = False)
        lab_data = ilab_labs[laboratory_id]

        url = launchilab(unique_user_id, self.sb_guid, self.sb_service_url, self.authority_guid, self.group_name, lab_data)
        if DEBUG:
            print repr(url)
        return {
            'load_url' : url,
            'reservation_id' : url
        }

def populate_cache(rlms):
    for lab in rlms.get_laboratories():
        rlms.get_translations(lab.laboratory_id)

ILAB = register("iLabs", ['1.0'], __name__)
ILAB.add_local_periodic_task('Populating cache', populate_cache, minutes = 55)

if __name__ == '__main__':
    DEBUG = True
    import getpass, sys, pprint
    if len(sys.argv) == 2:
        auth_key = sys.argv[1]
    else:
        auth_key = getpass.getpass("Provide auth key: ")
    pprint.pprint(get_foreign_credentials('http://ilabs.cti.ac.at/iLabServiceBroker/', auth_key))
    configuration = json.dumps({
        'sb_url' : 'http://ilabs.cti.ac.at/iLabServiceBroker/',
        'authority_guid' : auth_key,
    })
    rlms = RLMS(configuration)
Beispiel #17
0
    try:
        tasks = []
        for lab in rlms.get_laboratories():
            for lang in LANGUAGES:
                tasks.append(_QueueTask(lab.laboratory_id, lang))

        _run_tasks(tasks)

        dbg("Finished")
    finally:
        ALL_LINKS = None
        sys.stdout.flush()
        sys.stderr.flush()


PHET = register("PhET", ['1.0'], __name__)
PHET.add_global_periodic_task('Populating cache', populate_cache, hours=11)

DEBUG = PHET.is_debug() or (os.environ.get('G4L_DEBUG')
                            or '').lower() == 'true' or False
DEBUG_LOW_LEVEL = DEBUG and (os.environ.get('G4L_DEBUG_LOW')
                             or '').lower() == 'true'

if DEBUG:
    print("Debug activated")

if DEBUG_LOW_LEVEL:
    print("Debug low level activated")

sys.stdout.flush()
Beispiel #18
0
    def get_capabilities(self): 
        return [ Capabilities.WIDGET ] 

    def test(self):
        json.loads(self.configuration)
        # TODO
        return None

    def get_laboratories(self, **kwargs):
        return [ Laboratory(self.name, self.name, autoload = True) ]

    def reserve(self, laboratory_id, username, institution, general_configuration_str, particular_configurations, request_payload, user_properties, *args, **kwargs):
        return {
            'reservation_id' : 'not-required',
            'load_url' : self.web
        }

    def load_widget(self, reservation_id, widget_name, **kwargs):
        return {
            'url' : self.web
        }

    def list_widgets(self, laboratory_id, **kwargs):
        default_widget = dict( name = 'default', description = 'Default widget')
        if self.height is not None:
            default_widget['height'] = self.height
        return [ default_widget ]


register("Virtual labs", ['0.1'], __name__)
Beispiel #19
0
            'url' : response['url']
        }

    def list_widgets(self, laboratory_id, **kwargs):
        widgets_json = self._request('/widgets?laboratory_id=%s' % requests.utils.quote(laboratory_id))
        widgets = []
        for widget_json in widgets_json['widgets']:
            widget = {
                'name' : widget_json['name'],
                'description' : widget_json.get('description',''),
            }
            widgets.append(widget)

        return widgets

PLUGIN_NAME = "HTTP plug-in"
PLUGIN_VERSIONS = ['1.0']

def populate_cache(rlms):
    capabilities = rlms.get_capabilities()
    for lab in rlms.get_laboratories():
        if Capabilities.TRANSLATIONS in capabilities:
            rlms.get_translations(lab.laboratory_id)
        if Capabilities.TRANSLATION_LIST in capabilities:
            rlms.get_translation_list(lab.laboratory_id)
    

HTTP_PLUGIN = register(PLUGIN_NAME, PLUGIN_VERSIONS, __name__)
HTTP_PLUGIN.add_local_periodic_task('Populating cache', populate_cache, minutes = 55)

Beispiel #20
0
            global_min_priority = None

        overall_max_time = min(global_max_time or MAX, max_time or MAX)
        if overall_max_time is MAX:
            overall_max_time = None

        overall_min_priority = max(global_min_priority, min_priority)

        consumer_data = {}
        if overall_min_priority is not None:
            consumer_data['priority'] = overall_min_priority
        if overall_max_time is not None:
            consumer_data['time_allowed'] = overall_max_time
        return consumer_data


def populate_cache(rlms):
    for laboratory in rlms.get_laboratories():
        rlms.get_translations(laboratory.laboratory_id)

WEBLAB_DEUSTO = register("WebLab-Deusto", ['5.0'], __name__)
WEBLAB_DEUSTO.add_local_periodic_task('Populating cache', populate_cache, minutes = 55)


weblabdeusto_blueprint = Blueprint('weblabdeusto', __name__)
@weblabdeusto_blueprint.route('/')
def index():
    return "This is the index for WebLab-Deusto"

register_blueprint(weblabdeusto_blueprint, '/weblabdeusto')