[Erp5-report] r42379 davide.tammaro - in /erp5/trunk/products/Vifib: Conduit/ Tool/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jan 17 15:19:22 CET 2011
Author: davide.tammaro
Date: Mon Jan 17 15:19:22 2011
New Revision: 42379
URL: http://svn.erp5.org?rev=42379&view=rev
Log:
Added VifibConduit in Conduit. In SlapTool modified the useComputer func
Added:
erp5/trunk/products/Vifib/Conduit/
erp5/trunk/products/Vifib/Conduit/VifibConduit.py
- copied unchanged from r42374, erp5/trunk/products/Vifib/Tool/VifibConduit.py
erp5/trunk/products/Vifib/Conduit/__init__.py
Removed:
erp5/trunk/products/Vifib/Tool/VifibConduit.py
Modified:
erp5/trunk/products/Vifib/Tool/SlapTool.py
Added: erp5/trunk/products/Vifib/Conduit/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/Vifib/Conduit/__init__.py?rev=42379&view=auto
==============================================================================
--- erp5/trunk/products/Vifib/Conduit/__init__.py (added)
+++ erp5/trunk/products/Vifib/Conduit/__init__.py [utf8] Mon Jan 17 15:19:22 2011
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Łukasz Nowak <luke at nexedi.com>
+# Romain Courteaud <romain at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contract a Free Software
+# Service Company
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
Modified: erp5/trunk/products/Vifib/Tool/SlapTool.py
URL: http://svn.erp5.org/erp5/trunk/products/Vifib/Tool/SlapTool.py?rev=42379&r1=42378&r2=42379&view=diff
==============================================================================
--- erp5/trunk/products/Vifib/Tool/SlapTool.py [utf8] (original)
+++ erp5/trunk/products/Vifib/Tool/SlapTool.py [utf8] Mon Jan 17 15:19:22 2011
@@ -61,7 +61,7 @@ except ImportError:
from zLOG import LOG, INFO
import xml_marshaller
-
+from Products.Vifib.Conduit import VifibConduit
class SoftwareInstanceNotReady(Exception):
pass
@@ -256,7 +256,20 @@ class SlapTool(BaseTool):
computer_document = self._getComputerDocument(computer_id)
# easy way to start to store usage messages sent by client in related Web
# Page text_content...
- self._reportComputerUsage(computer_document, use_string)
+
+ #self._reportComputerUsage(computer_document, use_string)
+ #LOG("check-1", 0, "%s" % use_string)
+ unmarshalled_usage = xml_marshaller.xml_marshaller.loads(use_string)
+ #res = unmarshalled_usage.computer_partition_usage_list
+
+ #LOG("check-2", 0, "%s" % res[0].usage)
+ vifib_conduit_instance = VifibConduit.VifibConduit()
+ sub_object = vifib_conduit_instance.addNode(object=self,
+ xml=unmarshalled_usage.computer_partition_usage_list[0].usage)
+
+ #sub_object = vifib_conduit_instance.addNode(object=self, xml=res[0].usage)
+ #self._reportComputerUsage(computer_document, use_string)
+
return 'Content properly posted.'
security.declareProtected(Permissions.AccessContentsInformation, 'loadComputerConfigurationFromXML')
Removed: erp5/trunk/products/Vifib/Tool/VifibConduit.py
URL: http://svn.erp5.org/erp5/trunk/products/Vifib/Tool/VifibConduit.py?rev=42378&view=auto
==============================================================================
--- erp5/trunk/products/Vifib/Tool/VifibConduit.py [utf8] (original)
+++ erp5/trunk/products/Vifib/Tool/VifibConduit.py (removed)
@@ -1,83 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from AccessControl import ClassSecurityInfo
-from AccessControl import Unauthorized
-from AccessControl.SecurityManagement import newSecurityManager
-from OFS.Traversable import NotFound
-from Products.DCWorkflow.DCWorkflow import ValidationFailed
-from Products.ERP5Security.ERP5UserManager import SUPER_USER
-from Products.ERP5Type.Globals import InitializeClass
-from Products.ERP5Type.Tool.BaseTool import BaseTool
-from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
-from slapos.slap.slap import Computer
-from slapos.slap.slap import ComputerPartition as SlapComputerPartition
-from slapos.slap.slap import SoftwareInstance
-from slapos.slap.slap import SoftwareRelease
-from zLOG import LOG, INFO
-import xml_marshaller
-from lxml import etree
-from lxml.etree import Element
-parser = etree.XMLParser(remove_blank_text=True)
-
-
-class VifibConduit():
- """This conduit is used to synchronize tiosafe packing list and erp5"""
-
- def __init__(self):
- pass
-
- def convertToXml(self, xml):
- """
- if xml is a string, convert it in a node
- """
- if xml is None: return None
- if isinstance(xml, (str, unicode)):
- if isinstance(xml, unicode):
- xml = xml.encode('utf-8')
- #LOG('VifibCounduit', INFO, '%s' % xml, error=True)
- xml = etree.XML(xml, parser=parser)
- #if we have the xml from the node erp5 we just take the subnode
- if xml.xpath('local-name()') == 'erp5':
- xml = xml[0]
- return xml
-
-
-
- def addNode(self, object=None, xml=None):
- """
- This method create an object
- """
- #LOG('VifibConduit-check-3', INFO, '%s' % xml, error=True)
- xml = self.convertToXml(xml)
- tags_text = {}
- #fill up a dict with (tag - text) pairs
- for element in xml.iter():
- tags_text[element.tag] = element.text
- #retrieve the packing list module
- sale_packing_list_portal_type = 'Sale Packing List'
- sale_packing_list_module = \
- object.getPortalObject().getDefaultModule(sale_packing_list_portal_type)
- #We create the new packing list
-
- usage_report_sale_packing_list_document = \
- sale_packing_list_module.newContent(
- portal_type = 'Sale Packing List',
- )
-
- usage_report_sale_packing_list_document.confirm()
- usage_report_sale_packing_list_document.start()
- #Note inverted time and date---remember to correct in slapreport
- usage_report_sale_packing_list_document.edit(
- start_date=tags_text['time'],
- start_time=tags_text['date'],
- memory=tags_text['Memory'],
- cpu_time=tags_text['CpuTime'],
- cpu_percent=tags_text['CPU'],
- rss=tags_text['RSS'],
- )
-
- return usage_report_sale_packing_list_document
-
- #software_release_module_id = object.getDefaultModuleId(portal_type = 'Sale Packing List')
- #software_release_module_id = self.portal.restrictedTraverse(software_release_module_id)
- #software_release = software_release_module.newContent(portal_type = 'Sale Packing List')
More information about the Erp5-report
mailing list