GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( fbdd84...45bad2 )
by P.R.
04:28
created

LogFileMessageEventHandler   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 66
ccs 0
cts 33
cp 0
rs 10
wmc 11

1 Method

Rating   Name   Duplication   Size   Complexity  
D handle() 0 62 11
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import os
9
10
from enarksh.DataLayer import DataLayer
11
12
13
class LogFileMessageEventHandler:
14
    """
15
    An event handler for a LogFileMessage received events.
16
    """
17
    @staticmethod
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def handle(_event, message, _listener_data):
20
        """
21
        Handles a LogFileMessage received event.
22
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
23
        :param * _event: Not used.
24
        :param enarksh.message.logger.LogFileMessage.LogFileMessage message: The message.
25
        :param * _listener_data: Not used.
26
        """
27
        del _event, _listener_data
28
29
        print("%s %s %s" % (message.rnd_id, message.name, message.total_size))
30
31
        DataLayer.connect()
32
33
        if message.total_size > 0:
34
            # Read the log file or log files and concatenate if necessary.
35
            with open(message.filename1, 'rb') as f:
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ([a-z_][a-z0-9_]{1,60}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
36
                log = f.read()
37
38
            if message.filename2:
39
                with open(message.filename2, 'rb') as f:
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ([a-z_][a-z0-9_]{1,60}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
40
                    buf2 = f.read()
41
            else:
42
                buf2 = ''
43
44
            # Compute the number of skipped bytes.
45
            skipped = message.total_size - len(log) - len(buf2)
46
47
            if skipped != 0:
48
                # Add a newline to the end of the buffer, if required.
49
                if log[-1:] != '\n':
50
                    log += '\n'
51
52
                    # Note: This concatenation doesn't work for multi byte character sets.
53
                    log += '\n'
54
                    log += "Enarksh: Skipped {0} bytes.\n".format(skipped)
55
                    log += '\n'
56
57
                log += buf2
58
59
            blb_id = DataLayer.enk_blob_insert_blob(message.name, 'text/plain', log)
60
61
        else:
62
            blb_id = None
63
64
        if message.name == 'out':
65
            DataLayer.enk_back_run_node_update_log(message.rnd_id, blb_id, message.total_size)
66
        elif message.name == 'err':
67
            DataLayer.enk_back_run_node_update_err(message.rnd_id, blb_id, message.total_size)
68
        else:
69
            raise ValueError("Unknown output name '%s'" % message.name)
70
71
        # Remove the (temporary) log files.
72
        if message.filename1:
73
            os.unlink(message.filename1)
74
        if message.filename2:
75
            os.unlink(message.filename2)
76
77
        DataLayer.commit()
78
        DataLayer.disconnect()
79
80
# ----------------------------------------------------------------------------------------------------------------------
81