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