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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
86882101
Commit
86882101
authored
Jul 04, 2024
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_service: add ftp connector
only support putFile
parent
68c77afb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
255 additions
and
5 deletions
+255
-5
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
...plateItem/portal_components/document.erp5.FTPConnector.py
+21
-3
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.xml
...lateItem/portal_components/document.erp5.FTPConnector.xml
+6
-0
bt5/erp5_web_service/ModuleComponentTemplateItem/portal_components/module.erp5.FTPConnection.py
...mplateItem/portal_components/module.erp5.FTPConnection.py
+112
-0
bt5/erp5_web_service/ModuleComponentTemplateItem/portal_components/module.erp5.FTPConnection.xml
...plateItem/portal_components/module.erp5.FTPConnection.xml
+112
-0
bt5/erp5_web_service/ToolComponentTemplateItem/portal_components/tool.erp5.WebServiceTool.py
...emplateItem/portal_components/tool.erp5.WebServiceTool.py
+1
-0
bt5/erp5_web_service/bt/template_module_component_id_list
bt5/erp5_web_service/bt/template_module_component_id_list
+3
-2
No files found.
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
View file @
86882101
...
@@ -66,8 +66,12 @@ class FTPConnector(XMLObject):
...
@@ -66,8 +66,12 @@ class FTPConnector(XMLObject):
},
},
)
)
else
:
else
:
# XXX Must manage in the future ftp and ftps protocol
return
self
.
getPortalObject
().
portal_web_services
.
connect
(
raise
NotImplementedError
(
"Protocol %s is not yet implemented"
%
(
self
.
getUrlProtocol
(),))
user_name
=
self
.
getUserId
(),
password
=
self
.
getPassword
(),
url
=
self
.
getUrlString
(),
transport
=
self
.
getUrlProtocol
()
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'renameFile'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'renameFile'
)
def
renameFile
(
self
,
old_path
,
new_path
):
def
renameFile
(
self
,
old_path
,
new_path
):
...
@@ -155,4 +159,18 @@ class FTPConnector(XMLObject):
...
@@ -155,4 +159,18 @@ class FTPConnector(XMLObject):
try
:
try
:
conn
.
removeDirectory
(
path
)
conn
.
removeDirectory
(
path
)
finally
:
finally
:
conn
.
logout
()
conn
.
logout
()
\ No newline at end of file
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'checkConnection'
)
def
checkConnection
(
self
):
conn
=
None
try
:
conn
=
self
.
getConnection
()
return
True
except
Exception
:
return
False
finally
:
if
conn
:
conn
.
logout
()
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.xml
View file @
86882101
...
@@ -10,6 +10,12 @@
...
@@ -10,6 +10,12 @@
<key>
<string>
default_reference
</string>
</key>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
FTPConnector
</string>
</value>
<value>
<string>
FTPConnector
</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>
document.erp5.FTPConnector
</string>
</value>
<value>
<string>
document.erp5.FTPConnector
</string>
</value>
...
...
bt5/erp5_web_service/ModuleComponentTemplateItem/portal_components/module.erp5.FTPConnection.py
0 → 100644
View file @
86882101
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2013 Nexedi SARL and Contributors. All Rights Reserved.
# Aurélien Calonne <aurel@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
os
from
urlparse
import
urlparse
from
xmlrpclib
import
Binary
from
cStringIO
import
StringIO
from
ftplib
import
FTP
from
zLOG
import
LOG
class
FTPError
(
Exception
):
"""
Default exception for the connection
"""
pass
class
FTPConnection
:
"""
Handle a FTP Connection
"""
def
__init__
(
self
,
url
,
user_name
,
password
=
None
,
bind_address
=
None
):
self
.
url
=
url
self
.
user_name
=
user_name
self
.
password
=
password
self
.
bind_address
=
bind_address
def
connect
(
self
):
# Check URL
schema
=
urlparse
(
self
.
url
)
if
schema
.
scheme
==
'ftp'
:
hostname
=
schema
.
hostname
port
=
int
(
schema
.
port
)
self
.
ftp
=
FTP
()
else
:
raise
FTPError
(
'Not a valid ftp url %s, type is %s'
%
(
self
.
url
,
schema
.
scheme
))
try
:
self
.
ftp
.
connect
(
hostname
,
port
)
self
.
ftp
.
login
(
self
.
user_name
,
self
.
password
)
except
Exception
as
msg
:
raise
FTPError
(
str
(
msg
)
+
' while establishing connection to %s'
%
(
self
.
url
,))
return
self
def
writeFile
(
self
,
path
,
filename
,
data
,
confirm
=
True
):
"""
Write data in provided filepath
"""
filepath
=
os
.
path
.
join
(
path
,
filename
)
serialized_data
=
Binary
(
str
(
data
))
LOG
(
'write file'
,
0
,
filepath
)
try
:
self
.
ftp
.
storbinary
(
'STOR '
+
filepath
,
StringIO
(
str
(
serialized_data
)))
except
Exception
as
msg
:
raise
FTPError
(
str
(
msg
)
+
' while writing file %s on %s'
%
(
filepath
,
path
))
def
_getFile
(
self
,
filepath
):
pass
def
readBinaryFile
(
self
,
filepath
):
pass
def
readAsciiFile
(
self
,
filepath
):
pass
def
getDirectoryContent
(
self
,
path
,
sort_on
=
None
):
pass
def
getDirectoryFileList
(
self
,
path
):
pass
def
removeFile
(
self
,
filepath
):
pass
def
renameFile
(
self
,
old_path
,
new_path
):
pass
def
createDirectory
(
self
,
path
,
mode
=
0o777
):
pass
def
removeDirectory
(
self
,
path
):
pass
def
logout
(
self
):
self
.
ftp
.
quit
()
bt5/erp5_web_service/ModuleComponentTemplateItem/portal_components/module.erp5.FTPConnection.xml
0 → 100644
View file @
86882101
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Module Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
FTPConnection
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
module.erp5.FTPConnection
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Module Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</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>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<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>
bt5/erp5_web_service/ToolComponentTemplateItem/portal_components/tool.erp5.WebServiceTool.py
View file @
86882101
...
@@ -52,6 +52,7 @@ handler_module_dict = {
...
@@ -52,6 +52,7 @@ handler_module_dict = {
'soap'
:
'SOAPConnection'
,
'soap'
:
'SOAPConnection'
,
'soap_wsdl'
:
'SOAPWSDLConnection'
,
'soap_wsdl'
:
'SOAPWSDLConnection'
,
'sftp'
:
"SFTPConnection"
,
'sftp'
:
"SFTPConnection"
,
'ftp'
:
"FTPConnection"
,
'sql'
:
"SQLConnection"
,
'sql'
:
"SQLConnection"
,
'document'
:
"DocumentConnection"
,
'document'
:
"DocumentConnection"
,
}
}
...
...
bt5/erp5_web_service/bt/template_module_component_id_list
View file @
86882101
module.erp5.DocumentConnection
module.erp5.FTPConnection
module.erp5.SFTPConnection
module.erp5.SFTPConnection
module.erp5.SOAPConnection
module.erp5.SOAPConnection
module.erp5.SOAPWSDLConnection
module.erp5.SOAPWSDLConnection
module.erp5.SQLConnection
module.erp5.SQLConnection
module.erp5.XMLRPCConnection
module.erp5.XMLRPCConnection
module.erp5.DocumentConnection
\ No newline at end of file
\ No newline at end of file
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