rpms/pyflowtools/devel pyflowtools-0.3.1.patch, NONE, 1.1 pyflowtools.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Paul P Komkoff Jr (stingray) fedora-extras-commits at redhat.com
Wed Oct 5 20:34:00 UTC 2005


Author: stingray

Update of /cvs/extras/rpms/pyflowtools/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9204/devel

Modified Files:
	.cvsignore sources 
Added Files:
	pyflowtools-0.3.1.patch pyflowtools.spec 
Log Message:
auto-import pyflowtools-0.3-3 on branch devel from pyflowtools-0.3-3.src.rpm

pyflowtools-0.3.1.patch:

--- NEW FILE pyflowtools-0.3.1.patch ---
diff -urN pyflowtools-0.3/CHANGES pyflowtools-0.3.1/CHANGES
--- pyflowtools-0.3/CHANGES	2002-05-23 05:56:56.000000000 +0400
+++ pyflowtools-0.3.1/CHANGES	2005-09-06 12:26:43.000000000 +0400
@@ -1,3 +1,9 @@
+Version 0.3.1
+    - Bugfix: Py_XINCREF on get iterator function
+    - Bugfix: Py_XDECREF(self->set) on Flow deallocation
+    - Bugfix: begin/end threads in blocking areas
+    - Bugfix: Allow python to preempt thread waiting for flow input
+    - Code cleanup
 
 Version 0.3 
     
diff -urN pyflowtools-0.3/flowtools.c pyflowtools-0.3.1/flowtools.c
--- pyflowtools-0.3/flowtools.c	2002-05-22 01:54:41.000000000 +0400
+++ pyflowtools-0.3.1/flowtools.c	2005-09-06 12:26:52.000000000 +0400
@@ -91,12 +91,7 @@
 static PyObject *FlowSetObjectGetAttr( FlowObject *self, char *name );
 static PyObject *FlowSetObjectIter( FlowSetObject *o );
 static PyObject *FlowSetObjectIterNext( FlowSetObject *o );
-static PyObject *FlowSetObjectNext( FlowSetObject *self, PyObject *args );
-
-static struct PyMethodDef FlowSetMethods[] = {
-    { "next", (PyCFunction)FlowSetObjectNext },
-    { NULL, NULL }
-};
+static int FlowSet_init(FlowSetObject *self, PyObject *args, PyObject* kwds);
 
 PyTypeObject FlowSetType = {
         PyObject_HEAD_INIT(&PyType_Type)
@@ -106,7 +101,7 @@
         0,                                      /* tp_itemsize */
         (destructor)FlowSetObjectDelete,        /* tp_dealloc */
         0,                                      /* tp_print */
-        (getattrfunc)FlowSetObjectGetAttr,      /* tp_getattr */
+        0,      /* tp_getattr */
         0,                                      /* tp_setattr */
         0,                                      /* tp_compare */
         (reprfunc)0,                            /* tp_repr */
@@ -119,8 +114,8 @@
         (getattrofunc)0,                        /* tp_getattro */
         (setattrofunc)0,                        /* tp_setattro */
         0,                                      /* tp_as_buffer */
-        Py_TPFLAGS_HAVE_ITER,                   /* tp_flags */
-        0,                                      /* tp_doc */
+        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,                   /* tp_flags */
+        "Stream of netflow data",                                      /* tp_doc */
         (traverseproc)0,                        /* tp_traverse */
         (inquiry)0,                             /* tp_clear */
         0,                                      /* tp_richcompare */
@@ -135,11 +130,7 @@
         0,                                      /* tp_descr_get */
         0,                                      /* tp_descr_set */
         0,                                      /* tp_dictoffset */
-        0,                                      /* tp_init */
-        0,                                      /* tp_alloc */
-        0,                                      /* tp_new */
-        0,                                      /* tp_free */
-        0,                                      /* tp_is_gc */
+        (initproc) FlowSet_init,                /* tp_init */
 };
 
 static void FlowObjectDelete( FlowObject *self );
@@ -172,8 +163,8 @@
         (getattrofunc)0,                        /*tp_getattro*/
         (setattrofunc)0,                        /* tp_setattro */
         0,                                      /* tp_as_buffer */
-        0,                                      /* tp_flags */
-        0,                                      /* tp_doc */
+        Py_TPFLAGS_DEFAULT,                     /* tp_flags */
+        "Flow objects",                         /* tp_doc */
         (traverseproc)0,                        /* tp_traverse */
         (inquiry)0,                             /* tp_clear */
         0,                                      /* tp_richcompare */
@@ -195,71 +186,64 @@
         0,                                      /* tp_is_gc */
 };
 
-static struct ftio io;
-static struct ftver version;
+static int FlowSet_init(FlowSetObject *self, PyObject *args, PyObject *kwds) {
+    char* file = NULL;
+    struct ftver version = { 0 };
+    int res = 0;
 
-static PyObject* FlowSetObjectNew( PyObject* self, PyObject* args )
-{
-	FlowSetObject *flowset;
-    char *file = NULL;
-    int fd = 0;
+    if (! PyArg_ParseTuple(args, "|s", &file) )
+        return -1; 
 
-	if( ! PyArg_ParseTuple( args, "|s", &file ) )
-        return NULL;
-                
     if( file && strcmp( file , "-" ) != 0 ){
-        fd = open( file, O_RDONLY );
-        if( fd < 0 ){
+        self->fd = open( file, O_RDONLY );
+        if( self->fd < 0 ){
             PyErr_SetFromErrnoWithFilename( PyExc_IOError, file );
-            return NULL;
+            return -1;
         }
     }
 
-    if( ftio_init( &io, fd, FT_IO_FLAG_READ ) < 0 ){
+    Py_BEGIN_ALLOW_THREADS
+    res = ftio_init( &self->io, self->fd, FT_IO_FLAG_READ );
+    Py_END_ALLOW_THREADS
+
+    if( res ) {
         PyErr_SetString( FlowToolsError, "ftio_init() failed" );
-        return NULL;
+        return -1;
     }
-        
-	flowset = PyObject_NEW( FlowSetObject, &FlowSetType );
-	if( ! flowset ) return NULL;
 
-    ftio_get_ver( &io, &version );
-    fts3rec_compute_offsets( &flowset->offsets, &version );
-    
-    flowset->fd = fd;
-    flowset->io = io;
-    flowset->xfield = ftio_xfield( &flowset->io );
-        
-	return (PyObject *)flowset;
+    ftio_get_ver( &self->io, &version );
+    fts3rec_compute_offsets( &self->offsets, &version );
+
+    self->xfield = ftio_xfield( &self->io );
+
+    return 0;
 }
 
 static void FlowSetObjectDelete( FlowSetObject *self )
 {
-    ftio_close( &self->io );
+    Py_BEGIN_ALLOW_THREADS
+    ftio_close( &(self->io) );
     if( self->fd ) close( self->fd );
-    PyObject_Del( self );
-}
-
-static PyObject *FlowSetObjectGetAttr( FlowObject *self, char *name )
-{
-    return Py_FindMethod( FlowSetMethods, (PyObject *)self, name );
+    Py_END_ALLOW_THREADS
+    self->ob_type->tp_free(self);
 }
 
-
 static PyObject *FlowSetObjectIter( FlowSetObject *self )
 {
+        Py_XINCREF(self);
 	return (PyObject *)self;
 }
 
-static PyObject *FlowSetObjectNext( FlowSetObject *self, PyObject *args )
-{
-    return FlowSetObjectIterNext( self );
-}
-
 static PyObject *FlowSetObjectIterNext( FlowSetObject *self )
 {
     FlowObject *flow;
-    char *record = ftio_read( &self->io );
+    char *record;
+    
+    Py_BEGIN_ALLOW_THREADS
+    
+    record = ftio_read( &self->io );
+
+    Py_END_ALLOW_THREADS
     
     if( ! record ){
         PyErr_SetNone( PyExc_StopIteration );
@@ -270,15 +254,15 @@
     if( ! flow ) return NULL;
     flow->record = record;
     flow->set = self;
-    Py_INCREF( self );
+    Py_XINCREF( self );
     
     return (PyObject *)flow;
 }
 
 static void FlowObjectDelete( FlowObject *self )
 {
-    Py_DECREF( self );
-    PyObject_DEL( self );
+    Py_XDECREF( self->set );
+    self->ob_type->tp_free(self);
 }
 
 #define getoffset( f ) ( * ( (u_int16 *)( (void *)( &self->set->offsets ) + f->offset ) ) )
@@ -374,8 +358,7 @@
 }
 
 static struct PyMethodDef FlowToolsMethods[] = {
-    { "FlowSet", FlowSetObjectNew, METH_VARARGS, "Create new FlowSet object" },
-    { NULL, NULL, 0, NULL }
+    { NULL }
 };
 
 
@@ -383,8 +366,18 @@
 {
     PyObject *d, *m;
 
-	m = Py_InitModule( "flowtools", FlowToolsMethods );
+    FlowSetType.tp_new = PyType_GenericNew;
+    FlowType.tp_new = PyType_GenericNew;
+
+    if ((PyType_Ready(&FlowSetType) < 0) || (PyType_Ready(&FlowType) < 0))
+      return;
+
+
+    m = Py_InitModule3( "flowtools", FlowToolsMethods, "test" );
     
+    Py_INCREF(&FlowSetType);
+    PyModule_AddObject(m, "FlowSet", (PyObject *)&FlowSetType);
+
     d = PyModule_GetDict( m );
     FlowToolsError = PyErr_NewException( "flowtools.Error", NULL, NULL );
     PyDict_SetItemString( d, "Error", FlowToolsError );


--- NEW FILE pyflowtools.spec ---
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

Summary: An interface to OSU FlowTools
Name: pyflowtools
Version: 0.3
Release: 3
Source0: http://www.net.informatik.tu-muenchen.de/pers/robin/flowtools/%{name}-%{version}.tar.gz
Patch0: pyflowtools-0.3.1.patch
License: GPL
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
URL: http://www.net.informatik.tu-muenchen.de/pers/robin/flowtools/
Requires: python
BuildRequires: python-devel zlib-devel flow-tools-devel

%description
Python bindings to OSU Flow-Tools library

This is an interface which allows one to read flows stored by
OSU FlowTools into python program for further analysis.

%prep
%setup -q
%patch0 -p1

%build
export libdirname=%{_lib}
CFLAGS="$RPM_OPT_FLAGS" python setup.py build

%install
export libdirname=%{_lib}
python setup.py install --root=$RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc COPYING CHANGES README example.py flowprint-full
%{python_sitelib}/*

%changelog
* Sun Sep 25 2005 Paul P Komkoff Jr <i at stingr.net> - 0.3-3
- fix BuildRoot

* Sun Sep 11 2005 Paul P Komkoff Jr <i at stingr.net> - 0.3-2
- Major bugfix update
- Submission to fedora extras

* Thu Jan  6 2005 Paul P Komkoff Jr <i at stingr.net>
- Updated to updated flow-tools-devel rpm

* Mon Sep  6 2004 Paul P Komkoff Jr <i at stingr.net>
- created RPM
- added fix to allow threads while reading flow


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/pyflowtools/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	5 Oct 2005 20:31:56 -0000	1.1
+++ .cvsignore	5 Oct 2005 20:33:58 -0000	1.2
@@ -0,0 +1 @@
+pyflowtools-0.3.tar.gz


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/pyflowtools/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	5 Oct 2005 20:31:56 -0000	1.1
+++ sources	5 Oct 2005 20:33:58 -0000	1.2
@@ -0,0 +1 @@
+a9268d59812aeb5f34c1d41a6535ef95  pyflowtools-0.3.tar.gz




More information about the fedora-extras-commits mailing list