Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
a0047b4a
Commit
a0047b4a
authored
Apr 21, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syncml: pylint for py3
parent
01a47287
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
105 additions
and
110 deletions
+105
-110
bt5/erp5_syncml/DocumentTemplateItem/portal_components/document.erp5.SyncMLSubscription.py
...tem/portal_components/document.erp5.SyncMLSubscription.py
+1
-1
bt5/erp5_syncml/MixinTemplateItem/portal_components/mixin.erp5.SyncMLEngineMixin.py
...ateItem/portal_components/mixin.erp5.SyncMLEngineMixin.py
+4
-5
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.BaseConduit.py
...TemplateItem/portal_components/module.erp5.BaseConduit.py
+0
-1
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.ERP5Conduit.py
...TemplateItem/portal_components/module.erp5.ERP5Conduit.py
+3
-5
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLEngineAsynchronous.py
...portal_components/module.erp5.SyncMLEngineAsynchronous.py
+1
-1
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLMessage.py
...mplateItem/portal_components/module.erp5.SyncMLMessage.py
+88
-90
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportFile.py
...Item/portal_components/module.erp5.SyncMLTransportFile.py
+2
-2
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportHTTP.py
...Item/portal_components/module.erp5.SyncMLTransportHTTP.py
+1
-1
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportMail.py
...Item/portal_components/module.erp5.SyncMLTransportMail.py
+2
-2
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.VCardConduit.py
...emplateItem/portal_components/module.erp5.VCardConduit.py
+1
-1
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.XupdateUtils.py
...emplateItem/portal_components/module.erp5.XupdateUtils.py
+2
-1
No files found.
bt5/erp5_syncml/DocumentTemplateItem/portal_components/document.erp5.SyncMLSubscription.py
View file @
a0047b4a
...
...
@@ -541,7 +541,7 @@ class SyncMLSubscription(XMLObject):
xml_document = etree.tostring(xml_document, encoding='utf-8',
pretty_print=True)
if six.PY2 and isinstance(xml_document,
unicod
e):
if six.PY2 and isinstance(xml_document,
six.text_typ
e):
xml_document = xml_document.encode('utf-8')
# Link the signature to the document
if signature:
...
...
bt5/erp5_syncml/MixinTemplateItem/portal_components/mixin.erp5.SyncMLEngineMixin.py
View file @
a0047b4a
...
...
@@ -76,11 +76,10 @@ class SyncMLEngineMixin(object):
status
[
'authentication_type'
]))
# XXX Not working To Review !
raise
NotImplementedError
(
"Adding credentials"
)
"""
syncml_response = domain.generateBaseResponse()
syncml_response.addCredentialMessage(domain)
return syncml_response
"""
# syncml_response = domain.generateBaseResponse()
# syncml_response.addCredentialMessage(domain)
# return syncml_response
elif
status
[
'status_code'
]
==
\
resolveSyncmlStatusCode
(
'invalid_credentials'
):
syncml_logger
.
error
(
"
\
t
Client authentication refused"
)
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.BaseConduit.py
View file @
a0047b4a
...
...
@@ -92,5 +92,4 @@ class BaseConduit(object):
Method called when update command is received
XXX It should returns the list of conflicts ?
"""
pass
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.ERP5Conduit.py
View file @
a0047b4a
...
...
@@ -489,9 +489,8 @@ class ERP5Conduit(XMLSyncUtilsMixin):
first_object = False
elif sub_context is not None:
context = sub_context
else:
#
else:
# Ignore non existing objects
pass
#LOG('ERP5Conduit', INFO, 'sub document of %s not found with id:%r'%
\
#(context.getPath(), sub_context_id))
xpath = xpath.replace(object_block, '', 1)
...
...
@@ -694,7 +693,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
def afterNewObject(self, object): # pylint: disable=redefined-builtin
"""
Overloadable
method
"""
pass
security.declareProtected(Permissions.AccessContentsInformation,
'getStatusFromXml')
...
...
@@ -855,7 +853,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if xupdated_node_list:
xupdated_node = xupdated_node_list[0]
else:
ValueError('Wrong xpath expression:%r' % base_xpath_expression)
raise
ValueError('Wrong xpath expression:%r' % base_xpath_expression)
if base_xpath_expression not in xpath_expression_update_dict:
xpath_expression_update_dict[base_xpath_expression] =
\
dict(xml=xupdated_node,
...
...
@@ -875,7 +873,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if xupdated_node_list:
xupdated_node = xupdated_node_list[0]
else:
ValueError('Wrong xpath expression:%r' % base_xpath_expression)
raise
ValueError('Wrong xpath expression:%r' % base_xpath_expression)
if base_xpath_expression not in xpath_expression_update_dict:
xpath_expression_update_dict[base_xpath_expression] =
\
dict(xml=xupdated_node,
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLEngineAsynchronous.py
View file @
a0047b4a
...
...
@@ -145,7 +145,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin):
"""
Process the package 4 of the SyncML DS exchange
"""
if
False
:
if
False
:
# pylint:disable=using-constant-test
pass
# not subscriber.checkCorrectRemoteMessageId(
# syncml_request.header['message_id']):
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLMessage.py
View file @
a0047b4a
...
...
@@ -225,41 +225,41 @@ class SyncMLResponse(object):
receiving a challenge message
"""
raise
NotImplementedError
(
"To review"
)
"""
# create element 'SyncML' with a default namespace
xml = E.SyncML()
# syncml header
xml.append(self.buildHeader(
session_id=subscription.incrementSessionId(),
msg_id=subscription.incrementMessageId(),
target=subscription.getUrlString(),
source=subscription.getSubscriptionUrlString(),
user_id=subscription.getUserId(),
password=subscription.getPassword(),
authentication_format=subscription.getAuthenticationFormat(),
authentication_type=subscription.getAuthenticationType()))
# Build the message body
sync_body = E.SyncBody()
# alert message
sync_body.append(self.buildAlertMessage(
command_id=self._getNextCommandId(),
alert_code=subscription.getSyncmlAlertCode(),
target=subscription.getDestinationReference(),
source=subscription.getSourceReference(),
last_anchor=subscription.getLastAnchor(),
next_anchor=subscription.getNextAnchor()))
syncml_put = self.buildPutMessage(subscription)
if syncml_put is not None:
sync_body.append(syncml_put)
sync_body.append(E.Final())
xml.append(sync_body)
xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
pretty_print=True)
self.data_append(xml_string)
"""
#
# create element 'SyncML' with a default namespace
#
xml = E.SyncML()
#
# syncml header
#
xml.append(self.buildHeader(
#
session_id=subscription.incrementSessionId(),
#
msg_id=subscription.incrementMessageId(),
#
target=subscription.getUrlString(),
#
source=subscription.getSubscriptionUrlString(),
#
user_id=subscription.getUserId(),
#
password=subscription.getPassword(),
#
authentication_format=subscription.getAuthenticationFormat(),
#
authentication_type=subscription.getAuthenticationType()))
#
#
# Build the message body
#
sync_body = E.SyncBody()
#
#
# alert message
#
sync_body.append(self.buildAlertMessage(
#
command_id=self._getNextCommandId(),
#
alert_code=subscription.getSyncmlAlertCode(),
#
target=subscription.getDestinationReference(),
#
source=subscription.getSourceReference(),
#
last_anchor=subscription.getLastAnchor(),
#
next_anchor=subscription.getNextAnchor()))
#
syncml_put = self.buildPutMessage(subscription)
#
if syncml_put is not None:
#
sync_body.append(syncml_put)
#
sync_body.append(E.Final())
#
#
xml.append(sync_body)
#
xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
#
pretty_print=True)
#
self.data_append(xml_string)
def
addPutMessage
(
self
,
subscription
,
markup
=
'Put'
,
cmd_ref
=
None
,
message_id
=
None
):
...
...
@@ -280,61 +280,59 @@ class SyncMLResponse(object):
Both must be able to handle and process these informations
"""
return
"""
# XXX-Aurel : must be reviewed according to specification
# This part can be skipped for now
conduit = subscription.getConduit()
xml = None
# The conduit defined what capabilities the service offers
if getattr(conduit, 'getCapabilitiesCTTypeList', None) and
\
getattr(conduit, 'getCapabilitiesVerCTList', None) and
\
getattr(conduit, 'getPreferedCapabilitieVerCT', None):
xml = Element('{%s}%s' % (SYNCML_NAMESPACE, markup))
xml.append(E.CmdID(self._getNextCommandId()))
if message_id:
xml.append(E.MsgRef('%s' % message_id))
if cmd_ref:
xml.append(E.CmdRef('%s' % cmd_ref))
xml.extend((E.Meta(E.Type('application/vnd.syncml-devinf+xml')),
E.Item(E.Source(E.LocURI('./devinf12')),
E.Data(E.DevInf(E.VerDTD('1.2'),
E.Man('Nexedi'),
E.Mod('ERP5SyncML'),
E.OEM('Open Source'),
E.SwV('0.1'),
E.DevID(subscription.getSubscriptionUrlString()),
E.DevTyp('workstation'),
E.UTC(),
E.DataStore(E.SourceRef(subscription.getSourceReference()))
)
)
)))
data_store = xml.find('{%(ns)s}Item/{%(ns)s}Data/{%(ns)s}DevInf/{%(ns)s}DataStore' % {'ns': SYNCML_NAMESPACE})
tx_element_list = []
rx_element_list = []
for cttype in conduit.getCapabilitiesCTTypeList():
if cttype != 'text/xml':
for x_version in conduit.getCapabilitiesVerCTList(cttype):
rx_element_list.append(E.Rx(E.CTType(cttype), E.VerCT(x_version)))
tx_element_list.append(E.Tx(E.CTType(cttype), E.VerCT(x_version)))
rx_pref = Element('{%s}Rx-Pref' % SYNCML_NAMESPACE)
rx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
E.VerCT(conduit.getPreferedCapabilitieVerCT())))
data_store.append(rx_pref)
data_store.extend(rx_element_list)
tx_pref = Element('{%s}Tx-Pref' % SYNCML_NAMESPACE)
tx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
E.VerCT(conduit.getPreferedCapabilitieVerCT())))
data_store.append(tx_pref)
data_store.extend(tx_element_list)
data_store.append(E.SyncCap(
E.SyncType('2'),
E.SyncType('1'),
E.SyncType('4'),
E.SyncType('6')
))
self.data_append(xml)
"""
# # XXX-Aurel : must be reviewed according to specification
# # This part can be skipped for now
# conduit = subscription.getConduit()
# xml = None
# # The conduit defined what capabilities the service offers
# if getattr(conduit, 'getCapabilitiesCTTypeList', None) and \
# getattr(conduit, 'getCapabilitiesVerCTList', None) and \
# getattr(conduit, 'getPreferedCapabilitieVerCT', None):
# xml = Element('{%s}%s' % (SYNCML_NAMESPACE, markup))
# xml.append(E.CmdID(self._getNextCommandId()))
# if message_id:
# xml.append(E.MsgRef('%s' % message_id))
# if cmd_ref:
# xml.append(E.CmdRef('%s' % cmd_ref))
# xml.extend((E.Meta(E.Type('application/vnd.syncml-devinf+xml')),
# E.Item(E.Source(E.LocURI('./devinf12')),
# E.Data(E.DevInf(E.VerDTD('1.2'),
# E.Man('Nexedi'),
# E.Mod('ERP5SyncML'),
# E.OEM('Open Source'),
# E.SwV('0.1'),
# E.DevID(subscription.getSubscriptionUrlString()),
# E.DevTyp('workstation'),
# E.UTC(),
# E.DataStore(E.SourceRef(subscription.getSourceReference()))
# )
# )
# )))
# data_store = xml.find('{%(ns)s}Item/{%(ns)s}Data/{%(ns)s}DevInf/{%(ns)s}DataStore' % {'ns': SYNCML_NAMESPACE})
# tx_element_list = []
# rx_element_list = []
# for cttype in conduit.getCapabilitiesCTTypeList():
# if cttype != 'text/xml':
# for x_version in conduit.getCapabilitiesVerCTList(cttype):
# rx_element_list.append(E.Rx(E.CTType(cttype), E.VerCT(x_version)))
# tx_element_list.append(E.Tx(E.CTType(cttype), E.VerCT(x_version)))
# rx_pref = Element('{%s}Rx-Pref' % SYNCML_NAMESPACE)
# rx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
# E.VerCT(conduit.getPreferedCapabilitieVerCT())))
# data_store.append(rx_pref)
# data_store.extend(rx_element_list)
# tx_pref = Element('{%s}Tx-Pref' % SYNCML_NAMESPACE)
# tx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
# E.VerCT(conduit.getPreferedCapabilitieVerCT())))
# data_store.append(tx_pref)
# data_store.extend(tx_element_list)
# data_store.append(E.SyncCap(
# E.SyncType('2'),
# E.SyncType('1'),
# E.SyncType('4'),
# E.SyncType('6')
# ))
# self.data_append(xml)
def
addSyncCommand
(
self
,
sync_command
,
gid
,
data
,
media_type
,
more_data
):
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportFile.py
View file @
a0047b4a
...
...
@@ -25,7 +25,7 @@
#
##############################################################################
from
erp5.component.module.SyncMLTransportHTTP
import
ConnectionError
from
erp5.component.module.SyncMLTransportHTTP
import
ConnectionError
as
_ConnectionError
class
FileTransport
:
...
...
@@ -35,4 +35,4 @@ class FileTransport:
with
open
(
filename
,
'wb'
)
as
stream
:
stream
.
write
(
data
)
except
IOError
:
raise
ConnectionError
raise
_
ConnectionError
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportHTTP.py
View file @
a0047b4a
...
...
@@ -31,7 +31,7 @@ from requests import post
syncml_logger
=
getLogger
(
'ERP5SyncML'
)
class
ConnectionError
(
Exception
):
class
ConnectionError
(
Exception
):
# pylint:disable=redefined-builtin
pass
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.SyncMLTransportMail.py
View file @
a0047b4a
...
...
@@ -25,7 +25,7 @@
#
##############################################################################
from
erp5.component.module.SyncMLTransportHTTP
import
ConnectionError
from
erp5.component.module.SyncMLTransportHTTP
import
ConnectionError
as
_ConnectionError
from
Products.ERP5.ERP5Site
import
getSite
class
MailTransport
:
...
...
@@ -36,4 +36,4 @@ class MailTransport:
try
:
getSite
().
sendMail
(
from_address
,
to_address
,
sync_id
,
xml
)
except
:
raise
ConnectionError
raise
_
ConnectionError
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.VCardConduit.py
View file @
a0047b4a
...
...
@@ -141,7 +141,7 @@ class VCardConduit(ERP5Conduit):
property_value_list_well_incoded
=
[]
if
encoding
==
'QUOTED-PRINTABLE'
:
import
mimify
import
mimify
# pylint:disable=import-error
for
property_value
in
property_value_list
:
property_value
=
mimify
.
mime_decode
(
property_value
)
property_value_list_well_incoded
.
append
(
property_value
)
...
...
bt5/erp5_syncml/ModuleComponentTemplateItem/portal_components/module.erp5.XupdateUtils.py
View file @
a0047b4a
...
...
@@ -26,6 +26,7 @@
#
##############################################################################
import
six
from
erp5.component.module.XMLSyncUtils
import
XMLSyncUtilsMixin
from
xml.dom.ext.reader.Sax2
import
FromXml
# pylint:disable=no-name-in-module,import-error
...
...
@@ -40,7 +41,7 @@ class XupdateUtils(XMLSyncUtilsMixin):
Parse the xupdate and then it will call the conduit
"""
conflict_list
=
[]
if
isinstance
(
xupdate
,
(
str
,
unicode
)
):
if
isinstance
(
xupdate
,
six
.
string_types
):
xupdate
=
FromXml
(
xupdate
)
for
subnode
in
xupdate
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment