remove debug trace in generated code
[contrib/cloudeebus.git] / cloudeebus / cloudeebus.py
index 59d6d45..69e499f 100755 (executable)
@@ -48,8 +48,6 @@ from twisted.python import log
 # XML parser module
 from xml.etree.ElementTree import XMLParser
 
-# For debug only
-import os
 
 ###############################################################################
 
@@ -167,26 +165,12 @@ class exec_code:
         self.globalCtx = globalCtx
         
 
-    # __str__ : Return a string representation of the object, for
-    # nice printing.
-    def __str__(self) :
-        return self.exec_string
-
-    def p(self) :
-        print str(self)
-
     def append_stmt(self, stmt) :
         self.exec_code_valid = 0
         self.line += 1
-        if (stmt != "\n"):
-            for x in range(0,self.indent_level):
-                self.exec_string = self.exec_string + ' '            
-            self.exec_string = self.exec_string + stmt + "\t\t# l:" + str(self.line) + '\n'
-        else:
-            if (stmt == "\n"):
-                self.exec_string = self.exec_string + "# l:" + str(self.line) + '\n'
-            else:
-                self.exec_string = self.exec_string + stmt + "\t\t# l:" + str(self.line) + '\n'
+        for x in range(0,self.indent_level):
+            self.exec_string = self.exec_string + ' '            
+        self.exec_string = self.exec_string + stmt + '\n'
 
     def indent(self) :
         self.indent_level = self.indent_level + self.indent_increment
@@ -235,6 +219,8 @@ class XmlCb_Parser: # The target object of the parser
         # Set signature (in/out & name) for method
         if (tag == 'arg'):
             if (self.current == 'method'):
+                if (attrib.has_key('direction') == False):
+                    attrib['direction'] = "in"
                 self.dynDBusClass.add_signature(attrib['name'],
                                                 attrib['direction'],
                                                 attrib['type'])
@@ -270,7 +256,6 @@ class dynDBusClass():
         self.class_code.indent_increment = 4
         self.class_code.append_stmt("import dbus")
         self.class_code.append_stmt("\n")
-        self.class_code.append_stmt("\n")
         self.class_code.append_stmt("class " + self.className + "(dbus.service.Object):")
         self.class_code.indent()
         
@@ -280,7 +265,6 @@ class dynDBusClass():
         self.add_stmt("self.bus = bus")
         self.add_stmt("self.objName = objName")
         self.add_stmt("self.callback = callback")        
-#        self.add_stmt("dbus.service.Object.__init__(self, conn=bus, object_path=objName, bus_name=busName)")
         self.add_stmt("dbus.service.Object.__init__(self, conn=bus, bus_name=busName)")
         self.end_method()
                
@@ -360,7 +344,6 @@ class dynDBusClass():
         
     def end_method(self):
         self.class_code.append_stmt("\n")
-        self.class_code.append_stmt("\n")        
         self.class_code.dedent()
         
     def add_dbus_method(self):
@@ -390,7 +373,6 @@ class dynDBusClass():
 
     def add_body_method(self):
         if (self.methodToAdd != None):
-            self.class_code.append_stmt("print 'In " + self.methodToAdd + "()'")
             if (self.args_str != str()):
                 self.class_code.append_stmt("self.callback('" + self.methodToAdd + "', dbus_async_cb, dbus_async_err_cb, %s)" % self.args_str)
             else:        
@@ -405,17 +387,6 @@ class dynDBusClass():
         
     def declare(self) :
         self.class_code.execute()
-     
-    def __str__(self) :
-        return self.class_code.exec_string
-
-    # p : Since it is often useful to be able to look at the code
-    # that is generated interactively, this function provides
-    # a shorthand for "print str(some_exec_code_instance)", which
-    # gives a reasonable nice look at the contents of the
-    # exec_code object.
-    def p(self) :
-        print str(self)
 
 
 
@@ -640,27 +611,12 @@ class CloudeebusService:
             self.dynDBusClasses[self.className] = dynDBusClass(self.className, self.globalCtx, self.localCtx)
             self.dynDBusClasses[self.className].createDBusServiceFromXML(xmlTemplate)
             self.dynDBusClasses[self.className].declare()
-            
-            # For Debug only
-            if (1):
-                if (1): ## Force deletion
-                    if os.access('./MyDbusClass.py', os.R_OK) == True:
-                        os.remove('./MyDbusClass.py')
-                    
-                    if os.access('./MyDbusClass.py', os.R_OK) == False:
-                        f = open('./MyDbusClass.py', 'w')
-                        f.write(self.dynDBusClasses[self.className].class_code.exec_string)
-                        f.close()
 
         ## Class already exist, instanciate it if not already instanciated
         if (self.serviceAgents.has_key(self.className) == False):
-#            self.dynDBusClasses[self.className].p()
-#            self.dynDBusClasses[self.className].declare()
             self.serviceAgents[self.className] = eval(self.className + "(self.bus, callback=self.srvCB, objName=self.agentObjectPath, busName=self.srvName)", self.globalCtx, self.localCtx)
             
         self.serviceAgents[self.className].add_to_connection()
-#        exe_str = "self.serviceAgents['" + self.className +"'].add_to_connection()"
-#        exec (exe_str, self.globalCtx, self.localCtx)
         return (self.agentObjectPath)
                     
     @exportRpc