Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Initial commit of Prospector under GPL v3.0 - Harish Pillay hpillay@r…
Browse files Browse the repository at this point in the history
…edhat.com
  • Loading branch information
harishpillay committed Aug 25, 2017
0 parents commit 080acfd
Show file tree
Hide file tree
Showing 543 changed files with 46,226 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.py[co]
*.sw[po]
*.bak
*.orig
*~
.project
.pydevproject
HealthMeter.egg-info
37 changes: 37 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[submodule "libs/jquery-treeview"]
path = libs/jquery-treeview
url = git://github.com/jzaefferer/jquery-treeview.git
[submodule "libs/django-dag-cte"]
path = libs/django-dag-cte
url = git://github.com/hyperair/django-dag.git
[submodule "libs/jquery-ellipsis"]
path = libs/jquery-ellipsis
url = git://github.com/STAR-ZERO/jquery-ellipsis.git
[submodule "libs/google-trends-csv-downloader"]
path = libs/google-trends-csv-downloader
url = git://github.com/hyperair/google-trends-csv-downloader.git
[submodule "libs/jquery.tablesorter"]
path = libs/jquery.tablesorter
url = git://github.com/hyperair/tablesorter.git
[submodule "libs/jquery-sortable"]
path = libs/jquery-sortable
url = git://github.com/johnny/jquery-sortable
[submodule "libs/django-preferences"]
path = libs/django-preferences
url = git://github.com/hyperair/django-preferences
[submodule "libs/django-js-reverse"]
path = libs/django-js-reverse
url = git://github.com/hyperair/django-js-reverse
[submodule "libs/django-medusa"]
path = libs/django-medusa
url = git://github.com/hyperair/django-medusa
[submodule "libs/python-mantisbt-api"]
path = libs/python-mantisbt-api
url = git://github.com/hyperair/python-mantisbt-api
branch = develop
[submodule "libs/bootstrap"]
path = libs/bootstrap
url = git://github.com/twbs/bootstrap
[submodule "libs/bootstrap-slider"]
path = libs/bootstrap-slider
url = git://github.com/seiyria/bootstrap-slider
95 changes: 95 additions & 0 deletions .openshift/action_hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2017 Red Hat, Inc.
# License: GPLv3 or any later version

#!/bin/bash
# Script cannibalized from https://github.com/zfdang/memcached-in-openshift to
# install memcached into $OPENSHIFT_DATA_DIR

optdir="$OPENSHIFT_DATA_DIR/opt"

install_pkg() {
local pkg="$1" \
version="$2" \
url_template="$3" \
from_source="$4"
local builddir="$OPENSHIFT_TMP_DIR/$pkg-$version" \
prefix="$optdir/$pkg"

shift 4 # everything else is to be passed to configure

if [ -d "$prefix" ]; then
echo "$prefix exists. Skipping compilation..."
return 0
fi

(
set -e # Die on error

echo "Cleaning up $builddir if it exists"
rm -rf "$builddir"

echo "Creating $builddir"
mkdir "$builddir"

eval "local url=$url_template"
local tarball="$pkg-$version.tar.gz"

echo "Downloading $pkg from $url to $OPENSHIFT_TMP_DIR/$tarball"

cd "$OPENSHIFT_TMP_DIR"
curl -L -o "$tarball" "$url"

echo "Extracting $tarball"
tar -C "$builddir" --strip-components=1 -xzvf "$pkg-$version.tar.gz"

if [ "$from_source" = y ]; then
echo "Compiling"
cd "$builddir"

sh configure --prefix="$prefix" "$@"
make -j$(grep -c ^processor /proc/cpuinfo)

echo "Installing into $prefix"
make install

else
echo "Not from_source, so directly moving into $prefix"
mv -T "$builddir" "$prefix"
fi
)

ret=$?
if [ $ret -eq 0 ]; then
echo "Successfully installed $pkg-$version"
else
echo "Installation of $pkg-$version failed"
fi

return $ret
}

mkdir -p $optdir

install_pkg \
libevent \
2.0.22 \
'https://sourceforge.net/projects/levent/files/libevent/$pkg-2.0/libevent-$version-stable.tar.gz' \
y

install_pkg \
memcached \
1.4.24 \
'http://www.memcached.org/files/$pkg-$version.tar.gz' \
y \
--with-libevent=$optdir/libevent

install_pkg \
iojs \
3.0.0 \
'https://iojs.org/dist/v$version/$pkg-v$version-linux-x64.tar.gz' \
n

lessdir="$optdir/less"
mkdir -p "$lessdir"
cd "$lessdir"
HOME="$lessdir" $optdir/iojs/bin/npm install less
30 changes: 30 additions & 0 deletions .openshift/action_hooks/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 Red Hat, Inc.
# License: GPLv3 or any later version

#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again. This script gets executed directly, so it could be python, php,
# ruby, etc.

sleep 5
# export PYTHON_EGG_CACHE=$OPENSHIFT_GEAR_DIR/virtenv/lib/python-2.6
source $OPENSHIFT_PYTHON_DIR/virtenv/bin/activate

runcmd() {
echo "Executing '$*'"
"$@"
}

managepy="$OPENSHIFT_REPO_DIR/wsgi/manage.py"

manage() {
runcmd python "$managepy" "$@"
}

manage syncdb --noinput
manage migrate
# manage collectstatic --noinput
# runcmd mkdir -p $OPENSHIFT_DATA_DIR/staticgen
# runcmd ln -fsT $OPENSHIFT_DATA_DIR/staticgen \
# $OPENSHIFT_REPO_DIR/wsgi/static/generated
20 changes: 20 additions & 0 deletions .openshift/action_hooks/post_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2017 Red Hat, Inc.
# License: GPLv3 or any later version

#!/bin/bash

set -e

MEMCACHED_BINARY=${OPENSHIFT_DATA_DIR}opt/memcached/bin/memcached

if [ ! -e MEMCACHED_BINARY ]; then
pkill -U$(whoami) memcached || true
$MEMCACHED_BINARY -l $OPENSHIFT_PYTHON_IP -p 22322 -m 64 -d
echo "${MEMCACHED_BINARY} started!"

else
echo "============================================"
echo "${MEMCACHED_BINARY} does not exist!."
echo "You should manually install it ..."
echo "============================================"
fi
8 changes: 8 additions & 0 deletions .openshift/action_hooks/pre_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2017 Red Hat, Inc.
# License: GPLv3 or any later version

#!/bin/bash
# This is a simple script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the build step. This script gets executed directly, so it
# could be python, php, ruby, etc.
1 change: 1 addition & 0 deletions .openshift/cron/daily/warm_detailpage_cache
91 changes: 91 additions & 0 deletions HINTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Open Source Prospector #
## File layout ##
This project follows the standard Openshift v2 layout as per the
[Django Openshift example](https://github.com/openshift/django-example).

In the root directory, some noteworthy items are:

- `libs/`: bundled versions of third-party libraries, mostly submodules
- `.openshift/`: hook scripts for deployment on Openshift
- `scripts/`: convenience scripts, not really used any more since their
functionality have been moved into Django management commands.
- `wsgi/`: WSGI application and Django project.

Client-side resources such as Javascript and CSS files are organized inside the
individual apps' `static/` directories, under `static/js/` and `static/css/`
respectively.

The `static/js/` files are further organized by the view which uses them, with
the common files being in outer directories.


## Architecture ##
The Prospector project is built around the Django framework, making
extensive use of the Django ORM for all DB access, and for the frontend bits.

The Open Source Prospector consists of three main components, all of which talk
directly to the database.

- Django ORM models
- Frontend
- Metric calculation
- Importers

Configuration is done via auto-generated `django.contrib.admin` applications.


### Django ORM models ###
The database models are distributed among the Django apps by function.

- `btinfo`: Bug tracker metadata + imported information
- `cveinfo`: CPE metadata + imported CVE information
- `gtrendsinfo`: Google Trends queries + datapoints
- `jamiqinfo`: JamiQ topics + datapoints
- `mlinfo`: Mailing list metadata + imported information
- `participantinfo`: Participant/Contributor imported information
- `projectinfo`: Metadata on basic projects
- `vcsinfo`: VCS repository information
- `hmeter_frontend`: Aggregated information linking the models from individual
projects and their respective resources from the `*info` apps.


### Frontend ###
The frontend code can be found in the `hmeter_frontend` Django app, which is
located in `wsgi/healthmeter/hmeter_frontend/`.

There are three main user-visible views:

- `hmeter_frontend.views.project.ProjectIndex`:
The main project view, with URL `http://example.com/project/`. This view uses
Client-side Javascript files are in
`wsgi/healthmeter/hmeter_frontend/static/js/project/index`, and styles in
`wsgi/healthmeter/hmeter_frontend/static/css/project-index.css`

- `hmeter_frontend.views.project.ProjectDetail`: The detailed project report,
with URL `http://example.com/project/$id/`. This view is rendered according to
the layout of the `Metric` tree as configured in the database by combining
`hmeter_frontend/project/fragments/detail/sections/*` template fragments as
per the configured `Metric.template_name` field.

- `hmeter_frontend.views.project.CompareProject`: Project comparison page, with
URL `http://example.com/project/$comma_separated_ids`.


### Metric Calculation ###
The metric calculation portion is set up in `hmeter_frontend/metrics/`, with the
entry-point currently being in `hmeter_frontend.models.Metric.score_project`.

Each metric algorithm, as referenced by the `Metric.algorithm.name` field, can
be found in `hmeter_frontend.metrics.algorithms.*`, registered onto a `dict`
object in `hmeter_frontend.metrics.lookup`.

The metric algorithms follow a similar structure to the Django Class Based
Views, where each algorithm is a class that is constructed once per metric
calculation.


### Importers ###
The importers are implemented in `*.importers.`, with corresponding management
commands defined in `*.management.commands.update_*` for easy shell-based
invocation.

Loading

0 comments on commit 080acfd

Please sign in to comment.