Python Non-ASCII character '\x8b' in file - on line 1

1.6k Views Asked by At

I'm setting up one monitoring system that uses scripts made in python. ( just for info its OMD linux distribution with check_mk).

Anyway, this is the script that I want to use

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# WARN num, CRIT num
eximq_default_levels = (100, 200) 

def inventory_eximq(info):
if len(info) > 0 and info[0] != '':
    return [(None, 'eximq_default_levels')]

def check_eximq(item, params, info):
for line in info:
    if line[0] == '0':
        return (0, 'OK - The mailqueue is empty ', [ ('length', 0, params[0], params[1]),
                                                     ('size', '0') ])
    else:
        len     = int(line[0])

        perfdata = [ ('length', len, params[0], params[1])]

        if len > params[1]:
            return (2, 'CRIT - Mailqueue length is %d '
                       '(More than threshold: %d)' % (len, params[0]), perfdata)
        elif len > params[0]:
            return (1, 'WARN - Mailqueue length is %d '
                       '(More than threshold: %d)' % (len, params[0]), perfdata)
        else:
            return (0, 'OK - Mailqueue length is %d ' % len, perfdata)

return (3, 'UNKNOWN - Could not find summarizing line in output')

check_info['eximq'] = (check_eximq, "Exim Queue", 1, inventory_eximq)
checkgroup_of["eximq"] = "mailqueue_length"

When I compile/create package from this script I get the following error

Error in plugin file /omd/sites/infonet/local/share/check_mk/checks/eximq-1.0.mkp: Non->ASCII character '\x8b' in file /omd/sites/infonet/local/share/check_mk/checks/eximq-1.0.mkp >on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for >details (eximq-1.0.mkp, line 1)

I tried changing encoding to coding, removing it completely, adding it before #!/usr/bin/python but nothing helps. I also checked file through vi with option to show all characters and I didn't find any strange character at those locations.

Operating system is Centos and python is 2.6

Is there anything else I could try to sort this problem out ?

p.s. If its any relevant this is the guide to create the package from the script https://mathias-kettner.de/checkmk_packaging.html

0

There are 0 best solutions below