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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
2781646f
Commit
2781646f
authored
Sep 26, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web_service: support createDirectory / removeDirectory for sFTP
parent
2c550420
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
...plateItem/portal_components/document.erp5.FTPConnector.py
+22
-0
bt5/erp5_web_service/TestTemplateItem/portal_components/test.erp5.testFTPConnection.py
...lateItem/portal_components/test.erp5.testFTPConnection.py
+6
-0
product/ERP5Type/ConnectionPlugin/SFTPConnection.py
product/ERP5Type/ConnectionPlugin/SFTPConnection.py
+10
-0
No files found.
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
View file @
2781646f
...
@@ -112,3 +112,25 @@ class FTPConnector(XMLObject):
...
@@ -112,3 +112,25 @@ class FTPConnector(XMLObject):
conn
.
writeFile
(
remotepath
,
'%s'
%
filename
,
data
,
confirm
=
confirm
)
conn
.
writeFile
(
remotepath
,
'%s'
%
filename
,
data
,
confirm
=
confirm
)
finally
:
finally
:
conn
.
logout
()
conn
.
logout
()
def
createDirectory
(
self
,
path
,
mode
=
0777
):
"""Create a directory `path`, with file mode `mode`.
The directory is created immediatly, even if transaction is aborted.
"""
conn
=
self
.
getConnection
()
try
:
conn
.
createDirectory
(
path
,
mode
)
finally
:
conn
.
logout
()
def
removeDirectory
(
self
,
path
):
"""Create a directory `path`, with file mode `mode`.
The directory is removed immediatly, even if transaction is aborted.
"""
conn
=
self
.
getConnection
()
try
:
conn
.
removeDirectory
(
path
)
finally
:
conn
.
logout
()
\ No newline at end of file
bt5/erp5_web_service/TestTemplateItem/portal_components/test.erp5.testFTPConnection.py
View file @
2781646f
...
@@ -92,6 +92,12 @@ class TestSFTPConnection(ERP5TypeTestCase):
...
@@ -92,6 +92,12 @@ class TestSFTPConnection(ERP5TypeTestCase):
self
.
connection
.
listFiles
(
"."
,
sort_on
=
"st_size"
)
self
.
connection
.
listFiles
(
"."
,
sort_on
=
"st_size"
)
)
)
def
test_create_remove_directory
(
self
):
self
.
connection
.
createDirectory
(
"foo"
)
self
.
assertItemsEqual
([
"foo"
],
self
.
connection
.
listFiles
(
"."
))
self
.
connection
.
removeDirectory
(
"foo"
)
self
.
assertItemsEqual
([],
self
.
connection
.
listFiles
(
"."
))
else
:
else
:
def
test_no_SFTP_URL_in_environ
(
self
):
def
test_no_SFTP_URL_in_environ
(
self
):
raise
unittest
.
SkipTest
(
raise
unittest
.
SkipTest
(
...
...
product/ERP5Type/ConnectionPlugin/SFTPConnection.py
View file @
2781646f
...
@@ -171,6 +171,16 @@ class SFTPConnection:
...
@@ -171,6 +171,16 @@ class SFTPConnection:
raise
SFTPError
(
'%s while trying to rename "%s" to "%s" on %s.'
%
\
raise
SFTPError
(
'%s while trying to rename "%s" to "%s" on %s.'
%
\
(
str
(
msg
),
old_path
,
new_path
,
self
.
url
))
(
str
(
msg
),
old_path
,
new_path
,
self
.
url
))
def
createDirectory
(
self
,
path
,
mode
=
0777
):
"""Create a directory `path` with mode `mode`.
"""
return
self
.
conn
.
mkdir
(
path
,
mode
)
def
removeDirectory
(
self
,
path
):
"""Remove directory `path`.
"""
return
self
.
conn
.
rmdir
(
path
)
def
logout
(
self
):
def
logout
(
self
):
"""Logout of the SFTP Server"""
"""Logout of the SFTP Server"""
self
.
conn
.
close
()
self
.
conn
.
close
()
...
...
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