Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Admiral
Admiral
1647 views

CEF python class

I work pretty frequently with CEF events that I generate and manipulate with python scripts.

This usually gives pretty ugly and difficult to modify code when CEF parameters need to be manipulated. This is why I wrote my own set of functions (python 2.7)  to make this work easier and thought it could be useful for some other people.

There is some documentation and examples included in the attached documents. It looks good to me but hasn't been tested extensively. Should you find a bug, please be kind enough to let me know. Thx

Gaetan

Tags (2)
12 Replies
Cadet 1st Class Cadet 1st Class
Cadet 1st Class

Awesome stuff, thanks!

0 Likes

Thank you!

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Damn good job! Congrats!

0 Likes
Absent Member.
Absent Member.

Merci!

0 Likes
Absent Member.
Absent Member.

many thanks ... love your effort to share ..

0 Likes
Lieutenant
Lieutenant

This is wonderful, many thanks for your contribution! Very handy indeed. I can absolutely understand why you wrote this Python code.

Great work!

0 Likes
Vice Admiral
Vice Admiral

Great job Gaetan! Very usefull library

I can't see the stingest function in the code, maybe is for a new version?

Thanks!

0 Likes
Admiral
Admiral

Jorge,

Very very old indeed, it has been drastically changed since then to make it easier to use. I replaced the script with the latest one. Thank you for noticing 😉

0 Likes
Vice Admiral
Vice Admiral

Thanks Gaetan,

I've tried the stringest method and it doesn't work well with some events I have.

I had to handle CEF event in Python some weeks ago and I'm using a regular expression to split the fields. It works with field values containing "|" and additional field names with characters like "_" of ",".

This is the regex I use, maybe it is helpful to improve your script:

header_fields = strcef.split('| ')[0].split('|')

fields_regex = r"(?:_+)?(?P<_KEY_1>[\w.,_\-:\[\]]+)=(?P<_VAL_1>.*?(?=(?:\s[\w.,_\-:\[\]]+=|$)))"

fields_str = ''.join(strcef.split('| ')[1:])

fields_list = re.findall(fields_regex, fields_str)

0 Likes
Admiral
Admiral

Jorge,

Indeed the code was not dealing correctly with events containing a | character in the extension and has been updated.

Special characters in the field names shouldn't be an issue.

If you are still experiencing issues, feel free to send me cef events you have problem with via PM

Gaetan

0 Likes
Vice Admiral
Vice Admiral

Gaetan,

It works perfect now.

Thanks!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.