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

F/python #387

Merged
merged 30 commits into from
Feb 23, 2015
Merged

F/python #387

merged 30 commits into from
Feb 23, 2015

Conversation

bazsi
Copy link
Collaborator

@bazsi bazsi commented Feb 17, 2015

Please consider my Python related work for merging. It ports the Python module in the incubator to the syslog-ng proper.

It's not yet complete, but I intended to submit the functional parts to make it more accessible for everyone else.

I still have upcoming work that I've left out of this branch (e.g. template function support and "root" level Python language support), however those still have critical issues.

This one has much less test coverage than I would prefer (e.g. exactly None), at least an end-to-end test would be great to have. It's really difficult to do unit-like testing as most of it is just glue code.

Anyway, I indend to add some testing to the func-test suite in the nearfuture.

Please merge!
Thanks.

bazsi and others added 29 commits February 19, 2015 10:54
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
I have some pending patches that add additional features to the Python
module that are not yet ready for prime time, but which add entries to the
python_plugins as an array.  (template functions and root-level Python code
blocks support)

Do the conversion here, users will come later.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
…dy does that

This is already factored into LogThreadedDestDriver, so no need to
do that ou rselves.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
As it is explicitly handled by all call sites (the way it should be) and
which is being refactored into a single spot in upcoming patches.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
…tion names around

Instead of having to pass function names around, use a new function
that extracts this information from a callable.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
In order to simplify program flow and to break the code to smaller chunks,
use a separate function to initialize Python code.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
This change makes it possible to rework all Python function invocation
into simpler forms, that is made possible by previous refactorings
(most notable the py_get_callable_name() function).

This makes the Python related functions a bit more plug & play, even
though only very limited functions can be called (e.g. one with only
a single argument and either a bool or None return value). Exceptions are
also handled properly.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Make a new function available that imports a Python module, which can then
be used for more than implementing the imports() option of the Python
destination.

This is the basis of the _py_init_bindings() refactor upcoming in the next patch.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
…n value

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Instead of using a function based interface without proper instantiation,
use a class with a definite interface in the Python part.  The method names
are intended to match that of the Java destination of a similar role.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Instead of always converting the LogMessage to a dict, make it possible
to use the underlying C structure with a thin Python wrapper directly.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
It may happen that the Python C API returns NULL without an exception being
set. Fix potential segfault by checking if the exception is NULL.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
It was difficult to diagnose the "Error loading Python module" error
message, as syntax errors were not reported.

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
@bazsi
Copy link
Collaborator Author

bazsi commented Feb 19, 2015

I have rebased this against the latest master and also added an automated testcase to functest, and a few fixes that I've found while adding the testcase :)

It should be a better form for merging.

@lbudai
Copy link
Collaborator

lbudai commented Feb 19, 2015

Thanks! I'll try to review the patch in this week( +end :-) ).

Signed-off-by: Balazs Scheidler <balazs.scheidler@balabit.com>
@lbudai
Copy link
Collaborator

lbudai commented Feb 21, 2015

Nice work :-)

I had a list of questions/notes, but size of my list reduces as refactors are coming
and after 5dc8ca8 notes are gone...
(maybe buf1, buf2 not the best names for variables, but... well... it is OK)

One question:
Is there any other way for importing a python class than setting PYTHONPATH before running syslog-ng?

@bazsi
Copy link
Collaborator Author

bazsi commented Feb 21, 2015

I have some followup work and a few fixes in f/python-template-functions

That should conclude the python module for a short term until I submit my debugger cli in python work I worked on today.

You can avoid having to set PYTHONPATH by installing the extension module using a setup.py or something. Maybe we should also add /etc/syslog-ng or a subdirectory automatically. How do you do that with the Java plugin?

@lbudai
Copy link
Collaborator

lbudai commented Feb 23, 2015

In Java dest. we have an option for setting the classpath.

lbudai added a commit that referenced this pull request Feb 23, 2015
@lbudai lbudai merged commit 4b2d218 into master Feb 23, 2015
@bazsi bazsi deleted the f/python branch November 17, 2015 07:16
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

Successfully merging this pull request may close these issues.

3 participants