Merging the openflow part to the nepi-3-dev branch
[nepi.git] / src / nepi / resources / omf / omf_client.py
index 829603a..05af4f1 100644 (file)
@@ -1,38 +1,56 @@
-"""
-    NEPI, a framework to manage network experiments
-    Copyright (C) 2013 INRIA
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-"""
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2013 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+#         Julien Tribino <julien.tribino@inria.fr>
 
 from nepi.util.logger import Logger
 
-import sleekxmpp
-from sleekxmpp.exceptions import IqError, IqTimeout
+try:
+    import sleekxmpp
+    from sleekxmpp.exceptions import IqError, IqTimeout
+    class BaseOMFClient(sleekxmpp.ClientXMPP):
+        pass
+except ImportError:
+    msg = ("SleekXMPP is not installed. Without this library "
+          "you will be not able to use OMF Resources "
+          "if you want to install SleekXmpp: \n"
+          " git clone -b develop git://github.com/fritzy/SleekXMPP.git \n"
+          " cd SleekXMPP \n"
+          " sudo python setup.py install\n")
+
+    logger = Logger("BaseOMFClient")
+    logger.debug(msg)
+
+    class BaseOMFClient(object):
+        pass
+
 import traceback
 import xml.etree.ElementTree as ET
 
-# inherit from BaseXmpp and XMLStream classes
-class OMFClient(sleekxmpp.ClientXMPP, Logger): 
+# inherit from BaseXmpp and XMLstream classes
+class OMFClient(BaseOMFClient, Logger): 
     """
     .. class:: Class Args :
       
         :param jid: Jabber Id (= Xmpp Slice + Date)
-        :type jid: Str
+        :type jid: str
         :param password: Jabber Password (= Xmpp Password)
-        :type password: Str
+        :type password: str
 
     .. note::
 
@@ -44,9 +62,9 @@ class OMFClient(sleekxmpp.ClientXMPP, Logger):
         """
 
         :param jid: Jabber Id (= Xmpp Slice + Date)
-        :type jid: Str
+        :type jid: str
         :param password: Jabber Password (= Xmpp Password)
-        :type password: Str
+        :type password: str
 
 
         """