Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitised log #28

Open
jayvdb opened this issue Sep 26, 2015 · 4 comments
Open

Sanitised log #28

jayvdb opened this issue Sep 26, 2015 · 4 comments

Comments

@jayvdb
Copy link
Collaborator

jayvdb commented Sep 26, 2015

The ruby client has an option to sanitise the log, either by removing unprintable, or removing the colors also.

https://github.com/travis-ci/travis.rb/blob/master/lib/travis/tools/safe_string.rb

This can be easily added to Log, something like

def remove_unprintable(s):
    return regex.sub('[^[:print:]\x1b\n]', '', s)


def remove_ansi_color(s):
    return regex.sub('\x1b[^mK]*[mK]', '', s)



class Log

...

    def colorized(self):
        return remove_unprintable(self.body)

    def clean(self):
        return remove_ansi_color(self.colorized())

Would you be happy to include something like that?

In addition, I have a log parser that breaks the log into a sequence of named blocks, consisting of either lines containing meta job information or the commands from the yml with block names corresponding to the .yml blocks. Block with commands have command + output + exit code for each command in block, where applicable.

I need to clean it up a little more, to get rid of some remaining spaghetti, but it now correctly handles some 600 logs including most of the usual job scenarios, and a few different types of .travis.yml , mostly for Python projects. There will no doubt the scenarios that it doesnt handle properly, especially for very old travis logs when the infrastructure was different, but it provides a solid foundation for additional corner cases to be handled.

Would you be interested in log parsing being included in travispy, or would that be out of scope? I dont mind either way; just looking for direction.

@menegazzo menegazzo modified the milestone: 0.3.4 Sep 30, 2015
@jayvdb
Copy link
Collaborator Author

jayvdb commented Oct 26, 2015

My log parser ended up growing considerably, with lots of additional dependencies, and still many unhandled situations, so it is probably unsuitable for being included in this project. Im in the final stages of cleaning it up for release as a separate project.

So, ignoring that aspect, should I submit a PR for the basic Log sanitisation routines outlined above?

@menegazzo menegazzo removed this from the 0.3.4 milestone Mar 14, 2016
@menegazzo
Copy link
Owner

@jayvdb sorry about taking that long to get back to you.

Yes, please! Open the PR and let's put this into TravisPy.

@menegazzo
Copy link
Owner

Hi. Unfortunately I don't have the time to keep the support on this library. If you have the interest in taking the ownership of this, let me know.

@jayvdb
Copy link
Collaborator Author

jayvdb commented Feb 8, 2019

@menegazzo , yes I would love to. Sent you an email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants