-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
141 changed files
with
4,425 additions
and
748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- '2.7' | ||
notifications: | ||
irc: | ||
channels: | ||
- "anchor.foonetic.net#jplusplus" | ||
- anchor.foonetic.net#jplusplus | ||
on_success: always | ||
on_failure: always | ||
slack: | ||
secure: lc2NcRnOWDXmxoQt8wJh0947g9+cIpDaSe2SAJlXigdPL8qzq04GriV0KmRlcVBvjqB4bViWfEsn5ldtGBBiu5wyQ/nIckESfV/8zpLmUM5uEqhx1U3f9YJLDLjH1THNAJBIL9EI9DKo9IHF2uiZF0/sGj4ejorjiZC8J+K3MWk= | ||
before_install: | ||
- export COVERALLS_REPO_TOKEN=6opRu71NU2ODTYXULbiEUS1EPTcDNcZqI | ||
- export COVERALLS_SERVICE_NAME=travis-ci | ||
- export DATABASE_URL=sqlite:///test.db | ||
- export DJANGO_SETTINGS_MODULE=app.settings_tests | ||
- export NEO4J_PORT=7474 | ||
- export NEO4J_VERSION=1.9.1 | ||
- export COVERALLS_REPO_TOKEN=UDtLCy1He2SylMvJMjq1Uu9f1zVFbTim8 | ||
- export COVERALLS_SERVICE_NAME=travis-ci | ||
- export DATABASE_URL=sqlite:///test.db | ||
- export DJANGO_SETTINGS_MODULE=app.settings_tests | ||
- export NEO4J_PORT=7474 | ||
- export NEO4J_VERSION=1.9.1 | ||
install: | ||
- ./install_local_neo4j.bash $NEO4J_VERSION | ||
- ./lib/neo4j/bin/neo4j start | ||
- pip install -r test_requirements.txt | ||
- pip install coveralls | ||
- ./install_local_neo4j.bash $NEO4J_VERSION | ||
- ./lib/neo4j/bin/neo4j start | ||
- pip install -r test_requirements.txt | ||
- pip install coveralls | ||
script: | ||
- coverage run --source=app.detective ./manage.py test detective --pythonpath=. --traceback | ||
- coverage run --source=app.detective ./manage.py test detective --pythonpath=. --traceback | ||
after_success: | ||
- coveralls | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class UnavailableImage(Exception): pass | ||
class NotAnImage(Exception): pass |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
# Encoding: utf-8 | ||
# ----------------------------------------------------------------------------- | ||
# Project : Detective.io | ||
# ----------------------------------------------------------------------------- | ||
# Author : Edouard Richard <[email protected]> | ||
# ----------------------------------------------------------------------------- | ||
# License : GNU GENERAL PUBLIC LICENSE v3 | ||
# ----------------------------------------------------------------------------- | ||
# Creation : 04-09-2014 | ||
# Last mod : 04-09-2014 | ||
# ----------------------------------------------------------------------------- | ||
from django.core.management.base import BaseCommand, CommandError | ||
import json | ||
from django.db.models.loading import get_model | ||
from optparse import make_option | ||
from app.detective.models import Topic | ||
from app.detective import utils | ||
|
||
class Command(BaseCommand): | ||
help = "Detect orphans in the graph." | ||
option_list = BaseCommand.option_list + ( | ||
make_option('--fix', | ||
action='store_true', | ||
dest='fix', | ||
default=False, | ||
help='Delete orphans'), | ||
) | ||
|
||
def handle(self, *args, **options): | ||
total_orphans_count = 0 | ||
for topic in Topic.objects.all(): | ||
# escape common & energy as usual | ||
if topic.slug in ["common", "energy"]: continue | ||
self.stdout.write("Topic: %s" % (topic)) | ||
orphans_count = 0 | ||
try: | ||
for Model in topic.get_models(): | ||
try: | ||
fields = utils.get_model_fields(Model) | ||
for field in fields: | ||
if field["related_model"] and field["direction"] == "out" and "through" in field["rules"]: | ||
ids= [] | ||
for Model in Model.objects.all(): | ||
ids.extend([_.id for _ in Model.node.relationships.all()]) | ||
Properties = field["rules"]["through"] | ||
for info in Properties.objects.all(): | ||
if info._relationship not in ids: | ||
self.stdout.write("\t%s is an orphelin property of the model %s. The relation doesn't exist no more." % (info._NodeModel__node, Model.__class__.__name__)) | ||
orphans_count += 1 | ||
total_orphans_count += 1 | ||
if options["fix"]: | ||
self.stdout.write("\tremoving %s" % (info)) | ||
info.delete() | ||
except Exception as e: | ||
self.stderr.write("\tError with model %s (%s)" % (Model.__class__.__name__, e)) | ||
self.stdout.write("\tfound %d orphans" % (orphans_count)) | ||
except Exception as e: | ||
self.stderr.write("\tError with model %s (%s)" % (Model.__class__.__name__, e)) | ||
self.stdout.write("TOTAL: found %d orphans" % (total_orphans_count)) | ||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
# Encoding: utf-8 | ||
# ----------------------------------------------------------------------------- | ||
# Project : Detective.io | ||
# ----------------------------------------------------------------------------- | ||
# Author : Edouard Richard <[email protected]> | ||
# ----------------------------------------------------------------------------- | ||
# License : GNU GENERAL PUBLIC LICENSE v3 | ||
# ----------------------------------------------------------------------------- | ||
# Creation : 05-09-2014 | ||
# Last mod : 05-09-2014 | ||
# ----------------------------------------------------------------------------- | ||
from django.core.management.base import BaseCommand | ||
from optparse import make_option | ||
from django.contrib.auth.models import User | ||
from app.detective.models import DetectiveProfileUser, Topic | ||
|
||
class Command(BaseCommand): | ||
help = "Detect orphans in the graph." | ||
option_list = BaseCommand.option_list + ( | ||
make_option('--fix', | ||
action='store_true', | ||
dest='fix', | ||
default=False, | ||
help='upgrade the plan'), | ||
) | ||
|
||
def handle(self, *args, **options): | ||
from django.conf import settings | ||
for user in User.objects.all(): | ||
profile = DetectiveProfileUser.objects.get(user=user) | ||
user_topics = Topic.objects.filter(author=user) | ||
number_of_topic = user_topics.count() | ||
max_number_of_entities = 0 | ||
for topic in user_topics: | ||
max_number_of_entities = max(max_number_of_entities, topic.entities_count()) | ||
for plan in settings.PLANS: | ||
best_plan, proprs = plan.items()[0] | ||
if proprs.get("max_investigation") != -1 and number_of_topic > proprs.get("max_investigation"): continue | ||
if proprs.get("max_entities") != -1 and max_number_of_entities > proprs.get("max_entities") : continue | ||
break | ||
self.stdout.write("%s : %s ---> %s" % (user.username, profile.plan, best_plan)) | ||
if options["fix"]: | ||
profile.plan = best_plan | ||
profile.save() | ||
|
||
# EOF |
Oops, something went wrong.