[REF] Document_ftp
bzr revid: jvo@tinyerp.com-20100927170856-cm4lt3ykxdrldmzs
This commit is contained in:
parent
fb8df7b445
commit
8234754761
|
@ -27,7 +27,7 @@
|
|||
'description': """This is a support FTP Interface with document management system.
|
||||
With this module you would not only be able to access documents through OpenERP
|
||||
but you would also be able to connect with them through the file system using the
|
||||
a FTP client.
|
||||
FTP client.
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
- |
|
||||
In order to test the document_ftp module in OpenERP, I will try different operation on the FTP interface, and check their impacts on OpenERP's documents and vice-versa.
|
||||
In order to test the document_ftp module in OpenERP, I will try different operations on the FTP interface and check their impacts on OpenERP's documents and vice-versa.
|
||||
-
|
||||
In order to test behaviour of resource Directory I will make one resource Directory "Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner"
|
||||
In order to test the behaviour of resource Directory, I will make one resource Directory "Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner"
|
||||
-
|
||||
!record {model: 'document.directory', id: dir_label}:
|
||||
name : "Labels"
|
||||
|
@ -25,20 +25,20 @@
|
|||
storage_id : document.storage_default
|
||||
type : directory
|
||||
-
|
||||
I am create a one Document name "Document" and select "File" as its Directory,
|
||||
I am create one Document name "Document" and select "File" as its Directory,
|
||||
-
|
||||
When I am creating the record then "Resource Title" is filled automatic with "Document".
|
||||
When I am creating the record, "Resource Title" is filled automatic with "Document".
|
||||
-
|
||||
!record {model: 'ir.attachment', id: document_1}:
|
||||
name : "Document"
|
||||
parent_id : directory_file
|
||||
-
|
||||
In order to connect FTP server and set "File" path.
|
||||
I create one directory "New" in "File" directory from FTP and check its effect in OpenERP
|
||||
In order to connect FTP server and set "File" path,
|
||||
I create one directory "New" in "File" directory from FTP and check its effect in OpenERP.
|
||||
-
|
||||
Also Rename the directory name "New" to "New Directory".
|
||||
-
|
||||
Remove directory "New Directory" and remove file "Document".
|
||||
Remove directory "New Directory" and remove file "Document".
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from ftplib import FTP
|
||||
|
@ -64,10 +64,10 @@
|
|||
In order to check directory created from FTP is working perfectly
|
||||
-
|
||||
Now I will test the same for Resource directory which is mapped with OpenERP object.
|
||||
When you open this directory from FTP clients, it displays each records of mapped resource object as directory.
|
||||
When you open this directory from FTP clients, it displays each record of mapped resource object as directory.
|
||||
-
|
||||
Now I test FTP client and Open the "Labels" Directory to check Resource Directory in FTP.
|
||||
I can see that all Label of OpenERP are shown as children of "Labels" in FTP client as Directories
|
||||
I can see that all Labels of OpenERP are shown as children of "Labels" in FTP client as Directories.
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from ftplib import FTP
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
|
||||
assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd'
|
||||
-
|
||||
I append the string 'defgh' into "test.txt"
|
||||
I append the string 'defgh' to "test.txt"
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
from document_ftp import test_easyftp as te
|
||||
ftp = te.get_plain_ftp(timeout=1.0)
|
||||
-
|
||||
I create in the server a folder called 'Äïêéìáóôéêüò ÖÜêåëëïò'
|
||||
I create a folder called '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' in the server.
|
||||
-
|
||||
!record {model: document.directory, id: dir_itests }:
|
||||
name: 'Äïêéìáóôéêüò ÖÜêåëëïò'
|
||||
name: '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
parent_id: document.dir_root
|
||||
-
|
||||
And then I create another folder, under it, through FTP
|
||||
|
@ -16,67 +16,67 @@
|
|||
!python {model: ir.attachment}: |
|
||||
cr.commit()
|
||||
from document_ftp import test_easyftp as te
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò')
|
||||
ftp.mkd("ÖÜêåëëïò áðü êÜôù")
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
|
||||
ftp.mkd("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>")
|
||||
-
|
||||
I check that this folder exists at the server
|
||||
-
|
||||
!assert {model: document.directory, id: , search: "[('name','=','ÖÜêåëëïò áðü êÜôù')]" }:
|
||||
!assert {model: document.directory, id: , search: "[('name','=','<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>')]" }:
|
||||
- parent_id != False
|
||||
-
|
||||
I login with FTP and check that 'Äïêéìáóôéêüò ÖÜêåëëïò' is there
|
||||
I login with FTP and check that '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' is there
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù')
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>')
|
||||
-
|
||||
I create a file named 'ÄïêéìÞ' into that folder
|
||||
I create a file named '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' into that folder
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
from cStringIO import StringIO
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù')
|
||||
fdata = StringIO('êåßìåíï ìå utf-8')
|
||||
ftp.storbinary('STOR ÄïêéìÞ.txt', fdata)
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>')
|
||||
fdata = StringIO('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> utf-8')
|
||||
ftp.storbinary('STOR <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.txt', fdata)
|
||||
-
|
||||
I remove the 'ÄïêéìÞ.txt' file
|
||||
I remove the '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.txt' file
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
from cStringIO import StringIO
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù')
|
||||
ftp.delete('ÄïêéìÞ.txt')
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>')
|
||||
ftp.delete('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.txt')
|
||||
-
|
||||
I rename 'ÖÜêåëëïò áðü êÜôù' into 'Üëëïò'
|
||||
I rename '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>' into '<27><><EFBFBD><EFBFBD><EFBFBD>'
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò')
|
||||
ftp.rename("ÖÜêåëëïò áðü êÜôù", "Üëëïò")
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
|
||||
ftp.rename("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD>")
|
||||
-
|
||||
I place a file 'file Ö3' in 'Üëëïò'
|
||||
I place a file 'file <EFBFBD>3' in '<27><><EFBFBD><EFBFBD><EFBFBD>'
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
from cStringIO import StringIO
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò')
|
||||
fdata = StringIO('êé Üëëï êåßìåíï')
|
||||
ftp.storbinary('STOR file Ö3.txt', fdata)
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>')
|
||||
fdata = StringIO('<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
|
||||
ftp.storbinary('STOR file <EFBFBD>3.txt', fdata)
|
||||
-
|
||||
I rename the file into file+range(1..200) (large filename)
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
from cStringIO import StringIO
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò')
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>')
|
||||
vuvuzela = 'b'+''.join('z' * 200)+'!'
|
||||
ftp.rename("file Ö3.txt", vuvuzela)
|
||||
ftp.rename("file <EFBFBD>3.txt", vuvuzela)
|
||||
-
|
||||
I delete the file with the large name
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
from document_ftp import test_easyftp as te
|
||||
from cStringIO import StringIO
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò')
|
||||
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>')
|
||||
vuvuzela = 'b'+''.join('z' * 200)+'!'
|
||||
ftp.delete(vuvuzela)
|
||||
|
|
|
@ -25,20 +25,19 @@
|
|||
"""
|
||||
|
||||
from ftplib import FTP
|
||||
from tools.misc import detect_ip_addr
|
||||
from tools import config
|
||||
|
||||
def get_plain_ftp(timeout=10.0):
|
||||
ftp = FTP()
|
||||
host = config.get('ftp_server_host', '127.0.0.1')
|
||||
port = config.get('ftp_server_port','8021')
|
||||
ftp.connect(host,port, timeout=timeout)
|
||||
port = config.get('ftp_server_port', '8021')
|
||||
ftp.connect(host, port, timeout=timeout)
|
||||
return ftp
|
||||
|
||||
def get_ftp_login(cr, uid, ormobj):
|
||||
ftp = get_plain_ftp()
|
||||
user = ormobj.pool.get('res.users').read(cr, uid, uid)
|
||||
ftp.login(user.get('login',''),user.get('password',''))
|
||||
ftp.login(user.get('login',''), user.get('password',''))
|
||||
ftp.cwd("/" + cr.dbname)
|
||||
return ftp
|
||||
|
||||
|
|
Loading…
Reference in New Issue