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

my8100 / logparser / 77683b55-afde-4ba3-9f85-0ccac986d1c1

05 Jan 2025 10:06AM UTC coverage: 87.757% (+0.4%) from 87.405%
77683b55-afde-4ba3-9f85-0ccac986d1c1

push

circleci

web-flow
Release v0.8.4 and support allure report (#31)

* Support allure report

* Fix JAVA_HOME and allure-pytest

* Drop py27 tests due to allure-pytest

10 of 10 new or added lines in 2 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

810 of 923 relevant lines covered (87.76%)

5.22 hits per line

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

87.23
/logparser/utils.py
1
# coding: utf-8
2
import json
6✔
3
import logging
6✔
4
import platform
6✔
5
import sys
6✔
6

7
try:
6✔
8
    from scrapy import __version__ as scrapy_version
6✔
9
except ImportError:
6✔
10
    scrapy_version = '0.0.0'
6✔
11
from six.moves.urllib.parse import urlencode
6✔
12
from six.moves.urllib.request import Request, urlopen
6✔
13

14
from .__version__ import __version__
6✔
15
from .settings import (SCRAPYD_SERVER, SCRAPYD_LOGS_DIR, PARSE_ROUND_INTERVAL,
6✔
16
                       ENABLE_TELNET, OVERRIDE_TELNET_CONSOLE_HOST, LOG_ENCODING, LOG_EXTENSIONS,
17
                       LOG_HEAD_LINES, LOG_TAIL_LINES, LOG_CATEGORIES_LIMIT, JOBS_TO_KEEP, CHUNK_SIZE,
18
                       DELETE_EXISTING_JSON_FILES_AT_STARTUP, KEEP_DATA_IN_MEMORY, VERBOSE)
19

20

21
custom_settings = dict(
6✔
22
    scrapyd_server=SCRAPYD_SERVER,
23
    scrapyd_logs_dir=SCRAPYD_LOGS_DIR,
24
    parse_round_interval=PARSE_ROUND_INTERVAL,
25
    enable_telnet=ENABLE_TELNET,
26
    override_telnet_console_host=OVERRIDE_TELNET_CONSOLE_HOST,
27
    log_encoding=LOG_ENCODING,
28
    log_extensions=LOG_EXTENSIONS,
29
    log_head_lines=LOG_HEAD_LINES,
30
    log_tail_lines=LOG_TAIL_LINES,
31
    log_categories_limit=LOG_CATEGORIES_LIMIT,
32
    jobs_to_keep=JOBS_TO_KEEP,
33
    chunk_size=CHUNK_SIZE,
34
    delete_existing_json_files_at_startup=DELETE_EXISTING_JSON_FILES_AT_STARTUP,
35
    keep_data_in_memory=KEEP_DATA_IN_MEMORY,
36
    verbose=VERBOSE,
37
    # main_pid=0,
38
    # debug=False,
39
    # exit_timeout=0
40
)
41

42

43
def get_logger(name, level=logging.DEBUG):
6✔
44
    logger = logging.getLogger(name)
6✔
45
    handler = logging.StreamHandler()
6✔
46
    formatter = logging.Formatter(fmt="[%(asctime)s] %(levelname)-8s in %(name)s: %(message)s")
6✔
47
    handler.setFormatter(formatter)
6✔
48
    logger.addHandler(handler)
6✔
49
    logger.setLevel(level)
6✔
50
    return logger
6✔
51

52

53
def check_update(timeout=5, **kwargs):
6✔
54
    logger = get_logger(__name__)
6✔
55
    js = {}
6✔
56
    try:
6✔
57
        data = dict(custom_settings)
6✔
58
        data['os'] = platform.platform()
6✔
59
        data['py'] = '.'.join([str(n) for n in sys.version_info[:3]])
6✔
60
        data['logparser'] = __version__
6✔
61
        data['scrapy_version'] = scrapy_version
6✔
62
        data.update(kwargs)
6✔
63
        # print(data)
64
        url = 'https://my8100.pythonanywhere.com/check_update'
6✔
65
        json_data = json.dumps(data).encode('utf-8')
6✔
66
        req = Request(url, data=json_data)
6✔
67
        req.add_header('Content-Type', 'application/json')
6✔
68
        with urlopen(req, timeout=timeout) as resp:
6✔
69
            text = resp.read().decode('utf-8', 'replace')
6✔
70
        # print(text)
71
        js = json.loads(text)
6✔
72
        # print(js)
73
    # except Exception as err:
74
        # print(err)
UNCOV
75
    except:
×
UNCOV
76
        pass
×
77
    else:
78
        if js.get('latest_version') == __version__:
6✔
79
            logger.info("Running the latest version: %s", __version__)
6✔
80
        else:
81
            if js.get('info', ''):
×
82
                logger.warning(js['info'])
×
83
            if js.get('force_update', ''):
×
84
                sys.exit("Please update and then restart logparser. ")
×
85
    return js  # For test only
6✔
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

© 2025 Coveralls, Inc