Commit 988655c1 authored by Nicolas Delaby's avatar Nicolas Delaby

2010-01-05 nicolas

* Add alarm to check Conversion Tool availability (oood)
reviewed by romain

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31571 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21fd3f16
# -*- coding: utf-8 -*-
import sys
from ZODB.POSException import ConflictError
from zExceptions import ExceptionFormatter
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5Type.Document import newTempOOoDocument
from zLOG import LOG, INFO
def dumpWorkflowChain(self):
# This method outputs the workflow chain in the format that you can
# easily get diff like the following:
......@@ -90,3 +98,40 @@ def MessageCatalog_deleteNotTranslatedMessageDict(self):
# delete message from dict
del(self._messages[k])
return len(not_translated_message_dict.keys())
def checkConversionToolAvailability(self):
"""
Check conversion tool (oood) is available for erp5.
This script convert an odt document into HTML and try to read
the returned string and find out expected string
"""
portal = self.getPortalObject()
document_id = 'P-ERP5-TEST.Conversion.Tool.Availability-001-en.odt'
document_path = 'portal_skins/erp5_administration/%s' % (document_id,)
document_file = portal.restrictedTraverse(document_path)
message = None
severity = 0
try:
temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id)
temp_document.convertToBaseFormat()
mimetype, html_result = temp_document.convert(format='html')
except ConflictError:
raise
except: #Which Errors should we catch ?
#Transformation failed
message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info()))
else:
#Everything goes fine, Check that expected string is present in HTML conversion
if 'AZERTYUIOPMQ' not in html_result:
message = 'Conversion to HTML Failed:\n%s' % (html_result,)
active_process = self.newActiveProcess()
result = ActiveResult()
if message:
severity = 1
result.edit(detail=message)
result.edit(severity=severity)
active_process.activateResult(result)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Alarm" module="Products.ERP5Type.Document.Alarm"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkConversionToolAvailability</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple>
<string>problem</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Check that conversion tool (oood) is available for erp5</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>check_conversion_tool_availability</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1230768000.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_stop_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1577836800.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>sense_method_id</string> </key>
<value> <string>Alarm_getConversionToolAvailabiltyResult</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Check Conversion Tool Availability</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>checkConversionToolAvailability</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5Administration</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkConversionToolAvailability</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if process is None:\n
return False\n
result_list = process.getResultList()\n
return result_list and bool(result_list[0].getProperty(\'severity\')) or False\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>process=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>process</string>
<string>None</string>
<string>False</string>
<string>_getattr_</string>
<string>result_list</string>
<string>bool</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_getConversionToolAvailabiltyResult</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2010-01-05 nicolas
* Add alarm to check Conversion Tool availability (oood)
2009-10-16 rafael
* Update for the changes of new portal types of portal types.
......
75
\ No newline at end of file
82
\ No newline at end of file
portal_alarms/check_catalog
portal_alarms/check_conversion_tool_availability
portal_alarms/check_folder_handler
portal_alarms/check_localizer
portal_alarms/check_stock
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment