try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

PERMITTED_MODES = ['-i', '-r', '-c', '-a', '-ir',
                   '--insert', '--replace', '--correct', '--append']

_CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS_RE = re.compile(CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS)

_CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS = []
for _network, _collection in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.items():
    if '/' not in _network:
        _network += '/32'
    _CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.append((_ip_matcher_builder(_network), _collection))
    del _network
    del _collection



def cli_allocate_record(req):
    req.content_type = "text/plain"
    req.send_http_header()

    # check IP and useragent:
    if not _get_client_authorized_collections(_get_client_ip(req)):
        msg = "[ERROR] Sorry, client IP %s cannot use the service." % _get_client_ip(req)
        _log(msg)
        return _write(req, msg)
    if not _check_client_useragent(req):
Exemple #2
0
    # Example: RepNo_CMS-pas123.pdf
    ('report-number', re.compile(r'(?i)^RepNo[_-](.*)\.pdfa?$'),
     ('reportnumber', )),
    # Example: anything.pdf
    ('garbage', re.compile(r'(?i)^(.+)\.pdfa?$'), ('rec_garbage', ))
]

_CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS_RE = re.compile(
    CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS)

_CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS = []
for _network, _collection in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.items():
    if '/' not in _network:
        _network += '/32'
    _CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.append(
        (_ip_matcher_builder(_network), _collection))
    del _network
    del _collection


def cli_allocate_record(req):
    req.content_type = "text/plain"
    req.send_http_header()

    # check Authorization header
    allowed_by_token = _check_authorization_bearer(req)

    # check IP and useragent:
    if not allowed_by_token and not _get_client_authorized_collections(
            _get_client_ip(req)):
        msg = "[ERROR] Sorry, client IP %s cannot use the service." % _get_client_ip(
Exemple #3
0
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

PERMITTED_MODES = ['-i', '-r', '-c', '-a', '-ir',
                   '--insert', '--replace', '--correct', '--append']

_CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS_RE = re.compile(CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS)

_CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS = []
for _network, _collection in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.items():
    if '/' not in _network:
        _network += '/32'
    _CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.append((_ip_matcher_builder(_network), _collection))
    del _network
    del _collection



def cli_allocate_record(req):
    req.content_type = "text/plain"
    req.send_http_header()

    # check IP and useragent:
    if not _get_client_authorized_collections(_get_client_ip(req)):
        msg = "[ERROR] Sorry, client IP %s cannot use the service." % _get_client_ip(req)
        _log(msg)
        return _write(req, msg)
    if not _check_client_useragent(req):