示例#1
0
def load_package_modules(package_name, package_pathes):
    """
    Load (import) all modules from some package (except those starting with _).

    This is useful if there is some code in the module that runs at import time
    and registers some code of that module somewhere.

    Call this from __init__.py of the same package like this:

        load_package_modules(__name__, __path__)
    """
    for path in package_pathes:
        for root, dirs, files in os.walk(path):
            del dirs[:]
            for fname in files:
                if fname.startswith('_') or not fname.endswith('.py'):
                    continue
                module = fname[:-3]
                module_complete = package_name + '.' + module
                if module_complete in sys.modules:
                    continue
                info = imp.find_module(module, [root])
                try:
                    try:
                        imp.load_module(module_complete, *info)
                    except Exception as e:
                        import MoinMoin.log as logging
                        logger = logging.getLogger(package_name)
                        logger.exception("Failed to import {0} package module {1}: {2}".format(package_name, module, e))
                finally:
                    info[0].close()
示例#2
0
def load_package_modules(package_name, package_pathes):
    """
    Load (import) all modules from some package (except those starting with _).

    This is useful if there is some code in the module that runs at import time
    and registers some code of that module somewhere.

    Call this from __init__.py of the same package like this:

        load_package_modules(__name__, __path__)
    """
    for path in package_pathes:
        for root, dirs, files in os.walk(path):
            del dirs[:]
            for fname in files:
                if fname.startswith('_') or not fname.endswith('.py'):
                    continue
                module = fname[:-3]
                module_complete = package_name + '.' + module
                if module_complete in sys.modules:
                    continue
                info = imp.find_module(module, [root])
                try:
                    try:
                        imp.load_module(module_complete, *info)
                    except Exception as e:
                        import MoinMoin.log as logging
                        logger = logging.getLogger(package_name)
                        logger.exception("Failed to import {0} package module {1}: {2}".format(package_name, module, e))
                finally:
                    info[0].close()
示例#3
0
def _load():
    import imp, os, sys
    for path in __path__:
        for root, dirs, files in os.walk(path):
            del dirs[:]
            for file in files:
                if file.startswith('_') or not file.endswith('.py'):
                    continue
                module = file[:-3]
                module_complete = __name__ + '.' + module
                if module_complete in sys.modules:
                    continue
                info = imp.find_module(module, [root])
                try:
                    try:
                        imp.load_module(module_complete, *info)
                    except Exception, e:
                        import MoinMoin.log as logging
                        logger = logging.getLogger(__name__)
                        logger.exception(
                            "Failed to import converter package %s: %s" %
                            (module, e))
                finally:
                    info[0].close()
示例#4
0
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - This plugin is used for multi-tier mail processing

    @copyright: 2006 MoinMoin:AlexanderSchremmer
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin import log
logging = log.getLogger(__name__)

from MoinMoin.mail import mailimport


def execute(xmlrpcobj, secret, mail):
    request = xmlrpcobj.request
    secret = xmlrpcobj._instr(secret)
    mail = str(mail)

    if request.cfg.secrets['xmlrpc/ProcessMail'] != secret:
        return u"Invalid password"

    try:
        mailimport.import_mail_from_string(request, mail)
    except mailimport.ProcessingError, e:
        err = u"An error occured while processing the message: " + str(e.args)
        logging.error(err)
        return xmlrpcobj._outstr(err)
    return xmlrpcobj._outstr(u"OK")
示例#5
0
from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT

from MoinMoin import user
from MoinMoin.search.analyzers import item_name_analyzer, MimeTokenizer, AclTokenizer
from MoinMoin.themes import utctimestamp
from MoinMoin.storage.middleware.validation import ContentMetaSchema, UserMetaSchema, validate_data
from MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError
from MoinMoin.util.interwiki import split_fqname, CompositeName

from MoinMoin.util.mime import Type, type_moin_document
from MoinMoin.util.tree import moin_page
from MoinMoin.converter import default_registry
from MoinMoin.util.iri import Iri

from MoinMoin import log
logging = log.getLogger(__name__)


WHOOSH_FILESTORAGE = 'FileStorage'
INDEXES = [LATEST_REVS, ALL_REVS, ]

VALIDATION_HANDLING_STRICT = 'strict'
VALIDATION_HANDLING_WARN = 'warn'
VALIDATION_HANDLING = VALIDATION_HANDLING_WARN


def get_names(meta):
    """
    Get the (list of) names from meta data and deal with misc. bad things that
    can happen then (while not all code is fixed to do it correctly).
示例#6
0
 def __init__(self):
     GivenAuth.__init__(self, env_var="HTTP_X_FORWARDED_USER")
     self.log = log.getLogger(__name__)
示例#7
0
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - This module contains additional code related to serving
               requests with the standalone server. It uses werkzeug's
               BaseRequestHandler and overrides some functions that
               need to be handled different in MoinMoin than in werkzeug

    @copyright: 2008-2008 MoinMoin:FlorianKrupicka
    @license: GNU GPL, see COPYING for details.
"""
import os
from MoinMoin import config

from MoinMoin import version, log
logging = log.getLogger(__name__)

# make werkzeug use our logging framework and configuration:
import werkzeug._internal
werkzeug._internal._logger = log.getLogger('werkzeug')

from werkzeug.serving import run_simple, BaseRequestHandler

class RequestHandler(BaseRequestHandler):
    """
    A request-handler for WSGI, that overrides the default logging
    mechanisms to log via MoinMoin's logging framework.
    """
    server_version = "MoinMoin %s %s" % (version.release,
                                         version.revision)

    # override the logging functions
示例#8
0
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - This module contains additional code related to serving
               requests with the standalone server. It uses werkzeug's
               BaseRequestHandler and overrides some functions that
               need to be handled different in MoinMoin than in werkzeug

    @copyright: 2008-2008 MoinMoin:FlorianKrupicka
    @license: GNU GPL, see COPYING for details.
"""
import os
from MoinMoin import config

from MoinMoin import version, log
logging = log.getLogger(__name__)

# make werkzeug use our logging framework and configuration:
import werkzeug._internal
werkzeug._internal._logger = log.getLogger('werkzeug')

from werkzeug import run_simple
from werkzeug.serving import BaseRequestHandler

class RequestHandler(BaseRequestHandler):
    """
    A request-handler for WSGI, that overrides the default logging
    mechanisms to log via MoinMoin's logging framework.
    """
    server_version = "MoinMoin %s %s" % (version.release,
                                         version.revision)
示例#9
0
"""

__version__ = '0.0.4.2'

import urllib2
import re
import os

from MoinMoin import log
from MoinMoin.Page import Page
from MoinMoin.PageEditor import PageEditor
from MoinMoin.action import AttachFile
from MoinMoin import wikiutil
from MoinMoin.parser.text_moin_wiki import Parser as WikiParser

logger = log.getLogger(__name__)

class Image2Attach:

    def __init__(self, pagename, request):
        self.pagename = pagename
        self.request = request
        self.page = Page(request, pagename)
        self.image_urls = []
        self.images = {} # image binay files {filename: content}
        self.images_fetched = [] # images successful fetched
        self.process_success = 0 # count of process successful
        self.process_fail = 0 # count of process failed
        self.text = ''
        self.image_extenstions = ['jpg', 'gif', 'png']