[hydra-commits] ken.hunt: branch techdemo/ken.hunt/embeddedPythonTest r616 - in /techdemo/tea...

SVN commits to the Hydra project hydra-commits at lists.digium.com
Wed May 12 19:14:52 CDT 2010


Author: ken.hunt
Date: Wed May 12 19:14:51 2010
New Revision: 616

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=616
Log:
Simple python test.

Added:
    techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt   (with props)
    techdemo/team/ken.hunt/embeddedPythonTest/bin/
    techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat   (with props)
    techdemo/team/ken.hunt/embeddedPythonTest/build/
    techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat   (with props)
    techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt   (with props)
    techdemo/team/ken.hunt/embeddedPythonTest/source/
    techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt   (with props)
    techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp   (with props)

Added: techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt Wed May 12 19:14:51 2010
@@ -1,0 +1,8 @@
+cmake_minimum_required(VERSION 2.6)
+
+include(cmake/Hydra_v3.cmake)
+
+hydra_project(embedPythonTest 3.4 CXX CSharp)
+
+add_subdirectory(slice)
+add_subdirectory(source)

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/CMakeLists.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat Wed May 12 19:14:51 2010
@@ -1,0 +1,11 @@
+
+echo off
+copy /Y /B ..\build\source\Release\Routing.exe .
+
+copy /Y /B ..\build\slice\Release\RoutingServiceIf_CXX.dll
+copy /Y /B ..\build\slice\Channel\Release\ChannelServiceIf_CXX.dll
+copy /Y /B ..\build\slice\Channel\Release\EndpointIf_CXX.dll
+copy /Y /B ..\build\slice\Channel\Release\SignalIf_CXX.dll
+copy /Y /B ..\build\slice\Media\Release\MediaSinkIf_CXX.dll
+copy /Y /B ..\build\slice\Media\Release\MediaTranslationIf_CXX.dll
+

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/bin/install_release.bat
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat Wed May 12 19:14:51 2010
@@ -1,0 +1,6 @@
+ at ECHO OFF
+REM  -Wdev: Enable developer warnings.
+REM --build <sourcedir> : for out-of-source building 
+
+cmake -Wdev --build ..
+

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/build/runcmake.bat
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt Wed May 12 19:14:51 2010
@@ -1,0 +1,7 @@
+hydra_slice_include_directories(.)
+
+add_subdirectory(Media)
+add_subdirectory(Channel)
+
+
+hydra_compile_slice(RoutingServiceIf.ice)

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/slice/CMakeLists.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt Wed May 12 19:14:51 2010
@@ -1,0 +1,17 @@
+
+hydra_component_init(Routing CXX)
+INCLUDE(findPythonInterp)
+INCLUDE(findPythonLibs)
+get_filename_component(PY_LOC ${PYTHON_LIBRARIES} PATH)
+LINK_DIRECTORIES(${PY_LOC})
+include_directories(${PYTHON_INCLUDE_DIRS})
+hydra_component_add_slice(Routing MediaSinkIf)
+hydra_component_add_slice(Routing EndpointIf)
+hydra_component_add_slice(Routing SignalIf)
+hydra_component_add_slice(Routing ChannelServiceIf)
+hydra_component_add_slice(Routing RoutingServiceIf)
+hydra_component_add_file(Routing  Server.cpp)
+hydra_component_add_ice_libraries(Routing IceStorm)
+hydra_component_add_boost_libraries(Routing core)
+hydra_component_build_standalone(Routing)
+hydra_component_install(Routing)

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/CMakeLists.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp?view=auto&rev=616
==============================================================================
--- techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp (added)
+++ techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp Wed May 12 19:14:51 2010
@@ -1,0 +1,126 @@
+#include <Ice/Ice.h>
+#include <boost/cast.hpp>
+#include <boost/shared_ptr.hpp>
+#include <typeinfo>
+#include <Python.h>
+#include <stdio.h>
+
+#include "RoutingServiceIf.h"
+
+using namespace std;
+using namespace Hydra;
+
+
+class LookupServiceImpl : public Hydra::Routing::LookupService 
+{
+public:
+   virtual ::Hydra::Channel::EndpointPrx lookup(const ::std::string& destination, const ::Ice::Current& __context);
+};
+
+
+::Hydra::Channel::EndpointPrx LookupServiceImpl::lookup(const ::std::string& destination, const ::Ice::Current& __context)
+{
+	cout << "Looking up: " <<  destination << std::endl;
+
+   PyObject *pName, *pModule;
+
+   // TEMP...Changed to a simple python script. Make
+   // sure my pythonScripts folder is in  PYTHONPATH
+   pName = PyString_FromString("lookup");
+   pModule = PyImport_Import(pName);
+   Py_DECREF(pName);
+
+   if (pModule != 0)
+   {
+      PyObject *pFunc = PyObject_GetAttrString(pModule, "lookup");
+      if (pFunc != 0 && PyCallable_Check(pFunc))
+      {
+         PyObject *pArgs = PyTuple_New(1);
+         PyObject *pValue = PyInt_FromLong(atoi(destination.c_str()));
+         if (!pValue)
+         {
+            Py_DECREF(pArgs);
+            Py_DECREF(pFunc);
+            Py_DECREF(pModule);
+            return 0;
+         }
+         PyTuple_SetItem(pArgs, 0, pValue); // pValue ref given up here.
+
+         pValue = PyObject_CallObject(pFunc, pArgs);
+         Py_DECREF(pArgs);
+
+         if (pValue != 0)
+         {
+            cout << "Found: " <<  PyInt_AsLong(pValue) << std::endl;
+            Py_DECREF(pValue);
+         }
+         else
+         {
+            PyErr_Print();
+         }
+       
+         Py_DECREF(pFunc);
+         Py_DECREF(pModule);
+      }
+      else if (PyErr_Occurred())
+      {
+         PyErr_Print();
+      }
+   }
+   else
+   {
+      PyErr_Print();
+   }
+   Py_Finalize();
+   return 0;
+}
+
+
+int main(int argc, char* argv[])
+{
+    int status = 0;
+    Ice::CommunicatorPtr ic;
+
+    Py_Initialize();
+
+    try 
+    {
+        ic = Ice::initialize(argc, argv);
+        Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("LookupService", 
+          "default -p 10007");
+
+        Hydra::Routing::LookupServicePtr service = new LookupServiceImpl();
+        Ice::ObjectPrx objectPrx = adapter->add(service, ic->stringToIdentity("LookupService"));
+        Hydra::Routing::LookupServicePrx lookupPrx = Hydra::Routing::LookupServicePrx::uncheckedCast(objectPrx);
+
+        adapter->activate();
+
+        // Hardcode an invocation.
+        service->lookup("27");
+
+        ic->waitForShutdown();
+    } 
+    catch (const Ice::Exception& e) 
+    {
+        cerr << e << endl;
+        status = 1;
+    } 
+    catch (const char* msg) 
+    {
+        cerr << msg << endl;
+        status = 1;
+    }
+    if (ic) 
+    {
+        try 
+        {
+            ic->destroy();
+        } 
+        catch (const Ice::Exception& e) 
+        {
+            cerr << e << endl;
+            status = 1;
+        }
+    }
+    return status;
+}

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: techdemo/team/ken.hunt/embeddedPythonTest/source/Server.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the asterisk-scf-commits mailing list