README moves to markdown
[nepi.git] / src / nepi / resources / omf / omf_client.py
index ea53f60..8497f3b 100644 (file)
@@ -3,9 +3,8 @@
 #    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.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 from nepi.util.logger import Logger
 from nepi.resources.omf.omf6_parser import OMF6Parser
-
 try:
     import sleekxmpp
     from sleekxmpp.exceptions import IqError, IqTimeout
     class BaseOMFClient(sleekxmpp.ClientXMPP):
         pass
 except ImportError:
-    print "SleekXMPP is not installed. Without this library, \n" + \
-          " You will be not able to use OMF Resources \n"+ \
-          " 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"
+    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
 
@@ -40,7 +42,7 @@ import traceback
 import xml.etree.ElementTree as ET
 
 # inherit from BaseXmpp and XMLstream classes
-class OMFClient(sleekxmpp.ClientXMPP, Logger): 
+class OMFClient(BaseOMFClient, Logger): 
     """
     .. class:: Class Args :
       
@@ -73,8 +75,6 @@ class OMFClient(sleekxmpp.ClientXMPP, Logger):
         self._server = None
         self._parser = None
 
-
-
         self.register_plugin('xep_0077') # In-band registration
         self.register_plugin('xep_0030')
         self.register_plugin('xep_0059')
@@ -222,8 +222,9 @@ class OMFClient(sleekxmpp.ClientXMPP, Logger):
             msg = ' Deleted node: %s' % node
             self.info(msg)
         except:
-            error = traceback.format_exc()
-            msg = ' Could not delete topic: %s\ntraceback:\n%s' % (node, error)
+            #error = traceback.format_exc()
+            #msg = ' Could not delete topic: %s\ntraceback:\n%s' % (node, error)
+            msg = 'Could not delete the topic : '+node+' . Maybe It is not the owner of the topic'
             self.error(msg)
     
     def publish(self, data, node):
@@ -334,6 +335,17 @@ class OMFClient(sleekxmpp.ClientXMPP, Logger):
                     % (self.boundjid.bare, node, error)
             self.error(msg)
 
+    def check_mailbox(self, itype, attr):
+        """ Check the mail box
+
+        :param itype: type of mail
+        :type itype: str
+        :param attr: value wanted
+        :type attr: str
+
+        """
+        return self._parser.check_mailbox(itype, attr)
+
 
     def handle_omf_message(self, iq):
         """ Handle published/received message