Commit fc1919db authored by Rafael Monnerat's avatar Rafael Monnerat

*: pylint code for CodeStyleTest

  This fixes up most of inconsistencies related to pylint runs in
  order to clean up and make test pass (mostly)
parent b419a49c
...@@ -49,7 +49,7 @@ def ComputerConsumptionTioXMLFile_parseXml(self, REQUEST=None): ...@@ -49,7 +49,7 @@ def ComputerConsumptionTioXMLFile_parseXml(self, REQUEST=None):
try: try:
tree = etree.parse(string_to_validate) tree = etree.parse(string_to_validate)
except (etree.XMLSyntaxError, etree.DocumentInvalid) as e: except (etree.XMLSyntaxError, etree.DocumentInvalid): #pylint: disable=catching-non-exception
return None return None
if not xmlschema.validate(tree): if not xmlschema.validate(tree):
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSAccounting</string> </value> <value> <string>SlapOSAccounting</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSAccounting</string> </value> <value> <string>extension.erp5.SlapOSAccounting</string> </value>
...@@ -33,9 +45,7 @@ ...@@ -33,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 52, 58: Unused variable \'e\' (unused-variable)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -45,13 +55,28 @@ ...@@ -45,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -64,7 +89,7 @@ ...@@ -64,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -73,7 +98,7 @@ ...@@ -73,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -2,7 +2,7 @@ from zExceptions import Unauthorized ...@@ -2,7 +2,7 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
from erp5.component.module.DateUtils import addToDate, getClosestDate from erp5.component.module.DateUtils import getClosestDate
hosting_subscription = context hosting_subscription = context
portal = context.getPortalObject() portal = context.getPortalObject()
......
...@@ -7,7 +7,7 @@ from erp5.component.module.DateUtils import addToDate, getClosestDate ...@@ -7,7 +7,7 @@ from erp5.component.module.DateUtils import addToDate, getClosestDate
hosting_subscription = context hosting_subscription = context
portal = context.getPortalObject() portal = context.getPortalObject()
start_date = context.HostingSubscription_calculateSubscriptionStartDate() #start_date = context.HostingSubscription_calculateSubscriptionStartDate()
workflow_item_list = portal.portal_workflow.getInfoFor( workflow_item_list = portal.portal_workflow.getInfoFor(
ob=hosting_subscription, ob=hosting_subscription,
......
from erp5.component.module.DateUtils import addToDate, getClosestDate from erp5.component.module.DateUtils import addToDate
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL") raise Unauthorized("Unauthorized call script from URL")
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL") raise Unauthorized("Unauthorized call script from URL")
...@@ -10,25 +11,25 @@ def consumption_model_shuttle_ds61_i7(load): ...@@ -10,25 +11,25 @@ def consumption_model_shuttle_ds61_i7(load):
""" Expected consumed watts for the computer load """ Expected consumed watts for the computer load
""" """
if load <= 25: if load <= 25:
return 21.5 + 1.06*load return 21.5 + 1.06*load
else: else:
return 48 + 0.29*load return 48 + 0.29*load
def consumption_model_shuttle_nuc_i7(load): def consumption_model_shuttle_nuc_i7(load):
""" Expected consumed watts for the computer load """ Expected consumed watts for the computer load
""" """
if load <= 25: if load <= 25:
return 8.5 + 0.46*load return 8.5 + 0.46*load
else: else:
return 20 + 0.08*load return 20 + 0.08*load
def consumption_model_rikomagic_mk802iv(load): def consumption_model_rikomagic_mk802iv(load):
""" Expected consumed watts for the computer load """ Expected consumed watts for the computer load
""" """
if load <= 25: if load <= 25:
return 2.2 + 0.04*load return 2.2 + 0.04*load
else: else:
return 3.2 + 0.008*load return 3.2 + 0.008*load
def no_model(load): def no_model(load):
return 0 return 0
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL") raise Unauthorized("Unauthorized call script from URL")
......
partition_co2_dict = {}
min_delta_co2 = 2000 min_delta_co2 = 2000
minimal_candidate = None minimal_candidate = None
......
from DateTime import DateTime from DateTime import DateTime
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Document import newTempDocument
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -136,7 +135,7 @@ for date in sorted(consumption_dict, reverse=True): ...@@ -136,7 +135,7 @@ for date in sorted(consumption_dict, reverse=True):
hosting_title, instance_dict, hs_url = consumption_dict[date][hosting_key] hosting_title, instance_dict, hs_url = consumption_dict[date][hosting_key]
for instance_value_list in instance_dict.values(): for instance_value_list in instance_dict.values():
instance_title, values, instance_url, computer_title = instance_value_list instance_title, values, instance_url, computer_title = instance_value_list
line = newTempDocument(portal, instance_url, uid="%s_%s" % (context.getUid(), i)) line = newTempBase(portal, instance_url, uid="%s_%s" % (context.getUid(), i))
line.edit( line.edit(
title=hosting_title, title=hosting_title,
start_date=date, start_date=date,
......
from Products.ZSQLCatalog.SQLCatalog import Query
portal = context.getPortalObject() portal = context.getPortalObject()
query_kw.update(query_kw['selection'].getParams()) query_kw.update(query_kw['selection'].getParams())
......
portal = context.getPortalObject() portal = context.getPortalObject()
software_release_url = context.getUrlString() #software_release_url = context.getUrlString()
resource_uid = context.service_module.cpu_load_percent.getUid() resource_uid = context.service_module.cpu_load_percent.getUid()
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
......
...@@ -32,4 +32,4 @@ for movement in movement_list: ...@@ -32,4 +32,4 @@ for movement in movement_list:
if line is not None: if line is not None:
deliveries_keys[line.getExplanationValue()] = 1 deliveries_keys[line.getExplanationValue()] = 1
return filter(lambda x : x is not None, deliveries_keys.keys()) return [x for x in deliveries_keys if x is not None]
...@@ -28,7 +28,7 @@ class Simulator: ...@@ -28,7 +28,7 @@ class Simulator:
"""Simulation Method""" """Simulation Method"""
old = open(self.outfile, 'r').read() old = open(self.outfile, 'r').read()
if old: if old:
l = eval(old) l = eval(old) #pylint: disable=eval-used
else: else:
l = [] l = []
l.append({'recmethod': self.method, l.append({'recmethod': self.method,
...@@ -782,8 +782,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin): ...@@ -782,8 +782,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
simulation_movement.SimulationMovement_buildSlapOS(tag='root_tag') simulation_movement.SimulationMovement_buildSlapOS(tag='root_tag')
build_value = eval(open(build_simulator).read()) build_value = eval(open(build_simulator).read()) #pylint: disable=eval-used
activate_value = eval(open(activate_simulator).read()) activate_value = eval(open(activate_simulator).read()) #pylint: disable=eval-used
self.assertEqual([{ self.assertEqual([{
'recmethod': 'build', 'recmethod': 'build',
...@@ -804,8 +804,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin): ...@@ -804,8 +804,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
open(activate_simulator, 'w').truncate() open(activate_simulator, 'w').truncate()
lower_simulation_movement.SimulationMovement_buildSlapOS(tag='lower_tag') lower_simulation_movement.SimulationMovement_buildSlapOS(tag='lower_tag')
build_value = eval(open(build_simulator).read()) build_value = eval(open(build_simulator).read()) #pylint: disable=eval-used
activate_value = eval(open(activate_simulator).read()) activate_value = eval(open(activate_simulator).read()) #pylint: disable=eval-used
self.assertEqual([{ self.assertEqual([{
'recmethod': 'build', 'recmethod': 'build',
...@@ -870,8 +870,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin): ...@@ -870,8 +870,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
simulation_movement.SimulationMovement_buildSlapOS(tag='root_tag') simulation_movement.SimulationMovement_buildSlapOS(tag='root_tag')
build_value = eval(open(build_simulator).read()) build_value = eval(open(build_simulator).read()) #pylint: disable=eval-used
activate_value = eval(open(activate_simulator).read()) activate_value = eval(open(activate_simulator).read()) #pylint: disable=eval-used
self.assertEqual([], build_value) self.assertEqual([], build_value)
self.assertEqual([], activate_value) self.assertEqual([], activate_value)
...@@ -880,8 +880,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin): ...@@ -880,8 +880,8 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
open(activate_simulator, 'w').write(repr([])) open(activate_simulator, 'w').write(repr([]))
lower_simulation_movement.SimulationMovement_buildSlapOS(tag='lower_tag') lower_simulation_movement.SimulationMovement_buildSlapOS(tag='lower_tag')
build_value = eval(open(build_simulator).read()) build_value = eval(open(build_simulator).read()) #pylint: disable=eval-used
activate_value = eval(open(activate_simulator).read()) activate_value = eval(open(activate_simulator).read()) #pylint: disable=eval-used
self.assertEqual([], build_value) self.assertEqual([], build_value)
self.assertEqual([], activate_value) self.assertEqual([], activate_value)
...@@ -944,8 +944,8 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin): ...@@ -944,8 +944,8 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
delivery.Delivery_manageBuildingCalculatingDelivery() delivery.Delivery_manageBuildingCalculatingDelivery()
updateCausalityState_value = eval(open(updateCausalityState_simulator).read()) updateCausalityState_value = eval(open(updateCausalityState_simulator).read()) #pylint: disable=eval-used
updateSimulation_value = eval(open(updateSimulation_simulator).read()) updateSimulation_value = eval(open(updateSimulation_simulator).read()) #pylint: disable=eval-used
if empty: if empty:
self.assertEqual([], updateCausalityState_value) self.assertEqual([], updateCausalityState_value)
...@@ -1330,7 +1330,7 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin): ...@@ -1330,7 +1330,7 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
) )
return open_order return open_order
def _simulateScript(self, script_name): def _simulateScript(self, script_name, fake_return="False"):
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name) raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom, createZODBPythonScript(self.portal.portal_skins.custom,
......
...@@ -45,19 +45,7 @@ ...@@ -45,19 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 31, 10: Use of eval (eval-used)</string>
<string>W:785, 20: Use of eval (eval-used)</string>
<string>W:786, 23: Use of eval (eval-used)</string>
<string>W:807, 20: Use of eval (eval-used)</string>
<string>W:808, 23: Use of eval (eval-used)</string>
<string>W:873, 20: Use of eval (eval-used)</string>
<string>W:874, 23: Use of eval (eval-used)</string>
<string>W:883, 20: Use of eval (eval-used)</string>
<string>W:884, 23: Use of eval (eval-used)</string>
<string>W:947, 35: Use of eval (eval-used)</string>
<string>W:948, 31: Use of eval (eval-used)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -170,7 +170,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin): ...@@ -170,7 +170,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
def test_OpenSaleOrder_reindexIfIndexedBeforeLine_line_indexed_before(self): def test_OpenSaleOrder_reindexIfIndexedBeforeLine_line_indexed_before(self):
portal = self.portal portal = self.portal
order = self.createOpenSaleOrder() order = self.createOpenSaleOrder()
line = order.newContent(portal_type="Open Sale Order Line") order.newContent(portal_type="Open Sale Order Line")
self.tic() self.tic()
order.activate().immediateReindexObject() order.activate().immediateReindexObject()
# XXX One more kitten killed # XXX One more kitten killed
......
...@@ -45,9 +45,7 @@ ...@@ -45,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:173, 4: Unused variable \'line\' (unused-variable)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
# #
############################################################################## ##############################################################################
import transaction
from erp5.component.test.SlapOSTestCaseMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, SlapOSTestCaseMixin, simulate SlapOSTestCaseMixinWithAbort, SlapOSTestCaseMixin, simulate
from zExceptions import Unauthorized from zExceptions import Unauthorized
...@@ -267,7 +266,6 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration( ...@@ -267,7 +266,6 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
def createAllocatedComputer(self): def createAllocatedComputer(self):
# Create person # Create person
password = self.generateNewId()
reference = 'test_%s' % self.generateNewId() reference = 'test_%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
title=reference, title=reference,
...@@ -275,7 +273,6 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration( ...@@ -275,7 +273,6 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
person.newContent(portal_type='Assignment', role='member').open() person.newContent(portal_type='Assignment', role='member').open()
# Create second person # Create second person
password = self.generateNewId()
reference = 'test_%s' % self.generateNewId() reference = 'test_%s' % self.generateNewId()
second_person = self.portal.person_module.newContent(portal_type='Person', second_person = self.portal.person_module.newContent(portal_type='Person',
title=reference, title=reference,
......
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:270, 4: Unused variable \'password\' (unused-variable)</string>
<string>W: 8, 0: Unused import transaction (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -32,7 +32,7 @@ from AccessControl import Unauthorized ...@@ -32,7 +32,7 @@ from AccessControl import Unauthorized
from DateTime import DateTime from DateTime import DateTime
def getComputerSecurityCategory(self, base_category_list, user_name, def getComputerSecurityCategory(self, base_category_list, user_name,
object, portal_type): ob, portal_type):
""" """
This script returns a list of dictionaries which represent This script returns a list of dictionaries which represent
the security groups which a computer is member of. the security groups which a computer is member of.
...@@ -58,7 +58,7 @@ def getComputerSecurityCategory(self, base_category_list, user_name, ...@@ -58,7 +58,7 @@ def getComputerSecurityCategory(self, base_category_list, user_name,
return category_list return category_list
def getSoftwareInstanceSecurityCategory(self, base_category_list, user_name, def getSoftwareInstanceSecurityCategory(self, base_category_list, user_name,
object, portal_type): ob, portal_type):
""" """
This script returns a list of dictionaries which represent This script returns a list of dictionaries which represent
the security groups which a Software Instance is member of. the security groups which a Software Instance is member of.
...@@ -132,7 +132,7 @@ def getSecurityCategoryFromAssignmentDestinationClientOrganisation( ...@@ -132,7 +132,7 @@ def getSecurityCategoryFromAssignmentDestinationClientOrganisation(
self, self,
base_category_list, base_category_list,
user_name, user_name,
object, # pylint: disable=redefined-builtin ob,
portal_type, portal_type,
child_category_list=None child_category_list=None
): ):
...@@ -152,7 +152,7 @@ def getSecurityCategoryFromAssignmentDestinationClientOrganisation( ...@@ -152,7 +152,7 @@ def getSecurityCategoryFromAssignmentDestinationClientOrganisation(
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to ob -- object which we want to assign roles to
portal_type -- portal type of object portal_type -- portal type of object
""" """
category_list = [] category_list = []
......
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 35, 32: Redefining built-in \'object\' (redefined-builtin)</string>
<string>W: 61, 32: Redefining built-in \'object\' (redefined-builtin)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -103,25 +100,28 @@ ...@@ -103,25 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
network = context
portal = context.getPortalObject() portal = context.getPortalObject()
software_release = context.REQUEST.get('here') software_release = context.REQUEST.get('here')
......
...@@ -22,7 +22,7 @@ for computer in network.getSubordinationRelatedValueList(): ...@@ -22,7 +22,7 @@ for computer in network.getSubordinationRelatedValueList():
if isAllowed: if isAllowed:
allocation_state = 'Open' allocation_state = 'Open'
break break
except: except Exception:
continue continue
return allocation_state return allocation_state
slap_state = context.getSlapState() slap_state = context.getSlapState()
portal = context.getPortalObject() portal = context.getPortalObject()
portal_preferences = portal.portal_preferences
if slap_state == 'free': if slap_state == 'free':
computer = context.getParentValue() computer = context.getParentValue()
......
...@@ -4,9 +4,9 @@ status = "" ...@@ -4,9 +4,9 @@ status = ""
state = 'green' state = 'green'
if software_instance is not None: if software_instance is not None:
status = software_instance.SoftwareInstance_getCurrentStatus() status = software_instance.SoftwareInstance_getCurrentStatus()
if status.startswith('#error '): if status.startswith('#error '):
state = "red" state = "red"
return '<a href="%s" style="background-color: %s; display: block; height: 2em; width: 2em; float: left; margin: 5px;"></a> ' \ return '<a href="%s" style="background-color: %s; display: block; height: 2em; width: 2em; float: left; margin: 5px;"></a> ' \
'<p style="float: left; line-height: 10px; margin-left: 10px;">%s</p>' % ( '<p style="float: left; line-height: 10px; margin-left: 10px;">%s</p>' % (
......
...@@ -37,11 +37,11 @@ else : ...@@ -37,11 +37,11 @@ else :
if v: if v:
new_category_dict[category] = v new_category_dict[category] = v
for property in property_list: for _property in property_list:
if force or not computer.getProperty(property): if force or not computer.getProperty(_property):
v = computer_model.getProperty(property) v = computer_model.getProperty(_property)
if v: if v:
new_category_dict[property] = v new_category_dict[_property] = v
if new_category_dict: if new_category_dict:
computer.edit(**new_category_dict) computer.edit(**new_category_dict)
......
"""Fetch computer to find witch software is installed""" """Fetch computer to find witch software is installed"""
portal = context.getPortalObject()
portal_type = "Software Release" portal_type = "Software Release"
url_string_list = context.Computer_getSoftwareReleaseUrlStringList() url_string_list = context.Computer_getSoftwareReleaseUrlStringList()
......
computer = context
portal = context.getPortalObject() portal = context.getPortalObject()
software_installation_list = portal.portal_catalog( software_installation_list = portal.portal_catalog(
......
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery return context.getPortalObject().portal_catalog.countResults(
portal = context.getPortalObject()
computer = context
return portal.portal_catalog.countResults(
portal_type='Computer Partition', portal_type='Computer Partition',
parent_uid=computer.getUid(), parent_uid=context.getUid(),
free_for_request=0, free_for_request=0,
software_release_url=software_release_url software_release_url=software_release_url
)[0][0] )[0][0]
...@@ -3,8 +3,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery ...@@ -3,8 +3,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
person = context person = context
portal = context.getPortalObject() portal = context.getPortalObject()
def getOpenAllocationScopeUidList(exclude_uid_list=[]): def getOpenAllocationScopeUidList(exclude_uid_list):
return [scope.getUid() for scope in portal.portal_categories.allocation_scope.open.objectValues() if scope.getUid() not in exclude_uid_list] return [scope.getUid() for scope in portal.portal_categories.allocation_scope.open.objectValues()
if scope.getUid() not in exclude_uid_list]
computer_partition = None computer_partition = None
...@@ -93,7 +94,8 @@ if subscription_reference is not None and software_instance_portal_type != "Slav ...@@ -93,7 +94,8 @@ if subscription_reference is not None and software_instance_portal_type != "Slav
query_kw["allocation_scope_uid"] = portal.portal_categories.allocation_scope.open.subscription.getUid() query_kw["allocation_scope_uid"] = portal.portal_categories.allocation_scope.open.subscription.getUid()
else: else:
# else pic anything but open/subscription # else pic anything but open/subscription
query_kw["allocation_scope_uid"] = getOpenAllocationScopeUidList(exclude_uid_list=[portal.portal_categories.allocation_scope.open.subscription.getUid()]) query_kw["allocation_scope_uid"] = getOpenAllocationScopeUidList(
exclude_uid_list=[portal.portal_categories.allocation_scope.open.subscription.getUid()])
extra_query_kw = context.ComputerPartition_getCustomAllocationParameterDict( extra_query_kw = context.ComputerPartition_getCustomAllocationParameterDict(
......
...@@ -18,7 +18,7 @@ if has_partition: ...@@ -18,7 +18,7 @@ if has_partition:
except Exception: except Exception:
raise raise
result = 'There is system issue, please try again later.' # result = 'There is system issue, please try again later.'
else: else:
if state in ["start_requested", "stop_requested"]: if state in ["start_requested", "stop_requested"]:
......
list = [] computer_list = []
for si in context.portal_catalog(url_string=context.getUrlString(), portal_type='Software Installation', validation_state='validated'): for si in context.portal_catalog(url_string=context.getUrlString(),
portal_type='Software Installation',
validation_state='validated'):
computer = si.getAggregateValue() computer = si.getAggregateValue()
if si.getSlapState() == 'start_requested' and \ if si.getSlapState() == 'start_requested' and \
not computer.Computer_getSoftwareReleaseUsage(context.getUrlString()) \ not computer.Computer_getSoftwareReleaseUsage(context.getUrlString()) \
and computer.getValidationState() == 'validated': and computer.getValidationState() == 'validated':
list.append(computer) computer_list.append(computer)
return list return computer_list
...@@ -2460,8 +2460,6 @@ class TestSlapOSCorePersonRequestComputer(SlapOSTestCaseMixin): ...@@ -2460,8 +2460,6 @@ class TestSlapOSCorePersonRequestComputer(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
person_user = self.makePerson() person_user = self.makePerson()
self.tic() self.tic()
...@@ -2702,7 +2700,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin): ...@@ -2702,7 +2700,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
else: else:
return self.activeSense_call() return self.activeSense_call()
from Products.ERP5Type.Document.Alarm import Alarm from Products.ERP5Type.Document.Alarm import Alarm #pylint: disable=import-error
Alarm.activeSense_call = Alarm.activeSense Alarm.activeSense_call = Alarm.activeSense
Alarm.activeSense = verify_activeSense_call Alarm.activeSense = verify_activeSense_call
......
...@@ -100,24 +100,28 @@ ...@@ -100,24 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -62,7 +62,7 @@ else: ...@@ -62,7 +62,7 @@ else:
# Change the state at the end to allow to execute updateLocalRoles only once in the transaction # Change the state at the end to allow to execute updateLocalRoles only once in the transaction
validation_state = software_installation.getValidationState() validation_state = software_installation.getValidationState()
slap_state = software_installation.getSlapState() # slap_state = software_installation.getSlapState()
if validation_state == 'draft': if validation_state == 'draft':
portal.portal_workflow.doActionFor(software_installation, portal.portal_workflow.doActionFor(software_installation,
'validate_action') 'validate_action')
......
instance = state_change['object'] instance = state_change['object']
portal = instance.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided # Raise TypeError if all parameters are not provided
try: try:
connection_xml = state_change.kwargs['connection_xml'] connection_xml = state_change.kwargs['connection_xml']
......
instance = state_change['object'] instance = state_change['object']
portal = instance.getPortalObject()
# Get required arguments # Get required arguments
kwargs = state_change.kwargs kwargs = state_change.kwargs
......
...@@ -15,7 +15,7 @@ try: ...@@ -15,7 +15,7 @@ try:
root_state = kwargs["state"] root_state = kwargs["state"]
except KeyError: except KeyError:
raise raise
raise TypeError, "RequesterInstance_request takes exactly 7 arguments" #raise TypeError, "RequesterInstance_request takes exactly 7 arguments"
if is_slave not in [True, False]: if is_slave not in [True, False]:
raise ValueError, "shared should be a boolean" raise ValueError, "shared should be a boolean"
......
...@@ -19,12 +19,6 @@ except KeyError: ...@@ -19,12 +19,6 @@ except KeyError:
if is_slave not in [True, False]: if is_slave not in [True, False]:
raise ValueError, "shared should be a boolean" raise ValueError, "shared should be a boolean"
empty_parameter = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>"""
empty_parameter2 = """<?xml version='1.0' encoding='utf-8'?>
<instance/>"""
hosting_subscription_portal_type = "Hosting Subscription" hosting_subscription_portal_type = "Hosting Subscription"
tag = "%s_%s_inProgress" % (person.getUid(), tag = "%s_%s_inProgress" % (person.getUid(),
......
...@@ -3,14 +3,14 @@ grade = context.Base_getServiceLevelObjectGrade(slo, value) ...@@ -3,14 +3,14 @@ grade = context.Base_getServiceLevelObjectGrade(slo, value)
return grade return grade
# Report seems not able to render HTML # Report seems not able to render HTML
color_dict = { # color_dict = {
"A": "lightgreen", # "A": "lightgreen",
"B": "green", # "B": "green",
"C": "blue", # "C": "blue",
"D": "orange", # "D": "orange",
"E": "red", # "E": "red",
"F": "red", # "F": "red",
} # }
for g, color in color_dict.iteritems(): # for g, color in color_dict.iteritems():
if grade.startswith(g): # if grade.startswith(g):
return "<font color='%s'>%s</font>" % (color, grade) # return "<font color='%s'>%s</font>" % (color, grade)
from DateTime import DateTime from DateTime import DateTime
import json import json
portal = context.getPortalObject() portal = context.getPortalObject()
from Products.ERP5Type.Document import newTempDocument from Products.ERP5Type.Document import newTempBase
public_category_uid = portal.restrictedTraverse( public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid() "portal_categories/allocation_scope/open/public", None).getUid()
...@@ -78,7 +78,7 @@ for computer in portal.portal_catalog( ...@@ -78,7 +78,7 @@ for computer in portal.portal_catalog(
instance_error_ratio = float(instance_error_count)/instance_count instance_error_ratio = float(instance_error_count)/instance_count
l.append( l.append(
newTempDocument(context, '%s'% computer.id, **{"title": computer.title, newTempBase(context, '%s'% computer.id, **{"title": computer.title,
"uid": "%s_%s" % (computer.getUid(), instance_count), "uid": "%s_%s" % (computer.getUid(), instance_count),
"reference": computer.reference, "reference": computer.reference,
"partition_use_ratio": partition_use_ratio, "partition_use_ratio": partition_use_ratio,
......
...@@ -2,9 +2,9 @@ portal = context.getPortalObject() ...@@ -2,9 +2,9 @@ portal = context.getPortalObject()
uid_list = [context.getUid()] uid_list = [context.getUid()]
for instance in portal.portal_catalog( for instance in portal.portal_catalog(
portal_type="Software Instance", portal_type="Software Instance",
default_aggregate_uid=[cp.uid for cp in context.searchFolder(portal_type="Computer Partition")]): default_aggregate_uid=[cp.uid for cp in context.searchFolder(portal_type="Computer Partition")]):
uid_list.append(instance.getSpecialiseUid(portal_type="Hosting Subscription")) uid_list.append(instance.getSpecialiseUid(portal_type="Hosting Subscription"))
return portal.portal_catalog( return portal.portal_catalog(
portal_type='Support Request', portal_type='Support Request',
......
portal = context.getPortalObject() portal = context.getPortalObject()
from Products.ERP5Type.Document import newTempDocument from Products.ERP5Type.Document import newTempBase
kw = {} kw = {}
kw["portal_type"] = "Hosting Subscription" kw["portal_type"] = "Hosting Subscription"
...@@ -39,7 +39,7 @@ document_list = [] ...@@ -39,7 +39,7 @@ document_list = []
for person_relative_url in l: for person_relative_url in l:
person = portal.restrictedTraverse(person_relative_url) person = portal.restrictedTraverse(person_relative_url)
document_list.append( document_list.append(
newTempDocument(context.person_module, person.getId(), newTempBase(context.person_module, person.getId(),
uid = "t_%s" % person.getUid(), title=person.getTitle(), uid = "t_%s" % person.getUid(), title=person.getTitle(),
**l[person_relative_url])) **l[person_relative_url]))
......
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Document import newTempDocument from Products.ERP5Type.Document import newTempBase
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -37,7 +37,7 @@ creation_date_list = list(date_set) ...@@ -37,7 +37,7 @@ creation_date_list = list(date_set)
creation_date_list.sort() creation_date_list.sort()
for creation_date in creation_date_list: for creation_date in creation_date_list:
line = newTempDocument(context, '%s' % creation_date.replace("/", "_"), **{ line = newTempBase(context, '%s' % creation_date.replace("/", "_"), **{
"uid": "%s_%s" % (context.getUid(), len(stats_list)), "uid": "%s_%s" % (context.getUid(), len(stats_list)),
"title": creation_date, "title": creation_date,
"hosting_subscription_quantity" : countDocument(creation_date, "Hosting Subscription"), "hosting_subscription_quantity" : countDocument(creation_date, "Hosting Subscription"),
......
from zExceptions import Unauthorized from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
pass #raise Unauthorized raise Unauthorized
document = context document = context
portal = document.getPortalObject() portal = document.getPortalObject()
......
import random import random
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
person = context
computer_partition = None computer_partition = None
query_kw = { query_kw = {
...@@ -19,14 +18,13 @@ else: ...@@ -19,14 +18,13 @@ else:
# support SLA # support SLA
# Explicit location # Explicit location
explicit_location = False #explicit_location = False
if "computer_guid" in filter_kw: if "computer_guid" in filter_kw:
explicit_location = True #explicit_location = True
query_kw["parent_reference"] = SimpleQuery(parent_reference=filter_kw.pop("computer_guid")) query_kw["parent_reference"] = SimpleQuery(parent_reference=filter_kw.pop("computer_guid"))
if "instance_guid" in filter_kw: if "instance_guid" in filter_kw:
explicit_location = True #explicit_location = True
portal = context.getPortalObject()
instance_guid = filter_kw.pop("instance_guid") instance_guid = filter_kw.pop("instance_guid")
query_kw["aggregate_related_reference"] = SimpleQuery(aggregate_related_reference=instance_guid) query_kw["aggregate_related_reference"] = SimpleQuery(aggregate_related_reference=instance_guid)
......
...@@ -78,7 +78,7 @@ if show_all or configuration == "skins": ...@@ -78,7 +78,7 @@ if show_all or configuration == "skins":
if show_all or configuration == "web_content": if show_all or configuration == "web_content":
expected_file = portal.expected_web_page_module_configuration expected_file = portal.expected_web_page_module_configuration
found = portal.ERP5Site_dumpWebPageModuleContent( found = portal.ERP5Site_dumpWebPageModuleContent(
ignore_string_on_reference=["rapid_"]) ignore_string_on_reference_list=["rapid_"])
print resolveDiff("Web Content Configuration Diff", expected_file, found) print resolveDiff("Web Content Configuration Diff", expected_file, found)
if show_all or configuration == "actions": if show_all or configuration == "actions":
......
import hashlib import hashlib
portal = context.getPortalObject() portal = context.getPortalObject()
if not ignore_string_on_reference_list:
ignore_string_on_reference_list = []
def getWebContentHash(document): def getWebContentHash(document):
content = document.getTextContent("ignore") content = document.getTextContent("ignore")
...@@ -20,7 +22,7 @@ for document in portal.web_page_module.searchFolder( ...@@ -20,7 +22,7 @@ for document in portal.web_page_module.searchFolder(
print_web_content = 1 print_web_content = 1
document_reference = str(document.getReference("")) document_reference = str(document.getReference(""))
for ignore_string in ignore_string_on_reference: for ignore_string in ignore_string_on_reference_list:
if ignore_string in document_reference: if ignore_string in document_reference:
print_web_content = 0 print_web_content = 0
break break
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>ignore_string_on_reference=["rapid"]</string> </value> <value> <string>ignore_string_on_reference_list=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -2,14 +2,12 @@ portal = context.getPortalObject() ...@@ -2,14 +2,12 @@ portal = context.getPortalObject()
uid_groups_columns_dict = portal.portal_catalog.getSQLCatalog().getSQLCatalogSecurityUidGroupsColumnsDict() uid_groups_columns_dict = portal.portal_catalog.getSQLCatalog().getSQLCatalogSecurityUidGroupsColumnsDict()
uid_groups_columns_items = sorted(uid_groups_columns_dict.items()) uid_groups_columns_items = sorted(uid_groups_columns_dict.items())
security_column_list = sorted(uid_groups_columns_dict.values()) #security_column_list = sorted(uid_groups_columns_dict.values())
user_id_list = ['claudie', 'rafael', 'vifib-admin', 'nexedi_development_service'] user_id_list = [ user.getReference() for user in portal.person_module.searchFolder(
#for user in portal.person_module.searchFolder( reference='%',
# reference='%', validation_state='validated',
# validation_state='validated', default_role_uid=portal.portal_categories.role.internal.getUid())]
# default_role_uid=portal.portal_categories.role.internal.getUid()):
# user_id_list.append(user.getReference())
info_list = [] info_list = []
for user_id in sorted(user_id_list): for user_id in sorted(user_id_list):
...@@ -19,7 +17,7 @@ for user_id in sorted(user_id_list): ...@@ -19,7 +17,7 @@ for user_id in sorted(user_id_list):
groups = user.getGroups() groups = user.getGroups()
uid_dict_and_roles_column_dict = portal.Base_getSecurityUidDictAndRoleColumnDictForUser(user_id) uid_dict_and_roles_column_dict = portal.Base_getSecurityUidDictAndRoleColumnDictForUser(user_id)
info = [user_id, len(groups)] info = [user_id, len(groups)]
for local_roles_group_id, security_column in uid_groups_columns_items: for local_roles_group_id, security_column in uid_groups_columns_items: #pylint: disable=unused-variable
info.append(len(uid_dict_and_roles_column_dict[0].get(local_roles_group_id,[]))) info.append(len(uid_dict_and_roles_column_dict[0].get(local_roles_group_id,[])))
info_list.append(info) info_list.append(info)
......
import hashlib
portal = context.getPortalObject() portal = context.getPortalObject()
content_dict = {} content_dict = {}
......
...@@ -7,8 +7,7 @@ base_category_list - list of category values we need to retrieve ...@@ -7,8 +7,7 @@ base_category_list - list of category values we need to retrieve
object - object which we want to assign roles to. object - object which we want to assign roles to.
""" """
result_list = [] user_name = ob.Base_getOwnerId() #pylint: disable=redefined-builtin
user_name = object.Base_getOwnerId()
# XXX Hardcoded role # XXX Hardcoded role
return { return {
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value> <value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -14,7 +14,7 @@ The parameters are ...@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to ob -- object which we want to assign roles to
portal_type -- portal type of object portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
...@@ -22,10 +22,10 @@ NOTE: for now, this script requires proxy manager ...@@ -22,10 +22,10 @@ NOTE: for now, this script requires proxy manager
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
for base_category in base_category_list: for base_category in base_category_list:
category_list.append({base_category: object.getParentValue().getRelativeUrl()}) category_list.append({base_category: ob.getParentValue().getRelativeUrl()})
return category_list return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value> <value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -32,7 +32,7 @@ if obj is None: ...@@ -32,7 +32,7 @@ if obj is None:
person = obj.getDestinationSectionValue(portal_type="Person") person = obj.getDestinationSectionValue(portal_type="Person")
if person is not None: if person is not None:
for base_category in base_category_list: if base_category_list:
return {"Auditor": ["SHADOW-%s" % person.getUserId()]} return {"Auditor": ["SHADOW-%s" % person.getUserId()]}
return category_list return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
portal_memcached = context portal_memcached = context
portal = context.getPortalObject()
# erp5-memcached-persistent is provided by SlapOS, so here we are # erp5-memcached-persistent is provided by SlapOS, so here we are
# ensuring the site uses real DNS Configuration provided by SlapOS. # ensuring the site uses real DNS Configuration provided by SlapOS.
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
portal_memcached = context portal_memcached = context
portal = context.getPortalObject()
# erp5-memcached-persistent is provided by SlapOS, so here we are # erp5-memcached-persistent is provided by SlapOS, so here we are
# ensuring the site uses real DNS Configuration provided by SlapOS. # ensuring the site uses real DNS Configuration provided by SlapOS.
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
portal_oauth = context.portal_oauth portal_oauth = context.portal_oauth
error_list = []
for connector in portal_oauth.searchFolder(portal_type="Facebook Connector"): for connector in portal_oauth.searchFolder(portal_type="Facebook Connector"):
if connector.getReference() == "default": if connector.getReference() == "default":
......
portal_oauth = context.portal_oauth portal_oauth = context.portal_oauth
error_list = []
for connector in portal_oauth.searchFolder(portal_type="Google Connector"): for connector in portal_oauth.searchFolder(portal_type="Google Connector"):
if connector.getReference() == "default": if connector.getReference() == "default":
......
...@@ -4,11 +4,9 @@ if context.getPortalType() not in [ "System Preference"]: ...@@ -4,11 +4,9 @@ if context.getPortalType() not in [ "System Preference"]:
if context.getPreferenceState() != "global": if context.getPreferenceState() != "global":
return [] return []
portal = context.getPortalObject() portal = context.getPortalObject()
system_preference = context system_preference = context
expected_url = portal.ERP5Site_getConfigurationCloudoooUrl() expected_url = portal.ERP5Site_getConfigurationCloudoooUrl()
url = system_preference.getPreferredDocumentConversionServerUrl() url = system_preference.getPreferredDocumentConversionServerUrl()
if expected_url != url: if expected_url != url:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from Products.ERP5Type.Document import newTempDocument from Products.ERP5Type.Document import newTempBase
temp_object_list = [] temp_object_list = []
for assignment in context.getDestinationRelatedValueList(portal_type="Assignment"): for assignment in context.getDestinationRelatedValueList(portal_type="Assignment"):
person = assignment.getParentValue() person = assignment.getParentValue()
temp_object_list.append( temp_object_list.append(
newTempDocument( newTempBase(
context, str(person.getId()), context, str(person.getId()),
title=person.getTitle(), title=person.getTitle(),
default_email_text=person.getDefaultEmailText() default_email_text=person.getDefaultEmailText()
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
......
from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
......
from zExceptions import Unauthorized from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None: if REQUEST is None:
raise Unauthorized raise Unauthorized
......
from Products.ERP5Type.Document import newTempDocument from Products.ERP5Type.Document import newTempBase
return_list = [] return_list = []
try: try:
connection_dict = context.getConnectionXmlAsDict() connection_dict = context.getConnectionXmlAsDict()
except: except Exception:
return return_list return return_list
if connection_dict is None: if connection_dict is None:
...@@ -17,7 +17,7 @@ for k in sorted(connection_dict): ...@@ -17,7 +17,7 @@ for k in sorted(connection_dict):
if raw: if raw:
d = {"connection_key": k, "connection_value": connection_dict[k]} d = {"connection_key": k, "connection_value": connection_dict[k]}
else: else:
d = newTempDocument(portal, relative_url) d = newTempBase(portal, relative_url)
d.edit(connection_key=k, connection_value=connection_dict[k]) d.edit(connection_key=k, connection_value=connection_dict[k])
return_list.append(d) return_list.append(d)
return return_list return return_list
from zExceptions import UnauthorizedError from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise UnauthorizedError raise Unauthorized
from DateTime import DateTime from DateTime import DateTime
import json import json
......
...@@ -82,7 +82,7 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -82,7 +82,7 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
self.tic() self.tic()
return instance return instance
def _makeComputer(self): def _makeComputer(self, owner=None, allocation_scope='open/public'):
computer = self.portal.computer_module\ computer = self.portal.computer_module\
.template_computer.Base_createCloneDocument(batch_mode=1) .template_computer.Base_createCloneDocument(batch_mode=1)
computer.edit(reference="TESTCOMP-%s" % computer.getId()) computer.edit(reference="TESTCOMP-%s" % computer.getId())
......
...@@ -100,25 +100,28 @@ ...@@ -100,25 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -23,7 +23,7 @@ select_kw.update( ...@@ -23,7 +23,7 @@ select_kw.update(
default_source_uid=portal.restrictedTraverse('account_module/receivable').getUid() default_source_uid=portal.restrictedTraverse('account_module/receivable').getUid()
movement_list = [] movement_list = []
id = 1 _id = 1
for invoice in portal.portal_catalog(**select_kw): for invoice in portal.portal_catalog(**select_kw):
invoice.getObject().serialize() # in order to avoid selection on concurrent transactions invoice.getObject().serialize() # in order to avoid selection on concurrent transactions
...@@ -51,21 +51,21 @@ for invoice in portal.portal_catalog(**select_kw): ...@@ -51,21 +51,21 @@ for invoice in portal.portal_catalog(**select_kw):
source_payment='%s/bank_account' % invoice.getSourceSection(), # the other place defnied: business process source_payment='%s/bank_account' % invoice.getSourceSection(), # the other place defnied: business process
) )
temp_movement_rec = newTempSimulationMovement( temp_movement_rec = newTempSimulationMovement(
temp_object=True, id=str(id), temp_object=True, id=str(_id),
quantity=-1 * quantity, quantity=-1 * quantity,
source='account_module/receivable', source='account_module/receivable',
destination='account_module/payable', destination='account_module/payable',
**temp_movement_kw **temp_movement_kw
) )
id += 1 _id += 1
temp_movement_bank = newTempSimulationMovement( temp_movement_bank = newTempSimulationMovement(
temp_object=True, id=str(id), temp_object=True, id=str(_id),
quantity=1 * quantity, quantity=1 * quantity,
source='account_module/bank', source='account_module/bank',
destination='account_module/bank', destination='account_module/bank',
**temp_movement_kw **temp_movement_kw
) )
id += 1 _id += 1
movement_list.extend([temp_movement_rec, temp_movement_bank]) movement_list.extend([temp_movement_rec, temp_movement_bank])
return movement_list return movement_list
...@@ -5,7 +5,7 @@ if REQUEST is not None: ...@@ -5,7 +5,7 @@ if REQUEST is not None:
portal = context.getPortalObject() portal = context.getPortalObject()
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite()) integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())
transaction_date, transaction_id = context.PaymentTransaction_getPayzenId() _, transaction_id = context.PaymentTransaction_getPayzenId()
if transaction_id is not None: if transaction_id is not None:
# XXX raise? # XXX raise?
return None, None return None, None
...@@ -28,10 +28,11 @@ mapping_id = '%s_%s' % (today, transaction_id) ...@@ -28,10 +28,11 @@ mapping_id = '%s_%s' % (today, transaction_id)
# raise ValueError, "Payzen transaction_id already exists" # raise ValueError, "Payzen transaction_id already exists"
try: try:
mapping = integration_site.getCategoryFromMapping( # Init for use later.
'Causality/%s' % context.getId().replace('-', '_'), integration_site.getCategoryFromMapping(
create_mapping_line=True, 'Causality/%s' % context.getId().replace('-', '_'),
create_mapping=True) create_mapping_line=True,
create_mapping=True)
except ValueError: except ValueError:
pass pass
integration_site.Causality[context.getId().replace('-', '_')].setDestinationReference(mapping_id) integration_site.Causality[context.getId().replace('-', '_')].setDestinationReference(mapping_id)
......
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject()
state = context.getSimulationState() state = context.getSimulationState()
transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2)) transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2))
......
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject()
state = context.getSimulationState() state = context.getSimulationState()
if (state != 'started') or (context.getPaymentMode() != 'payzen'): if (state != 'started') or (context.getPaymentMode() != 'payzen'):
return return
else: else:
transaction_date, transaction_id = context.PaymentTransaction_getPayzenId() _, transaction_id = context.PaymentTransaction_getPayzenId()
if transaction_id is not None: if transaction_id is not None:
# so the payment is registered in payzen # so the payment is registered in payzen
......
...@@ -9,7 +9,6 @@ def storeWorkflowComment(ctx, comment): ...@@ -9,7 +9,6 @@ def storeWorkflowComment(ctx, comment):
payzen_event = context payzen_event = context
transaction = payzen_event.getDestinationValue() transaction = payzen_event.getDestinationValue()
portal = transaction.getPortalObject()
assert signature in (True, False) assert signature in (True, False)
if signature is False: if signature is False:
...@@ -21,7 +20,7 @@ isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPos ...@@ -21,7 +20,7 @@ isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPos
error_code = data_kw['errorCode'] error_code = data_kw['errorCode']
if error_code == '2': if error_code == '2':
transaction_date, payzen_id = transaction.PaymentTransaction_getPayzenId() transaction_date, _ = transaction.PaymentTransaction_getPayzenId()
# Mark on payment transaction history log that transaction was not processed yet # Mark on payment transaction history log that transaction was not processed yet
payzen_event.confirm() payzen_event.confirm()
payzen_event.acknowledge(comment='Transaction not found on payzen side.') payzen_event.acknowledge(comment='Transaction not found on payzen side.')
...@@ -61,8 +60,6 @@ elif error_code == '0': ...@@ -61,8 +60,6 @@ elif error_code == '0':
payzen_event.confirm(comment='Unknown transactionStatus %r' % transaction_status) payzen_event.confirm(comment='Unknown transactionStatus %r' % transaction_status)
return return
doActionFor = context.getPortalObject().portal_workflow.doActionFor
if transaction_status in mark_transaction_id_list: if transaction_status in mark_transaction_id_list:
# Mark on payment transaction history log that transaction was not processed yet # Mark on payment transaction history log that transaction was not processed yet
storeWorkflowComment(transaction, 'Transaction status %s (%s) did not changed the document state' % (transaction_status, transaction_status_description)) storeWorkflowComment(transaction, 'Transaction status %s (%s) did not changed the document state' % (transaction_status, transaction_status_description))
......
...@@ -100,24 +100,28 @@ ...@@ -100,24 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -100,24 +100,28 @@ ...@@ -100,24 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -100,25 +100,28 @@ ...@@ -100,25 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -100,24 +100,28 @@ ...@@ -100,24 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -20,11 +20,10 @@ payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Tran ...@@ -20,11 +20,10 @@ payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Tran
now = DateTime() now = DateTime()
payment_transaction.AccountingTransaction_updateStartDate(now) payment_transaction.AccountingTransaction_updateStartDate(now)
transaction_date, transaction_id = payment_transaction.PaymentTransaction_generatePayzenId() _, transaction_id = payment_transaction.PaymentTransaction_generatePayzenId()
if transaction_id is None: if transaction_id is None:
raise ValueError, "Transaction already registered" raise ValueError, "Transaction already registered"
today = now.toZone('UTC').asdatetime().strftime('%Y%m%d')
payzen_dict = { payzen_dict = {
'vads_currency': payment_transaction.getResourceValue().Currency_getIntegrationMapping(), 'vads_currency': payment_transaction.getResourceValue().Currency_getIntegrationMapping(),
'vads_amount': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))), 'vads_amount': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),
......
...@@ -6,7 +6,6 @@ payzen related transaction for destination_section and doing its duplicate""" ...@@ -6,7 +6,6 @@ payzen related transaction for destination_section and doing its duplicate"""
from DateTime import DateTime from DateTime import DateTime
payzen_event = state_change['object'] payzen_event = state_change['object']
transaction = payzen_event.getDestinationValue() transaction = payzen_event.getDestinationValue()
portal = transaction.getPortalObject()
payment_service = payzen_event.getSourceValue(portal_type="Payzen Service") payment_service = payzen_event.getSourceValue(portal_type="Payzen Service")
previous_id = transaction.PaymentTransaction_getPreviousPayzenId() previous_id = transaction.PaymentTransaction_getPreviousPayzenId()
...@@ -31,6 +30,15 @@ payzen_dict.update( ...@@ -31,6 +30,15 @@ payzen_dict.update(
data_kw, signature, sent_text, received_text = payment_service.soap_duplicate(**payzen_dict) data_kw, signature, sent_text, received_text = payment_service.soap_duplicate(**payzen_dict)
sent = payzen_event.newContent(title='Sent SOAP', portal_type='Payzen Event Message', text_content=sent_text) # SENT
received = payzen_event.newContent(title='Received SOAP', text_content=received_text, predecessor_value=sent, portal_type='Payzen Event Message') sent = payzen_event.newContent(title='Sent SOAP',
portal_type='Payzen Event Message',
text_content=sent_text)
# RECEIVED
payzen_event.newContent(title='Received SOAP',
text_content=received_text,
predecessor_value=sent,
portal_type='Payzen Event Message')
context.PayzenEvent_processUpdate(state_change, data_kw, signature) context.PayzenEvent_processUpdate(state_change, data_kw, signature)
payzen_event = state_change['object'] payzen_event = state_change['object']
payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction") payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction")
portal = payment_transaction.getPortalObject()
transaction_date, transaction_id = payment_transaction.PaymentTransaction_getPayzenId() transaction_date, transaction_id = payment_transaction.PaymentTransaction_getPayzenId()
if transaction_id is None: if transaction_id is None:
...@@ -11,11 +10,14 @@ data_kw, signature, sent_text, received_text = payment_service.soap_getInfo( ...@@ -11,11 +10,14 @@ data_kw, signature, sent_text, received_text = payment_service.soap_getInfo(
transaction_date.toZone('UTC').asdatetime(), transaction_date.toZone('UTC').asdatetime(),
transaction_id) transaction_id)
# SENT
sent = payzen_event.newContent( sent = payzen_event.newContent(
title='Sent SOAP', title='Sent SOAP',
portal_type='Payzen Event Message', portal_type='Payzen Event Message',
text_content=sent_text) text_content=sent_text)
received = payzen_event.newContent(
# RECEIVED
payzen_event.newContent(
title='Received SOAP', title='Received SOAP',
portal_type='Payzen Event Message', portal_type='Payzen Event Message',
text_content=received_text, text_content=received_text,
......
...@@ -21,8 +21,9 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None): ...@@ -21,8 +21,9 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None):
for address in to_add_ip_dict_list: for address in to_add_ip_dict_list:
if to_delete_ip_id_list: if to_delete_ip_id_list:
id = to_delete_ip_id_list.pop() address_document = document.restrictedTraverse(
address_document = document.restrictedTraverse(id) to_delete_ip_id_list.pop()
)
else: else:
kw = {'portal_type': 'Internet Protocol Address'} kw = {'portal_type': 'Internet Protocol Address'}
if not len(document.objectIds(portal_type='Internet Protocol Address')): if not len(document.objectIds(portal_type='Internet Protocol Address')):
......
...@@ -25,7 +25,7 @@ class Simulator: ...@@ -25,7 +25,7 @@ class Simulator:
"""Simulation Method""" """Simulation Method"""
old = open(self.outfile, 'r').read() old = open(self.outfile, 'r').read()
if old: if old:
l = eval(old) l = eval(old) #pylint: disable=eval-used
else: else:
l = [] l = []
l.append({'recmethod': self.method, l.append({'recmethod': self.method,
...@@ -542,7 +542,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -542,7 +542,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertComputerBangSimulator(self, args, kwargs): def assertComputerBangSimulator(self, args, kwargs):
stored = eval(open(self.computer_bang_simulator).read()) stored = eval(open(self.computer_bang_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['comment'] = kwargs.pop('comment') kwargs['comment'] = kwargs.pop('comment')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -599,7 +599,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -599,7 +599,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
os.unlink(self.computer_bang_simulator) os.unlink(self.computer_bang_simulator)
def assertLoadComputerConfigurationFromXML(self, args, kwargs): def assertLoadComputerConfigurationFromXML(self, args, kwargs):
stored = eval(open(self.computer_load_configuration_simulator).read()) stored = eval(open(self.computer_load_configuration_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -848,7 +848,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -848,7 +848,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
self.assertEqual("", response.body) self.assertEqual("", response.body)
def assertReportComputerConsumption(self, args, kwargs): def assertReportComputerConsumption(self, args, kwargs):
stored = eval(open(self.computer_use_computer_simulator).read()) stored = eval(open(self.computer_use_computer_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -1477,7 +1477,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1477,7 +1477,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceUpdateConnectionSimulator(self, args, kwargs): def assertInstanceUpdateConnectionSimulator(self, args, kwargs):
stored = eval(open(self.instance_update_connection_simulator).read()) stored = eval(open(self.instance_update_connection_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['connection_xml'] = kwargs.pop('connection_xml') kwargs['connection_xml'] = kwargs.pop('connection_xml')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -1686,7 +1686,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1686,7 +1686,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceBangSimulator(self, args, kwargs): def assertInstanceBangSimulator(self, args, kwargs):
stored = eval(open(self.instance_bang_simulator).read()) stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['comment'] = kwargs.pop('comment') kwargs['comment'] = kwargs.pop('comment')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -1746,7 +1746,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1746,7 +1746,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
os.unlink(self.instance_bang_simulator) os.unlink(self.instance_bang_simulator)
def assertInstanceRenameSimulator(self, args, kwargs): def assertInstanceRenameSimulator(self, args, kwargs):
stored = eval(open(self.instance_rename_simulator).read()) stored = eval(open(self.instance_rename_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -1786,7 +1786,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1786,7 +1786,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.assertEqual(None, self.destroy_requested_software_instance.getSslCertificate()) self.assertEqual(None, self.destroy_requested_software_instance.getSslCertificate())
def assertInstanceRequestSimulator(self, args, kwargs): def assertInstanceRequestSimulator(self, args, kwargs):
stored = eval(open(self.instance_request_simulator).read()) stored = eval(open(self.instance_request_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -2393,7 +2393,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2393,7 +2393,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertComputerBangSimulator(self, args, kwargs): def assertComputerBangSimulator(self, args, kwargs):
stored = eval(open(self.computer_bang_simulator).read()) stored = eval(open(self.computer_bang_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['comment'] = kwargs.pop('comment') kwargs['comment'] = kwargs.pop('comment')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -2800,7 +2800,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2800,7 +2800,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceBangSimulator(self, args, kwargs): def assertInstanceBangSimulator(self, args, kwargs):
stored = eval(open(self.instance_bang_simulator).read()) stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['comment'] = kwargs.pop('comment') kwargs['comment'] = kwargs.pop('comment')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -2860,7 +2860,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2860,7 +2860,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
os.unlink(self.instance_bang_simulator) os.unlink(self.instance_bang_simulator)
def assertInstanceRenameSimulator(self, args, kwargs): def assertInstanceRenameSimulator(self, args, kwargs):
stored = eval(open(self.instance_rename_simulator).read()) stored = eval(open(self.instance_rename_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -2887,7 +2887,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2887,7 +2887,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
os.unlink(self.instance_rename_simulator) os.unlink(self.instance_rename_simulator)
def assertInstanceRequestSimulator(self, args, kwargs): def assertInstanceRequestSimulator(self, args, kwargs):
stored = eval(open(self.instance_request_simulator).read()) stored = eval(open(self.instance_request_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -3044,7 +3044,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3044,7 +3044,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
got_xml.split('\n'))])) got_xml.split('\n'))]))
def assertSupplySimulator(self, args, kwargs): def assertSupplySimulator(self, args, kwargs):
stored = eval(open(self.computer_supply_simulator).read()) stored = eval(open(self.computer_supply_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['software_release_url'] = kwargs.pop('software_release_url') kwargs['software_release_url'] = kwargs.pop('software_release_url')
kwargs['state'] = kwargs.pop('state') kwargs['state'] = kwargs.pop('state')
...@@ -3072,7 +3072,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3072,7 +3072,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
os.unlink(self.computer_supply_simulator) os.unlink(self.computer_supply_simulator)
def assertRequestComputerSimulator(self, args, kwargs): def assertRequestComputerSimulator(self, args, kwargs):
stored = eval(open(self.computer_request_computer_simulator).read()) stored = eval(open(self.computer_request_computer_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
kwargs['computer_title'] = kwargs.pop('computer_title') kwargs['computer_title'] = kwargs.pop('computer_title')
self.assertEqual(stored, self.assertEqual(stored,
...@@ -3121,7 +3121,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3121,7 +3121,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
os.unlink(self.computer_request_computer_simulator) os.unlink(self.computer_request_computer_simulator)
def assertGenerateComputerCertificateSimulator(self, args, kwargs): def assertGenerateComputerCertificateSimulator(self, args, kwargs):
stored = eval(open(self.generate_computer_certificate_simulator).read()) stored = eval(open(self.generate_computer_certificate_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
...@@ -3168,7 +3168,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3168,7 +3168,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
os.unlink(self.generate_computer_certificate_simulator) os.unlink(self.generate_computer_certificate_simulator)
def assertRevokeComputerCertificateSimulator(self, args, kwargs): def assertRevokeComputerCertificateSimulator(self, args, kwargs):
stored = eval(open(self.revoke_computer_certificate_simulator).read()) stored = eval(open(self.revoke_computer_certificate_simulator).read()) #pylint: disable=eval-used
# do the same translation magic as in workflow # do the same translation magic as in workflow
self.assertEqual(stored, self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs, [{'recargs': args, 'reckwargs': kwargs,
......
...@@ -45,24 +45,7 @@ ...@@ -45,24 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 28, 10: Use of eval (eval-used)</string>
<string>W:545, 13: Use of eval (eval-used)</string>
<string>W:602, 13: Use of eval (eval-used)</string>
<string>W:851, 13: Use of eval (eval-used)</string>
<string>W:1480, 13: Use of eval (eval-used)</string>
<string>W:1689, 13: Use of eval (eval-used)</string>
<string>W:1749, 13: Use of eval (eval-used)</string>
<string>W:1789, 13: Use of eval (eval-used)</string>
<string>W:2396, 13: Use of eval (eval-used)</string>
<string>W:2803, 13: Use of eval (eval-used)</string>
<string>W:2863, 13: Use of eval (eval-used)</string>
<string>W:2890, 13: Use of eval (eval-used)</string>
<string>W:3047, 13: Use of eval (eval-used)</string>
<string>W:3075, 13: Use of eval (eval-used)</string>
<string>W:3124, 13: Use of eval (eval-used)</string>
<string>W:3171, 13: Use of eval (eval-used)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -22,8 +22,8 @@ def Base_instanceXmlToDict(self, xml): ...@@ -22,8 +22,8 @@ def Base_instanceXmlToDict(self, xml):
else: else:
value = element.text value = element.text
result_dict[key] = value result_dict[key] = value
except (etree.XMLSchemaError, etree.XMLSchemaParseError, except (etree.XMLSchemaError, etree.XMLSchemaParseError, #pylint: disable=catching-non-exception
etree.XMLSchemaValidateError, etree.XMLSyntaxError): etree.XMLSchemaValidateError, etree.XMLSyntaxError): #pylint: disable=catching-non-exception
LOG('SubscriptionRequest', INFO, 'Issue during parsing xml:', error=True) LOG('SubscriptionRequest', INFO, 'Issue during parsing xml:', error=True)
return result_dict return result_dict
......
...@@ -31,7 +31,6 @@ subscription_request = context.subscription_request_module.newContent( ...@@ -31,7 +31,6 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request.setDefaultEmailText(email) subscription_request.setDefaultEmailText(email)
def wrapWithShadow(subscription_request, amount, subscription_reference, subscription_request_id): def wrapWithShadow(subscription_request, amount, subscription_reference, subscription_request_id):
subscription_request.activate(tag="subscription_condition_%s" % subscription_request_id subscription_request.activate(tag="subscription_condition_%s" % subscription_request_id
).SubscriptionRequest_applyCondition(subscription_reference, target_language) ).SubscriptionRequest_applyCondition(subscription_reference, target_language)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>email, subscription_reference, confirmation_required=False, user_input_dict={}, target_language=None, batch_mode=True, REQUEST=None</string> </value> <value> <string>email, subscription_reference, confirmation_required=False, user_input_dict=None, target_language=None, batch_mode=True, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
from zExceptions import Unauthorized from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
pass #raise Unauthorized raise Unauthorized
portal = context.getObject() portal = context.getObject()
......
...@@ -6,6 +6,9 @@ if REQUEST is not None: ...@@ -6,6 +6,9 @@ if REQUEST is not None:
portal = context.getPortalObject() portal = context.getPortalObject()
if user_input_dict is None:
user_input_dict = {}
if context.getValidationState() not in ["validated", "published"]: if context.getValidationState() not in ["validated", "published"]:
raise ValueError("This Trial Condition isn't validated.") raise ValueError("This Trial Condition isn't validated.")
......
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