add support for writing python strings directly
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Apr 2008 22:40:38 +0000 (22:40 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Apr 2008 22:40:38 +0000 (22:40 +0000)
lib/base/console.cpp
lib/base/console.h

index cc994ea9e321eaedb850b01b76d0ba6518b8cbf4..a29772d8fac00a54d3453a67b2239f8fb9f5eea0 100644 (file)
@@ -333,7 +333,18 @@ void eConsoleAppContainer::write( const char *data, int len )
        char *tmp = new char[len];
        memcpy(tmp, data, len);
        outbuf.push(queue_data(tmp,len));
-       out->start();
+       if (out)
+               out->start();
+}
+
+void eConsoleAppContainer::write( PyObject *data )
+{
+       char *buffer;
+       int length;
+       if (PyString_AsStringAndSize(data, &buffer, &length))
+               return;
+       if (buffer && length)
+               write(buffer, length);
 }
 
 void eConsoleAppContainer::readyWrite(int what)
index cf8e539796685ec31a9621b4659bc29f9178ff51..07ad6a90f5f5a99de81c16535f6d3827cdd4f541 100644 (file)
@@ -42,6 +42,7 @@ public:
        void kill();
        void sendCtrlC();
        void write( const char *data, int len );
+       void write( PyObject *data );
        bool running() { return (fd[0]!=-1) && (fd[1]!=-1) && (fd[2]!=-1); }
        PSignal1<void, const char*> dataAvail;
        PSignal1<void,int> dataSent;