code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/python # It's only just begun... # Current status: completely unusable, try the fence_cxs.py script for the moment. This Red # Hat compatible version is just in its' infancy. # Copyright 2011 Matt Clark # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU G...
Python
#!/usr/bin/python import sys, getopt, time, os import pexpect, re import telnetlib import atexit import __main__ ## do not add code here. #BEGIN_VERSION_GENERATION RELEASE_VERSION="3.0.17" BUILD_DATE="(built Thu Oct 7 07:06:21 UTC 2010)" REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved." #E...
Python
#!/usr/bin/python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Fr...
Python
#!/usr/bin/python import sys, getopt, time, os import pexpect, re import telnetlib import atexit import __main__ ## do not add code here. #BEGIN_VERSION_GENERATION RELEASE_VERSION="3.0.17" BUILD_DATE="(built Thu Oct 7 07:06:21 UTC 2010)" REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved." #E...
Python
#!/usr/bin/env python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # th...
Python
#!/usr/bin/env python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # th...
Python
#!/usr/bin/python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Fr...
Python
#!/usr/bin/python import sys, getopt, time, os import pexpect, re import telnetlib import atexit import __main__ ## do not add code here. #BEGIN_VERSION_GENERATION RELEASE_VERSION="3.0.17" BUILD_DATE="(built Thu Oct 7 07:06:21 UTC 2010)" REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved." #E...
Python
#!/usr/bin/python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Fr...
Python
#!/usr/bin/python import sys, getopt, time, os import pexpect, re import telnetlib import atexit import __main__ ## do not add code here. #BEGIN_VERSION_GENERATION RELEASE_VERSION="3.0.17" BUILD_DATE="(built Thu Oct 7 07:06:21 UTC 2010)" REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved." #E...
Python
#!/usr/bin/env python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # th...
Python
#!/usr/bin/env python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # th...
Python
#============================================================================ # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public # License as published by the Free Software Foundation. # # This library is distributed in the hope th...
Python
#!/usr/bin/python # ############################################################################# # Copyright 2011 Matt Clark # This file is part of fence-xenserver # # fence-xenserver is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Fr...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with url parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single f...
Python
#!/usr/bin/python # # Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law ...
Python
#!/usr/bin/python # # Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law ...
Python
""" The MIT License Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the ...
Python
# This is the version of this source code. manual_verstr = "1.5" auto_build_num = "211" verstr = manual_verstr + "." + auto_build_num try: from pyutil.version_class import Version as pyutil_Version __version__ = pyutil_Version(verstr) except (ImportError, ValueError): # Maybe there is no pyutil insta...
Python
""" The MIT License Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the ...
Python
""" The MIT License Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright 2011 Google Inc. All Rights Reserved. """Multi-credential file store with lock support. This module implements a JSON credential store where multiple credentials can be stored in one file. That file supports locking both in a single process and across processes. The credential themselves are keyed off o...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
#!/usr/bin/python2.4 # -*- coding: utf-8 -*- # # Copyright (C) 2011 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
Python
# Copyright (C) 2011 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
import Cookie import datetime import time import email.utils import calendar import base64 import hashlib import hmac import re import logging # Ripped from the Tornado Framework's web.py # http://github.com/facebook/tornado/commit/39ac6d169a36a54bb1f6b9bf1fdebb5c9da96e09 # # Tornado is licensed under the Apache Licen...
Python
# Copyright (C) 2007 Joe Gregorio # # Licensed under the MIT License """MIME-Type Parser This module provides basic functions for handling mime-types. It can handle matching mime-types against a list of media-ranges. See section 14.1 of the HTTP specification [RFC 2616] for a complete explanation. http://www.w3.o...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
#!/usr/bin/python2.4 # # Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
#!/usr/bin/python2.4 # # Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Python
# Early, and incomplete implementation of -04. # import re import urllib RESERVED = ":/?#[]@!$&'()*+,;=" OPERATOR = "+./;?|!@" EXPLODE = "*+" MODIFIER = ":^" TEMPLATE = re.compile(r"{(?P<operator>[\+\./;\?|!@])?(?P<varlist>[^}]+)}", re.UNICODE) VAR = re.compile(r"^(?P<varname>[^=\+\*:\^]+)((?P<explode>[\+\*])|(?P<part...
Python
#!/usr/bin/env python # Copyright (c) 2010, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this l...
Python
"""SocksiPy - Python SOCKS module. Version 1.00 Copyright 2006 Dan-Haim. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this ...
Python
""" iri2uri Converts an IRI to a URI. """ __author__ = "Joe Gregorio (joe@bitworking.org)" __copyright__ = "Copyright 2006, Joe Gregorio" __contributors__ = [] __version__ = "1.0.0" __license__ = "MIT" __history__ = """ """ import urlparse # Convert an IRI to a URI following the rules in RFC 3987 # # The characte...
Python
from __future__ import generators """ httplib2 A caching http interface that supports ETags and gzip to conserve bandwidth. Requires Python 2.3 or later Changelog: 2007-08-18, Rick: Modified so it's able to use a socks proxy if needed. """ __author__ = "Joe Gregorio (joe@bitworking.org)" __copyright__ = "Copyright...
Python
#!/usr/bin/env python # # Copyright (c) 2002, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this ...
Python
COMPONENTS = [ "AdaBoost", "AutoInvert", "AutoMlpClassifier", "BiggestCcExtractor", "BinarizeByHT", "BinarizeByOtsu", "BinarizeByRange", "BinarizeBySauvola", "BitDataset", "BitNN", "BookStore", "CascadedMLP", "CenterFeatureMap", "ConnectedComponentSegmenter", "CurvedCutSegmenter", "CurvedCutWithCcSe...
Python
# Django settings for ocradmin project. import os import sys import socket import subprocess as sp # Ensure celery/lazy loading Django models play nice import djcelery djcelery.setup_loader() SITE_ROOT = os.path.abspath(os.path.dirname(__file__)) # add lib dir to pythonpath sys.path.insert(0, os.path.join(SITE_RO...
Python
from django.db import models # Create your models here.
Python
""" Useful functions and classes for nodes to use. """ from __future__ import absolute_import import os import re import tempfile import subprocess as sp from lxml import etree from HTMLParser import HTMLParser from . import cache, exceptions class HTMLContentHandler(HTMLParser): def __init__(self): HTM...
Python
""" Stages under which nodes are categorized. Listed in this module to avoid typing the wrong string. """ INPUT = "input" OUTPUT = "output" FILTER_BINARY = "filter_binary" FILTER_GRAY = "filter_gray" BINARIZE = "binarize" PAGE_SEGMENT = "page_segment" RECOGNIZE = "recognize" UTILS = "utils" POST = "post_process"
Python
""" Utility class for displaying node scripts. """ import os import re import sys import pydot import json import tempfile class DotError(StandardError): """Dot problems.""" # http://www.graphviz.org/doc/info/lang.html RAW_NAME_RE = r"(^[A-Za-z_][a-zA-Z0-9_]*$)|(^-?([.[0-9]+|[0-9]+(.[0-9]*)?)$)" def condition...
Python
""" OCR-specific nodetree cacher classes. """ import os import shutil from contextlib import contextmanager from nodetree import cache from ocradmin.vendor import deepzoom import hashlib import bencode from pymongo import Connection import gridfs class UnsupportedCacheTypeError(StandardError): pass class BaseC...
Python
""" Test the scripts. """ import os import glob from django.test import TestCase from django.utils import simplejson as json from django.conf import settings from ocradmin.core.tests import testutils from nodetree import script, node, exceptions import numpy from ocradmin.nodelib import nodes VALID_SCRIPTDIR = ...
Python
""" Nodetree related exceptions. """ class ExternalToolError(StandardError): """Errors with external command-line tools etc.""" class AbortedAction(StandardError): """Exception to raise when execution is aborted.""" class ImproperlyConfigured(StandardError): """Something is configured wrong"""
Python
""" Tesseract Recogniser """ from __future__ import absolute_import import os import shutil import codecs import tempfile import subprocess as sp from nodetree import node, exceptions, utils as nodeutils from . import base from .. import stages, utils, exceptions from ocradmin.ocrmodels.models import OcrModel fro...
Python
""" Cuneiform Recogniser """ from __future__ import absolute_import import os import shutil import tempfile import subprocess as sp from nodetree import node import numpy from . import base from .. import utils, stages, types class AbbyyRecognizer(base.CommandLineRecognizerNode): """ Recognize an image us...
Python
""" Nodes for interoperating with Fedora Commons. """ import os import ocrolib from nodetree import node, exceptions from cStringIO import StringIO from . import base, util as utilnodes from .. import stages, utils from eulfedora.server import Repository from eulfedora.models import DigitalObject, FileDatastream fro...
Python
""" Storage node interfaces. """ from __future__ import absolute_import import os import re import io import codecs import tempfile import subprocess as sp from cStringIO import StringIO import hashlib from nodetree import node, writable_node, exceptions from . import base, util as utilnodes from .. import stages, ...
Python
""" Generic base classes for other nodes. """ from __future__ import absolute_import import os import codecs import json import subprocess as sp from nodetree import node, writable_node, exceptions import ocrolib from PIL import Image from .. import stages, types, utils class ExternalToolError(StandardError): ...
Python
""" Cuneiform Recogniser """ from __future__ import absolute_import import os import codecs import shutil import tempfile import subprocess as sp import numpy from nodetree import node from . import base from .. import stages, types, utils class CuneiformRecognizer(base.CommandLineRecognizerNode): """ Re...
Python
""" Nodes that use web services to do something. """ import json import httplib2 import urllib from BeautifulSoup import BeautifulSoup from nodetree import node, exceptions from . import base from .. import stages class WebServiceNodeError(exceptions.NodeError): pass class BaseWebService(node.Node, base.TextW...
Python
""" Nodes to perform random things. """ from __future__ import absolute_import import os import re import codecs import tempfile import subprocess as sp from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup from nodetree import node, writable_node, exceptions from . import base from .. import stages, types, ut...
Python
from __future__ import absolute_import from nodetree import node, writable_node, exceptions from .base import GrayPngWriterMixin from .. import stages import numpy class Rotate90(node.Node, GrayPngWriterMixin): """ Rotate a Numpy image num*90 degrees counter-clockwise. """ stage = stages.FILTER_BINA...
Python
""" Experimental segmentation nodes. """ from __future__ import absolute_import from nodetree import node, writable_node import ocrolib from ocrolib import iulib, numpy from . import base from .. import stages class Rectangle(object): """ Rectangle class, Iulib-style. """ def __init__(self, x0, y0...
Python
from __future__ import absolute_import from . import ( abbyy, ocropus, tesseract, util, numpy, pil, ocrlab, cuneiform, web, fedora, storage)
Python
""" Ocropus OCR processing nodes. """ from __future__ import absolute_import import os import sys import json from nodetree import node, writable_node, exceptions from nodetree import utils as nodeutils import ocrolib from ocradmin.ocrmodels.models import OcrModel from . import base from .. import stages, utils ...
Python
""" Image transformation nodes based on the Python Image Library (PIL). """ from __future__ import absolute_import import os from nodetree import node, exceptions import numpy from PIL import Image from . import base from .. import stages def image2array(im): if im.mode not in ("L", "F"): raise ValueEr...
Python
""" Custom types for node input/output. """ class HocrString(unicode): pass
Python
""" Object representing a batch operation, consisting of one or more OcrTasks. """ import datetime from django.db import models from django.contrib.auth.models import User from tagging.fields import TagField from ocradmin.projects.models import Project class Batch(models.Model): """ OCR Batch object. ""...
Python
from django.conf.urls.defaults import * from ocradmin.batch import views from django.contrib.auth.decorators import login_required urlpatterns = patterns('', (r'^abort/(?P<batch_pk>\d+)/?$', login_required(views.abort_batch)), (r'^create/?$', login_required(views.create)), (r'^delete/(?P<pk>\d+)/?$', login_requ...
Python
from django.template import Library register = Library() @register.filter def get_range( value ): """ Filter - returns a list containing range made from given value Usage (in template): <ul>{% for i in 3|get_range %} <li>{{ i }}. Do something</li> {% endfor %}</ul> Results with the HTM...
Python
from batch_tests import *
Python
""" OCR batch tests. """ import os import re import shutil from django.test import TestCase from django.test.client import Client from django.contrib.auth.models import User from django.conf import settings from ocradmin.presets.models import Preset from ocradmin.batch.models import Batch from ocradmin.ocrtasks.mo...
Python
""" Celery tasks for Batch operations. """ import os import shutil from celery.contrib.abortable import AbortableTask from celery.task.sets import subtask from ocradmin.ocrtasks.decorators import register_handlers from ocradmin.ocrtasks.utils import get_progress_callback, get_abort_callback from django.utils import si...
Python
""" Batch-related views. """ import os import glob import tarfile import StringIO from django import forms from django.contrib.auth.decorators import login_required from django.core import serializers from django.core.serializers.json import DjangoJSONEncoder from django.conf import settings from django.db import tra...
Python
from django.db import models # Create your models here.
Python
""" This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". Replace these with more appropriate tests for your application. """ from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): """ ...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^ls/?$', 'ocradmin.filebrowser.views.ls'), (r'^explore/?$', 'ocradmin.filebrowser.views.explore'), )
Python
# App for browsing the server. import os import time from stat import * from django.conf import settings from django.contrib.auth.decorators import login_required from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import render_to_response from django.template import RequestConte...
Python
from django.conf.urls.defaults import * from django.conf import settings # Uncomment the next two lines to enable the admin: from django.contrib import admin from django.contrib.auth.views import login, logout admin.autodiscover() import djcelery urlpatterns = patterns('', # Static media (r'^static/(?P<path>...
Python
""" Class for Asyncronous OCR jobs. Wraps tasks that run on the Celery queue with more metadata and persistance. """ import datetime import uuid from django.db import models from picklefield import fields from ocradmin.batch.models import Batch from ocradmin.projects.models import Project from django.contrib.auth.m...
Python
""" Utilities for managing OcrTasks. """ from celery.contrib.abortable import AbortableAsyncResult from models import OcrTask def get_progress_callback(task_id): """ Closure for generating a function that refers to a task id in outer scope. """ def progress_func(progress, lines=None): ""...
Python
""" Utils for testing the Ocr Task wrapper. """ from celery.contrib.abortable import AbortableTask from decorators import register_handlers @register_handlers class TestTask(AbortableTask): """ Dummy task for running tests on. """ name = "testing.test" max_retries = None def run(self, a, b,...
Python
""" This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". Replace these with more appropriate tests for your application. """ from django.conf import settings from django.contrib.auth.models import User from django.test import TestCase...
Python
from django.conf.urls.defaults import * from ocradmin.ocrtasks import views from django.contrib.auth.decorators import login_required urlpatterns = patterns('', (r'^list/?$', login_required(views.tasklist)), (r'^detail/(?P<pk>\d+)/$', login_required(views.taskdetail)), (r'^delete/(?P<pk>\d+)?/?$', login_require...
Python
""" Callbacks to run when certain celery signals are recieved in response to the ConvertPageTask. """ from ocradmin.ocrtasks.models import OcrTask from celery.datastructures import ExceptionInfo def on_task_sent(**kwargs): """ Update the database when a task is sent to the broker. """ task = OcrTask....
Python
""" Decorator for registering Celery fun classes with wrapper handlers. """ from celery.registry import tasks from celery.signals import task_sent, task_prerun, \ task_postrun, task_failure from handlers import on_task_sent, on_task_prerun, \ on_task_postrun, on_task_failure def register_handlers(tas...
Python
""" View the task objects that are created when submitting a celery task and updated by it's subsequent signals. """ from django.http import HttpResponse from django.shortcuts import render, get_object_or_404 from django.utils import simplejson as json from ocradmin.ocrtasks.models import OcrTask from ocradmin.core im...
Python
""" Generic OCR helper functions and wrapper around various OCRopus and Tesseract tools. """ import os import re from datetime import datetime import subprocess as sp from PIL import Image from django.utils import simplejson from django.conf import settings from HTMLParser import HTMLParser from xml.parsers import ...
Python
from django.conf.urls.defaults import * from django.contrib.auth.decorators import login_required from ocradmin.core import views urlpatterns = patterns('', (r'^/?$', 'ocradmin.core.views.index'), (r'^abort/(?P<task_id>[^\/]+)/?$', login_required(views.abort)), (r'^task_config/(?P<task_pk>\d+)/?$', login_re...
Python
import re from django.template import Library from django.conf import settings register = Library() @register.filter def formatattr(value): """Formats an object's nested attribute for display""" value = value.split(".")[-1] return " ".join([p.capitalize() for p in value.split("_")])
Python
import re import types from django.template import Library from django.conf import settings numeric_test = re.compile("^\d+$") register = Library() @register.filter def getattribute(value, argstr): """Gets an attribute of an object dynamically from a string name""" args = argstr.split(".") leads = args[:-...
Python
import time import utils def test_simple_binarize(): """ Test the Ocropus native binarizer. """ start = time.clock() wrap = utils.OcropusWrapper(params={"clean": "StandardPreprocessing"}) bin = wrap.get_page_binary("21.png") return time.clock() - start def test_sp_binarize(): """ ...
Python
# Miscellaneos functions relating the projects app import os from datetime import datetime from django.http import HttpResponseRedirect from django.utils.http import urlquote from django.conf import settings def project_required(func): """ Decorator function for other actions that require a project to be ...
Python
""" Generic base classes for template handling. These prevent having to write lots of boring code but it's necessary to read the docs to understand it: https://docs.djangoproject.com/en/1.3/topics/class-based-views/ https://docs.djangoproject.com/en/1.3/ref/class-based-views/ """ from django import http from djan...
Python
""" Functions for performing test setup/teardown etc. """ import os MODELDIR = "etc/defaultmodels" def symlink_model_fixtures(): """ Create symlinks between the files referenced in the OcrModel fixtures and our default model files. Need to do this because they get deleted again at test teardown. ...
Python