Commit b790643e authored by Jérome Perrin's avatar Jérome Perrin

py3: 2to3 -j 20 --write --nobackups --no-diffs --fix=has_key master

parent e5fd9154
...@@ -44,7 +44,7 @@ length = context.getArrayShape()[0] ...@@ -44,7 +44,7 @@ length = context.getArrayShape()[0]
# never access more than 1000 lines at once # never access more than 1000 lines at once
list_lines = min(list_lines, limit, 1000) list_lines = min(list_lines, limit, 1000)
if context.REQUEST.has_key("limit"): if "limit" in context.REQUEST:
list_start = limit[0] list_start = limit[0]
list_lines = limit[1] - limit[0] list_lines = limit[1] - limit[0]
......
...@@ -308,10 +308,10 @@ class SlapOSComputeNodeMixin(object): ...@@ -308,10 +308,10 @@ class SlapOSComputeNodeMixin(object):
parameter_dict.pop('filter_xml')) parameter_dict.pop('filter_xml'))
partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid') partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid')
for slave_instance_dict in parameter_dict.get("slave_instance_list", []): for slave_instance_dict in parameter_dict.get("slave_instance_list", []):
if slave_instance_dict.has_key("connection_xml"): if "connection_xml" in slave_instance_dict:
slave_instance_dict.update(self._instanceXmlToDict( slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("connection_xml"))) slave_instance_dict.pop("connection_xml")))
if slave_instance_dict.has_key("xml"): if "xml" in slave_instance_dict:
slave_instance_dict.update(self._instanceXmlToDict( slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("xml"))) slave_instance_dict.pop("xml")))
partition_dict['_parameter_dict'].update(parameter_dict) partition_dict['_parameter_dict'].update(parameter_dict)
......
...@@ -129,13 +129,13 @@ class SlapOSComputePartitionMixin(object): ...@@ -129,13 +129,13 @@ class SlapOSComputePartitionMixin(object):
parameter_dict.pop('filter_xml')) parameter_dict.pop('filter_xml'))
partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid') partition_dict['_instance_guid'] = parameter_dict.pop('instance_guid')
for slave_instance_dict in parameter_dict.get("slave_instance_list", []): for slave_instance_dict in parameter_dict.get("slave_instance_list", []):
if slave_instance_dict.has_key("connection_xml"): if "connection_xml" in slave_instance_dict:
connection_dict = software_instance._instanceXmlToDict( connection_dict = software_instance._instanceXmlToDict(
slave_instance_dict.pop("connection_xml")) slave_instance_dict.pop("connection_xml"))
slave_instance_dict.update(connection_dict) slave_instance_dict.update(connection_dict)
slave_instance_dict['connection-parameter-hash'] = \ slave_instance_dict['connection-parameter-hash'] = \
calculate_dict_hash(connection_dict) calculate_dict_hash(connection_dict)
if slave_instance_dict.has_key("xml"): if "xml" in slave_instance_dict:
slave_instance_dict.update(software_instance._instanceXmlToDict( slave_instance_dict.update(software_instance._instanceXmlToDict(
slave_instance_dict.pop("xml"))) slave_instance_dict.pop("xml")))
partition_dict['_parameter_dict'].update(parameter_dict) partition_dict['_parameter_dict'].update(parameter_dict)
......
...@@ -11,7 +11,7 @@ message_dict = context.getAccessStatus() ...@@ -11,7 +11,7 @@ message_dict = context.getAccessStatus()
if message_dict.get("no_data", None) == 1: if message_dict.get("no_data", None) == 1:
message_dict = {} message_dict = {}
if message_dict.has_key('created_at'): if 'created_at' in message_dict:
contact_date = DateTime(message_dict.get('created_at').encode('utf-8')) contact_date = DateTime(message_dict.get('created_at').encode('utf-8'))
return (now_date - contact_date) < maximum_days return (now_date - contact_date) < maximum_days
......
...@@ -29,9 +29,9 @@ parameter_dict = instance.getConnectionXmlAsDict() ...@@ -29,9 +29,9 @@ parameter_dict = instance.getConnectionXmlAsDict()
url_string = parameter_dict.get('monitor-setup-url', '') url_string = parameter_dict.get('monitor-setup-url', '')
if url_string: if url_string:
if parameter_dict.has_key('monitor-user') and \ if 'monitor-user' in parameter_dict and \
parameter_dict.has_key('monitor-password') and \ 'monitor-password' in parameter_dict and \
parameter_dict.has_key('monitor-base-url'): 'monitor-base-url' in parameter_dict:
username = parameter_dict.get('monitor-user') username = parameter_dict.get('monitor-user')
password = parameter_dict.get('monitor-password') password = parameter_dict.get('monitor-password')
url = parameter_dict.get('monitor-base-url') + '/public/feeds' url = parameter_dict.get('monitor-base-url') + '/public/feeds'
......
...@@ -26,7 +26,7 @@ current_username = context.getPortalObject().portal_membership.getAuthenticatedM ...@@ -26,7 +26,7 @@ current_username = context.getPortalObject().portal_membership.getAuthenticatedM
if current_username == original_login: if current_username == original_login:
# We should logout immediately # We should logout immediately
if context.REQUEST.has_key('portal_skin'): if 'portal_skin' in context.REQUEST:
context.portal_skins.clearSkinCookie() context.portal_skins.clearSkinCookie()
context.REQUEST.RESPONSE.expireCookie('__ac', path='/') context.REQUEST.RESPONSE.expireCookie('__ac', path='/')
context.REQUEST.RESPONSE.expireCookie('__ac_google_hash', path='/') context.REQUEST.RESPONSE.expireCookie('__ac_google_hash', path='/')
......
...@@ -46,9 +46,9 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -46,9 +46,9 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
return '' return ''
if context.getPortalType() in ["Software Instance", "Slave Instance"]: if context.getPortalType() in ["Software Instance", "Slave Instance"]:
connection = context.getConnectionXmlAsDict() connection = context.getConnectionXmlAsDict()
if connection and connection.has_key('monitor-user') and \ if connection and 'monitor-user' in connection and \
connection.has_key('monitor-password') and \ 'monitor-password' in connection and \
connection.has_key('monitor-base-url'): 'monitor-base-url' in connection:
return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20title%3A%22Template%20Software%20Instance%22%20AND%20specialise_title%3A%22Template%20Instance%20Tree%22' return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20title%3A%22Template%20Software%20Instance%22%20AND%20specialise_title%3A%22Template%20Instance%20Tree%22'
else: else:
return '' return ''
...@@ -56,9 +56,9 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -56,9 +56,9 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
soft_inst = context.getSuccessorValue() soft_inst = context.getSuccessorValue()
if soft_inst: if soft_inst:
connection = soft_inst.getConnectionXmlAsDict() connection = soft_inst.getConnectionXmlAsDict()
if connection and connection.has_key('monitor-user') and \ if connection and 'monitor-user' in connection and \
connection.has_key('monitor-password') and \ 'monitor-password' in connection and \
connection.has_key('monitor-base-url'): 'monitor-base-url' in connection:
return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Instance%20Tree%22%20AND%20title%3A%22Template%20Instance%20Tree%22' return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Instance%20Tree%22%20AND%20title%3A%22Template%20Instance%20Tree%22'
return '' return ''
......
...@@ -14,7 +14,7 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None): ...@@ -14,7 +14,7 @@ def compareAndUpdateAddressList(document, address_list, additional_dict=None):
to_add_ip_dict_list.remove(current_dict) to_add_ip_dict_list.remove(current_dict)
else: else:
# XXX - Only delete if Network interface are supposed to be the same # XXX - Only delete if Network interface are supposed to be the same
if additional_dict.has_key('network_interface'): if 'network_interface' in additional_dict:
if address.getNetworkInterface('') and additional_dict['network_interface'] != address.getNetworkInterface(): if address.getNetworkInterface('') and additional_dict['network_interface'] != address.getNetworkInterface():
continue continue
to_delete_ip_id_list.append(address.getId()) to_delete_ip_id_list.append(address.getId())
...@@ -94,7 +94,7 @@ for send_partition in compute_node_dict['partition_list']: ...@@ -94,7 +94,7 @@ for send_partition in compute_node_dict['partition_list']:
compareAndUpdateAddressList(partition, send_partition['address_list'], {'network_interface': network_interface}) compareAndUpdateAddressList(partition, send_partition['address_list'], {'network_interface': network_interface})
tap_addr_list = [] tap_addr_list = []
additional_dict = {'network_interface': 'route_' + network_interface} additional_dict = {'network_interface': 'route_' + network_interface}
if send_partition['tap'].has_key('ipv4_addr') and send_partition['tap']['ipv4_addr']: if 'ipv4_addr' in send_partition['tap'] and send_partition['tap']['ipv4_addr']:
tap_addr_list.append({ tap_addr_list.append({
'addr': send_partition['tap']['ipv4_addr'], 'addr': send_partition['tap']['ipv4_addr'],
'netmask': send_partition['tap']['ipv4_netmask'] 'netmask': send_partition['tap']['ipv4_netmask']
......
...@@ -128,7 +128,7 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -128,7 +128,7 @@ class testSlapOSMixin(ERP5TypeTestCase):
def isLiveTest(self): def isLiveTest(self):
#return 'ERP5TypeLiveTestCase' in [q.__name__ for q in self.__class__.mro()] #return 'ERP5TypeLiveTestCase' in [q.__name__ for q in self.__class__.mro()]
# XXX - What is the better way to know if we are in live test mode ? # XXX - What is the better way to know if we are in live test mode ?
return not os.environ.has_key('TEST_CA_PATH') return 'TEST_CA_PATH' not in os.environ
def beforeTearDown(self): def beforeTearDown(self):
if self.abort_transaction: if self.abort_transaction:
......
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