def handle(self, *args, **options): print "Starting" if os.path.exists(options["path"]): dst_path = os.path.join(options["path"], "ghiro_output") if os.path.exists(dst_path): print "ERROR: a folder 'ghiro_output' already exist in that path!" sys.exit() else: # Mongo connection. db = mongo_connect() fs = gridfs.GridFS(db) # We are fine, run! for analysis in Analysis.objects.all(): try: file = get_file(analysis.image_id) except (InvalidId, TypeError): print "Unable to dump %s" % analysis.id continue else: with open( os.path.join(dst_path, "analysis_%s" % analysis.id), "a") as the_file: the_file.write(file) else: print "ERROR: path not found!"
def handle(self, *args, **options): print "Starting" if os.path.exists(options["path"]): dst_path = os.path.join(options["path"], "ghiro_output") if os.path.exists(dst_path): print "ERROR: a folder 'ghiro_output' already exist in that path!" sys.exit() else: # Mongo connection. db = mongo_connect() fs = gridfs.GridFS(db) # We are fine, run! for analysis in Analysis.objects.all(): try: file = get_file(analysis.image_id) except (InvalidId, TypeError): print "Unable to dump %s" % analysis.id continue else: with open(os.path.join(dst_path, "analysis_%s" % analysis.id), "a") as the_file: the_file.write(file) else: print "ERROR: path not found!"
from django.utils.timezone import now from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.db.models import Count from django.utils.encoding import force_unicode from django.core.files import File from django.core.files.temp import NamedTemporaryFile import analyses.forms as forms from analyses.models import Case, Analysis, Favorite, Comment, Tag from lib.db import save_file, get_file from lib.utils import create_thumb from users.models import Profile from ghiro.common import log_activity, mongo_connect, check_allowed_content # Mongo connection. db = mongo_connect() fs = gridfs.GridFS(db) @login_required def new_case(request): """Creates a new case.""" if request.method == "POST": form = forms.CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.owner = request.user case.save() form.save_m2m() # Always add owner. case.users.add(request.user) # Auditing.
from django.http import HttpResponseRedirect, HttpResponse from django.core.urlresolvers import reverse from django.db.models import Q from django.utils.timezone import now from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.db.models import Count import analyses.forms as forms from analyses.models import Case, Analysis from users.models import Profile from analyzer.db import save_file, get_file from analyzer.utils import create_thumb from ghiro.common import log_activity, mongo_connect # Mongo connection. db = mongo_connect() fs = gridfs.GridFS(db) @login_required def new_case(request): """Creates a new case.""" if request.method == "POST": form = forms.CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.owner = request.user case.save() form.save_m2m() # Always add owner. case.users.add(request.user)