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
Thomas Gambier
erp5
Commits
8b26b05d
Commit
8b26b05d
authored
Sep 26, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
createDirectory an removeDirectory operations for sFTP
/reviewed-on
nexedi/erp5!756
parents
78e66722
2781646f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
...plateItem/portal_components/document.erp5.FTPConnector.py
+23
-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 @
8b26b05d
...
...
@@ -31,6 +31,7 @@ from AccessControl import ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
class
FTPConnector
(
XMLObject
):
# CMF Type Definition
meta_type
=
'FTP Connector'
...
...
@@ -111,3 +112,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 @
8b26b05d
...
...
@@ -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 @
8b26b05d
...
...
@@ -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