• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inspirehep / inspire-next / 12409

pending completion
12409

Pull #3436

travis-ci

web-flow
utils: make is_pdf_link accept long lines

The previous (i.e. third) iteration of `is_pdf_link` didn't work when
all the content was on a single line, as it was then reading too much
resulting in the connection being killed.
This is avoided by reading a fixed number of bytes, instead of a fixed
number of lines.

Signed-off-by: Micha Moskovic <michamos@gmail.com>
Pull Request #3436: utils: make is_pdf_link accept long lines

2 of 2 new or added lines in 1 file covered. (100.0%)

7216 of 9239 relevant lines covered (78.1%)

2.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/inspirehep/utils/robotupload.py
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of INSPIRE.
4
# Copyright (C) 2014-2017 CERN.
5
#
6
# INSPIRE is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# INSPIRE is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with INSPIRE. If not, see <http://www.gnu.org/licenses/>.
18
#
19
# In applying this license, CERN does not waive the privileges and immunities
20
# granted to it by virtue of its status as an Intergovernmental Organization
21
# or submit itself to any jurisdiction.
22

23
"""Utils for sending robotuploads to other Invenio instances."""
5✔
24

25
from __future__ import absolute_import, division, print_function
5✔
26

27
import os
5✔
28

29
import requests
5✔
30
from six import text_type
5✔
31
from flask import current_app
5✔
32

33
from .url import make_user_agent_string
5✔
34

35

36
def make_robotupload_marcxml(url, marcxml, mode, **kwargs):
5✔
37
    """Make a robotupload request."""
38
    headers = {
2✔
39
        "User-agent": make_user_agent_string("inspire"),
40
        "Content-Type": "application/marcxml+xml",
41
    }
42
    if url is None:
2✔
43
        base_url = current_app.config.get("LEGACY_ROBOTUPLOAD_URL")
2✔
44
    else:
45
        base_url = url
1✔
46

47
    if isinstance(marcxml, text_type):
2✔
48
        marcxml = marcxml.encode('utf8')
1✔
49

50
    if base_url:
2✔
51
        url = os.path.join(base_url, "batchuploader/robotupload", mode)
2✔
52
        return requests.post(
2✔
53
            url=url,
54
            data=marcxml,
55
            headers=headers,
56
            params=kwargs,
57
        )
58
    else:
59
        raise ValueError(
1✔
60
            "Base URL missing for robotupload. "
61
            "Please check `LEGACY_ROBOTUPLOAD_URL` config."
62
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2024 Coveralls, Inc