Example #1
0
    def generate():
        yield 'running...\t'

        repository = Repository(settings.basedir)
        for ref in repository.dumpreferences():
            ref['deb'] = os.path.join(repository.options.basedir, ref['deb'])
            try:
                (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(ref['deb'])
                ref['stats'] = {'mtime': time.ctime(mtime), 'ctime': time.ctime(ctime), 'user': pwd.getpwuid(uid).pw_gecos, 'size': size}
                cache(settings).write(repository, ref['codename'], ref['component'], ref['arch'], ref['package'], ref['version'], ref)
                yield "</br>"
                yield json.dumps(ref)
            except Exception as e:
                app.logger.warn(e)
                app.logger.warn('unable to write cache for %s %s' % (ref['package'], ref['version']))

        yield json.dumps({'status': 'OK'})
Example #2
0
def get_package_detail(codename, component, architecture, package, version, format=None):
    app.logger.info(request.path)

    g.breadcrumb = [{'name': 'browse', 'url': url_for('get_repository_detail')},
                    {'name': codename, 'url': url_for('get_codename_detail', codename=codename)},
                    {'name': component, 'url': url_for('get_component_detail', codename=codename, component=component)},
                    {'name': architecture, 'url': url_for('get_architecture_detail', codename=codename, component=component, architecture=architecture)},
                    {'name': package, 'url': url_for('get_package_versions', codename=codename, component=component, architecture=architecture, package=package)},
                    {'name': version, 'url': request.path},]

    # get any un-referenced versions of our package name
    repository = Repository(settings.basedir)
    all_versions = repository.list(codename, package)

    try:
        reference = cache(settings).read(repository, codename, component, architecture, package, version)
        app.logger.debug('Rendering from cache')
    except Exception as e:
        # loop through the references until we find a match. Cache it out afterwards
        # so that we don't have to do this again.
        app.logger.info(e)
        for ref in repository.dumpreferences():
            if ref['package'] == package and ref['version'] == version:
                ref['deb'] = os.path.join(repository.options.basedir, ref['deb'])

                try:
                    (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(ref['deb'])
                    ref['stats'] = {'mtime': time.ctime(mtime), 'ctime': time.ctime(ctime), 'user': pwd.getpwuid(uid).pw_gecos, 'size': size}
                except Exception as e:
                    app.logger.warn(e)

                try:
                    cache(settings).write(repository, codename, component, architecture, package, ref['version'], ref)
                    reference = ref
                except Exception as e:
                    # unable to cache result. reference local variable will not have been set.
                    app.logger.warn('unable to cache')
                    app.logger.warn(e)

    if 'reference' in locals():
        return render_template('api/detail/version.html', package=package, reference=reference, versions=all_versions)

    return render_template('api/detail/version.html', package=package)
Example #3
0
def get_package_changelog(codename, component, architecture, package, version):
    repository = Repository(settings.basedir)
    try:
        reference = cache(settings).read(repository, codename, component, architecture, package, version)
    except:
        for ref in repository.dumpreferences():
            if ref['package'] == package and ref['version'] == version:
                reference = ref

    if 'reference' in locals():
        reference['deb'] = os.path.join(repository.options.basedir, reference['deb'])
        return json.dumps(repository.list_changes(reference['deb']))

    return json.dumps([])
Example #4
0

@app.route('/static/<path:path>')
def static_static(path):
    return send_from_directory('static', path)


def poll_kafka():
    client = KafkaClient(hosts='freedom.sugarlabs.org:9092')
    consumer = client.topics['org.sugarlabs.hook'].get_simple_consumer(
        consumer_group='aslo-web-interface', auto_commit_enable=True)

    for msg in consumer:
        try:
            data = json.loads(msg.value)
        except ValueError:
            print 'Invalid json in message', msg.offset, msg.value
            continue

        if data.get('clone_url') == \
           'https://github.com/samdroid-apps/sugar-activities':
            backend.pull_activities()


if __name__ == '__main__':
    os.system('sass sass/index.sass:static-cache/index.css')
    backend.cache()

    thread.start_new_thread(poll_kafka, ())
    app.run(host='0.0.0.0', debug=True)
Example #5
0
def setUpModule():
    backend.ACTIVITIES = os.path.join(mkdtemp(), 'a')
    shutil.copytree('test-data', backend.ACTIVITIES)
    backend.cache()
Example #6
0
def download_deb(**kwargs):
    app.logger.debug(kwargs)
    repository = Repository(settings.basedir)
    ref = cache(settings).read(repository, kwargs['codename'], kwargs['component'], kwargs['architecture'], kwargs['package'], kwargs['version'])
    return send_file(ref['deb'], as_attachment=True)
Example #7
0
def setUpModule():
    backend.ACTIVITIES = os.path.join(mkdtemp(), 'a')
    shutil.copytree('test-data', backend.ACTIVITIES)
    backend.cache()