示例#1
0
from ..entry import get_entry_by_id, update_entry_by_id, Purpose, Variant, State
from ..localfile import FileCopy, FolderScanner


############
# RAW IMPORT


class RawImportOptions(PropertySet):
    entry_id = Property(int)
    source_path = Property()
    folder = Property()
    mime_type = Property()


register_schema(RawImportOptions)


class RawImportJobHandler(JobHandler):
    Options = RawImportOptions
    method = 'raw_import'

    def run(self, job):
        logging.info('Starting raw import.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        self.system = current_system()
        self.options = job.options
        self.folder = self.system.import_folders[self.options.folder]
示例#2
0
文件: jpg.py 项目: eblade/images6
from ..job import JobHandler, Job, create_job, register_job_handler
from ..job.imageproxy import ImageProxyOptions, ImageProxyJobHandler


class JPEGImportOptions(PropertySet):
    entry_id = Property(int)
    source_path = Property()
    folder = Property()
    mime_type = Property()
    analyse = Property(bool)
    is_derivative = Property(bool, default=False)
    source_purpose = Property(enum=Purpose, default=Purpose.raw)
    source_version = Property(int)


register_schema(JPEGImportOptions)


class JPEGImportJobHandler(JobHandler):
    Options = JPEGImportOptions
    method = 'jpeg_import'

    def run(self, job):
        logging.info('Starting jpg generation.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        self.system = current_system()
        self.options = job.options
        self.folder = self.system.import_folders[self.options.folder]
示例#3
0
from ..job import JobHandler, register_job_handler
from ..system import current_system
from ..entry import get_entry_by_id, update_entry_by_id, Purpose, Backup


class FlickrOptions(PropertySet):
    entry_id = Property(int)
    source_purpose = Property(enum=Purpose, default=Purpose.original)
    source_version = Property(int)
    title = Property()
    description = Property()
    tags = Property(list)
    is_public = Property(bool, default=True)


register_schema(FlickrOptions)


class FlickrJobHandler(JobHandler):
    method = 'flickr'
    Options = FlickrOptions

    def run(self, job):
        logging.info('Starting flickr export.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())

        options = job.options
        entry = get_entry_by_id(options.entry_id)
示例#4
0
文件: amend.py 项目: eblade/images6
import logging
from lindh.jsonobject import register_schema, PropertySet, Property

from ..system import current_system
from ..job import JobHandler, register_job_handler
from ..entry import get_entry_by_id, update_entry_by_id, Purpose, Variant
from ..localfile import FileCopy, FolderScanner


class AmendOptions(PropertySet):
    entry_id = Property(int)
    amend_metadata = Property(bool, default=True)
    amend_variants = Property(bool, default=True)


register_schema(AmendOptions)


class AmendJobHandler(JobHandler):
    method = 'amend'
    Options = AmendOptions

    def run(self, job):
        logging.info('Starting amending.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())

        options = job.options
        entry = get_entry_by_id(options.entry_id)
        before = entry.to_json()
示例#5
0
文件: remote.py 项目: eblade/images6
from ..entry import (
    Variant,
    Backup,
    get_entry_by_id,
    update_entry_by_id,
)
from ..job import JobHandler, Job, create_job, register_job_handler


class RemoteOptions(PropertySet):
    entry_id = Property(int)
    variant = Property(type=Variant)
    remote = Property()


register_schema(RemoteOptions)


class RemoteJobHandler(JobHandler):
    Options = RemoteOptions
    method = 'remote'

    def run(self, job):
        logging.info('Starting remote transfer.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        system = current_system()
        options = job.options
        remote = system.remotes[options.remote]
        rules = system.rules.values()
示例#6
0

def get_job_handler_for_method(method):
    return _handlers[method]


class JobHandler(object):
    def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key.replace(' ', '_'), value)

    def run(self, *args, **kwargs):
        raise NotImplemented


class DummyOptions(PropertySet):
    time = Property(float, default=1.0)


class DummyJobHandler(JobHandler):
    method = 'dummy'
    Options = DummyOptions

    def run(self, job):
        options = job.options
        time.sleep(options.time)


register_job_handler(DummyJobHandler)
register_schema(DummyOptions)
示例#7
0
文件: publish.py 项目: eblade/images6
class ElementType(EnumProperty):
    image = 'image'
    text = 'text'
    heading = 'heading'


class Element(PropertySet):
    type = Property(enum=ElementType, default=ElementType.image)
    src = Property()
    content = Property()
    entry_id = Property()


class Page(PropertySet):
    number = Property(int)
    show = Property(bool, default=True)
    width = Property(int)
    height = Property(int)
    elements = Property(type=Element, is_list=True)


class Publication(PropertySet):
    author = Property()
    publish_ts = Property()
    title = Property()
    comment = Property()
    pages = Property(type=Page, is_list=True)


register_schema(Publication)
示例#8
0
    Purpose,
    get_entry_by_id,
    update_entry_by_id,
    delete_entry_by_id,
)


class ImageProxyOptions(PropertySet):
    entry_id = Property(int)
    angle = Property(int)
    mirror = Property(int)
    source_purpose = Property(enum=Purpose, default=Purpose.original)
    source_version = Property(int)


register_schema(ImageProxyOptions)


class ImageProxyJobHandler(JobHandler):
    Options = ImageProxyOptions
    method = 'imageproxy'

    def run(self, job):
        logging.info('Starting image proxy generation.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        options = job.options

        self.entry = get_entry_by_id(options.entry_id)
        logging.info('Entry\n%s', self.entry.to_json())
示例#9
0
from ..system import current_system
from ..entry import (
    Variant,
    get_entry_by_id,
    update_entry_by_id,
)
from ..job import JobHandler, Job, create_job, register_job_handler
from .remote import RemoteOptions, RemoteJobHandler


class RulesOptions(PropertySet):
    entry_id = Property(int)
    entry_ids = Property(list)


register_schema(RulesOptions)


class RulesJobHandler(JobHandler):
    Options = RulesOptions
    method = 'rules'

    def run(self, job):
        logging.info('Starting rules check.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        system = current_system()
        options = job.options
        rules = system.rules.values()
示例#10
0
from lindh.jsonobject import PropertySet, Property, register_schema

from ..system import current_system
from ..localfile import FileCopy, mangle
from ..job import JobHandler, Job, register_job_handler
from ..entry import Variant


LOCAL_STORES = ('original', 'derivative', 'thumb', 'proxy', 'check', 'raw')

class DeleteOptions(PropertySet):
    entry_id = Property(int)
    variant = Property(Variant)


register_schema(DeleteOptions)


class DeleteJobHandler(JobHandler):
    Options = DeleteOptions
    method = 'delete'

    def run(self, job):
        logging.info('Starting delete job.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        self.system = current_system()
        self.options = job.options
        self.variant = job.options.variant
示例#11
0
from . import JobHandler, register_job_handler
from ..system import current_system
from ..entry import get_entry_by_id, update_entry_by_id, Purpose, Variant, State


#################
# TAG BULK UPDATE


class TagBulkUpdateOptions(PropertySet):
    entry_ids = Property(list)
    add_tags = Property(list)
    remove_tags = Property(list)


register_schema(TagBulkUpdateOptions)


class TagBulkUpdateJobHandler(JobHandler):
    Options = TagBulkUpdateOptions
    method = 'tag_update'

    def run(self, job):
        logging.info('Starting tag update.')
        assert job is not None, "Job can't be None"
        assert job.options is not None, "Job Options can't be None"
        logging.info('Job\n%s', job.to_json())
        system = current_system()
        options = job.options

        if len(options.add_tags) == 0 and len(options.remove_tags) == 0: