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
a9f898c1
Commit
a9f898c1
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
52a046a9
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 @
a9f898c1
...
...
@@ -113,3 +113,25 @@ class FTPConnector(XMLObject):
conn
.
writeFile
(
remotepath
,
'%s'
%
filename
,
data
,
confirm
=
confirm
)
finally
:
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 @
a9f898c1
...
...
@@ -92,6 +92,12 @@ class TestSFTPConnection(ERP5TypeTestCase):
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
:
def
test_no_SFTP_URL_in_environ
(
self
):
raise
unittest
.
SkipTest
(
...
...
product/ERP5Type/ConnectionPlugin/SFTPConnection.py
View file @
a9f898c1
...
...
@@ -171,6 +171,16 @@ class SFTPConnection:
raise
SFTPError
(
'%s while trying to rename "%s" to "%s" on %s.'
%
\
(
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
):
"""Logout of the SFTP Server"""
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