How to use the paperwork.frontend.util.jobs.Job function in paperwork

To help you get started, we’ve selected a few paperwork examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / mainwindow / pages.py View on Github external
def __init__(self, factory, job_id, page, size):
        Job.__init__(self, factory, job_id)
        self.page = page
        self.size = size
        self.__cond = threading.Condition()
        self.can_run = True
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / mainwindow / scan.py View on Github external
def __init__(self, factory, id, scan_session):
        Job.__init__(self, factory, id)
        self.can_run = False
        self.scan_session = scan_session
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / mainwindow / pages.py View on Github external
from paperwork_backend.common.page import BasicPage
from paperwork_backend.util import image2surface
from paperwork_backend.util import split_words
from paperwork.frontend.util.canvas.animations import SpinnerAnimation
from paperwork.frontend.util.canvas.drawers import Drawer
from paperwork.frontend.util.imgcutting import ImgGripHandler
from paperwork.frontend.util import load_image
from paperwork.frontend.util.jobs import Job
from paperwork.frontend.util.jobs import JobFactory


_ = gettext.gettext
logger = logging.getLogger(__name__)


class JobPageImgLoader(Job):
    can_stop = True
    priority = 500

    __gsignals__ = {
        'page-loading-start': (GObject.SignalFlags.RUN_LAST, None, ()),
        'page-loading-img': (GObject.SignalFlags.RUN_LAST, None,
                             (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT)),
        'page-loading-done': (GObject.SignalFlags.RUN_LAST, None, ()),
    }

    def __init__(self, factory, job_id, page, size):
        Job.__init__(self, factory, job_id)
        self.page = page
        self.size = size
        self.__cond = threading.Condition()
        self.can_run = True
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / settingswindow / __init__.py View on Github external
def __init__(self, factory, id, resolutions_store, devid, source=None):
        Job.__init__(self, factory, id)
        self.__resolutions_store = resolutions_store
        self.__devid = devid
        self.__source = source
        self.can_run = False
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / mainwindow / docs.py View on Github external
from paperwork.frontend.util.img import image2pixbuf
from paperwork.frontend.util.jobs import Job
from paperwork.frontend.util.jobs import JobFactory
from paperwork.frontend.util.renderer import LabelWidget
from paperwork.frontend.widgets import LabelColorButton

_ = gettext.gettext
logger = logging.getLogger(__name__)


def sort_documents_by_date(documents):
    documents.sort()
    documents.reverse()


class JobDocThumbnailer(Job):
    """
    Generate doc list thumbnails
    """

    THUMB_BORDER = 1

    __gsignals__ = {
        'doc-thumbnailing-start': (GObject.SignalFlags.RUN_LAST, None, ()),
        'doc-thumbnailing-doc-done': (GObject.SignalFlags.RUN_LAST, None,
                                      (
                                          GObject.TYPE_PYOBJECT,  # thumbnail
                                          GObject.TYPE_PYOBJECT,  # doc
                                          GObject.TYPE_INT,  # current doc
                                          # number of docs being thumbnailed
                                          GObject.TYPE_INT,)),
        'doc-thumbnailing-end': (GObject.SignalFlags.RUN_LAST, None, ()),
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow / __init__.py View on Github external
job.connect(
            'doc-examination-start',
            lambda job: GLib.idle_add(
                self.__main_win.on_doc_examination_start_cb, job))
        job.connect(
            'doc-examination-progression',
            lambda job, progression, txt: GLib.idle_add(
                self.__main_win.set_progression, job, progression, txt))
        job.connect(
            'doc-examination-end',
            lambda job: GLib.idle_add(
                self.__main_win.on_doc_examination_end_cb, job))
        return job


class JobIndexUpdater(Job):
    """
    Update the index
    """

    __gsignals__ = {
        'index-update-start': (GObject.SignalFlags.RUN_LAST, None, ()),
        'index-update-progression': (GObject.SignalFlags.RUN_LAST, None,
                                     (GObject.TYPE_FLOAT,
                                      GObject.TYPE_STRING)),
        'index-update-interrupted': (GObject.SignalFlags.RUN_LAST, None, ()),
        'index-update-write': (GObject.SignalFlags.RUN_LAST, None, ()),
        'index-update-end': (GObject.SignalFlags.RUN_LAST, None, ()),
    }

    can_stop = True
    priority = 15
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / diag / __init__.py View on Github external
import pyinsane2
import gettext
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk

from paperwork.frontend.util import load_uifile
from paperwork.frontend.util.jobs import Job, JobFactory


_ = gettext.gettext
logger = logging.getLogger(__name__)


class JobInfoGetter(Job):
    __gsignals__ = {
        'scan-progression': (GObject.SignalFlags.RUN_LAST, None,
                             (GObject.TYPE_STRING,  # step
                              GObject.TYPE_FLOAT,  # [0.0-1.0]
                              )),
        'scan-done': (GObject.SignalFlags.RUN_LAST, None, ()),
    }

    STEP_SYSINFO = "a"
    STEP_PAPERWORK = "b"
    STEP_SCANNER = "c"

    can_stop = True
    priority = 1000

    def __init__(self, factory, id, main_win):
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / settingswindow / __init__.py View on Github external
from paperwork.frontend.util.actions import SimpleAction
from paperwork.frontend.util.canvas import Canvas
from paperwork.frontend.util.canvas.animations import ScanAnimation
from paperwork.frontend.util.canvas.drawers import PillowImageDrawer
from paperwork.frontend.util.config import DEFAULT_CALIBRATION_RESOLUTION
from paperwork.frontend.util.config import RECOMMENDED_SCAN_RESOLUTION
from paperwork.frontend.util.imgcutting import ImgGripHandler
from paperwork.frontend.util.jobs import Job, JobFactory, JobScheduler
from paperwork.frontend.util.jobs import JobFactoryProgressUpdater


_ = gettext.gettext
logger = logging.getLogger(__name__)


class JobDeviceFinder(Job):
    __gsignals__ = {
        'device-finding-start': (GObject.SignalFlags.RUN_LAST, None,
                                 ()),
        'device-found': (GObject.SignalFlags.RUN_LAST, None,
                         (GObject.TYPE_STRING,  # user name
                          GObject.TYPE_STRING,  # device id
                          GObject.TYPE_BOOLEAN)),  # is the active one
        'device-finding-end': (GObject.SignalFlags.RUN_LAST, None, ())
    }

    can_stop = False
    priority = 500

    def __init__(self, factory, id, selected_devid):
        Job.__init__(self, factory, id)
        self.__selected_devid = selected_devid
github openpaperwork / paperwork / paperwork-gtk / scripts / compare_algorithms.py View on Github external
OCR_TOOL = pyocr.get_available_tools()[0]

LOCK = threading.Lock()

MAX_LEVENSHTEIN_DISTANCE = 1
MIN_WORD_LEN = 4

g_lang = "eng"
g_dictionnary = None
g_tknzr = None
g_nb_total_pages = 0
g_start_time = None


class JobImageProcessing(Job):
    def __init__(self, factory, job_id, page_in, algos):
        super(JobImageProcessing, self).__init__(factory, job_id)
        self.page_in = page_in
        self.algos = algos

    def _add_score(self, txt, stats):
        stats['nb_pages'] += 1
        for (word, word_pos) in g_tknzr(txt):
            stats['nb_words'] += 1
            if len(word) < MIN_WORD_LEN:
                stats['too_short'] += 1
                continue
            if g_dictionnary.check(word):
                stats['perfect'] += 1
                continue
            suggestions = g_dictionnary.suggest(word)