Merge lp:~vila/bzr/956027-pyftpdlib into lp:bzr/2.5

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6492
Proposed branch: lp:~vila/bzr/956027-pyftpdlib
Merge into: lp:bzr/2.5
Diff against target: 129 lines (+24/-55)
3 files modified
bzrlib/tests/ftp_server/__init__.py (+5/-1)
bzrlib/tests/ftp_server/pyftpdlib_based.py (+17/-54)
doc/en/release-notes/bzr-2.5.txt (+2/-0)
To merge this branch: bzr merge lp:~vila/bzr/956027-pyftpdlib
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Review via email: mp+97688@code.launchpad.net

Commit message

Support pyftpdlib >= 0.7.0 as an ftp test server

Description of the change

Our support for pyftplib has been broken (with no easy workaround I could
found) for 0.6.0, this proposal drop support for previous versions and
provides support for 0.7.0.

I'm targeting 2.5 as bzr-upload can't run its tests anymore otherwise and a
2.5-compatible release is needed for other reasons.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/ftp_server/__init__.py'
2--- bzrlib/tests/ftp_server/__init__.py 2011-06-14 01:26:41 +0000
3+++ bzrlib/tests/ftp_server/__init__.py 2012-03-15 16:12:19 +0000
4@@ -41,7 +41,11 @@
5
6 try:
7 from bzrlib.tests.ftp_server import pyftpdlib_based
8- pyftpdlib_available = True
9+ if pyftpdlib_based.pyftplib_version >= (0, 7, 0):
10+ pyftpdlib_available = True
11+ else:
12+ # 0.6.0 breaks SITE CHMOD
13+ pyftpdlib_available = False
14 except ImportError:
15 pyftpdlib_available = False
16
17
18=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
19--- bzrlib/tests/ftp_server/pyftpdlib_based.py 2011-06-07 07:00:23 +0000
20+++ bzrlib/tests/ftp_server/pyftpdlib_based.py 2012-03-15 16:12:19 +0000
21@@ -96,57 +96,18 @@
22 else:
23 ftpserver.FTPHandler.ftp_NLST(self, path)
24
25- def ftp_SITE_CHMOD(self, line):
26- try:
27- mode, path = line.split(None, 1)
28- mode = int(mode, 8)
29- except ValueError:
30- # We catch both malformed line and malformed mode with the same
31- # ValueError.
32- self.respond("500 'SITE CHMOD %s': command not understood."
33- % line)
34- self.log('FAIL SITE CHMOD ' % line)
35- return
36- ftp_path = self.fs.fs2ftp(path)
37- try:
38- self.run_as_current_user(self.fs.chmod, self.fs.ftp2fs(path), mode)
39- except OSError, err:
40- why = ftpserver._strerror(err)
41- self.log('FAIL SITE CHMOD 0%03o "%s". %s.' % (mode, ftp_path, why))
42- self.respond('550 %s.' % why)
43- else:
44- self.log('OK SITE CHMOD 0%03o "%s".' % (mode, ftp_path))
45- self.respond('200 SITE CHMOD succesful.')
46-
47- if pyftplib_version >= (0, 6, 0):
48- def log_cmd(self, cmd, arg, respcode, respstr):
49- # base class version choke on unicode, the alternative is to just
50- # provide an empty implementation and relies on the client to do
51- # the logging for debugging purposes. Not worth the trouble so far
52- # -- vila 20110607
53- if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
54- line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(),
55- respcode)
56- self.log(line)
57-
58-
59-if pyftplib_version < (0, 6,0):
60- # pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD>
61- # methods, but fails to recognize them.
62- ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
63- # Best fit choice even if not exactly right (can be d, f or m too)
64- perm='w',
65- auth_needed=True, arg_needed=True, check_path=False,
66- help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
67- )
68- # An empty password is valid, hence the arg is neither mandatory not
69- # forbidden
70- ftpserver.proto_cmds['PASS'].arg_needed = None
71-else:
72- # Same rationale as above (the password should be optional), but the hole
73- # in pyftplib-0.6.0 is narrower
74- ftpserver.proto_cmds['PASS']['arg'] = None
75-
76+ def log_cmd(self, cmd, arg, respcode, respstr):
77+ # base class version choke on unicode, the alternative is to just
78+ # provide an empty implementation and relies on the client to do
79+ # the logging for debugging purposes. Not worth the trouble so far
80+ # -- vila 20110607
81+ if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
82+ line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(), respcode)
83+ self.log(line)
84+
85+
86+# An empty password is valid, hence the arg is neither mandatory nor forbidden
87+ftpserver.proto_cmds['PASS']['arg'] = None
88
89 class ftp_server(ftpserver.FTPServer):
90
91@@ -191,7 +152,7 @@
92
93 address = ('localhost', 0) # bind to a random port
94 authorizer = AnonymousWithWriteAccessAuthorizer()
95- authorizer.add_anonymous(self._root, perm='elradfmw')
96+ authorizer.add_anonymous(self._root, perm='elradfmwM')
97 self._ftp_server = ftp_server(address, BzrConformingFTPHandler,
98 authorizer)
99 # This is hacky as hell, will not work if we need two servers working
100@@ -227,7 +188,9 @@
101 % (self._ftpd_thread.ident,))
102
103 def _run_server(self):
104- """Run the server until stop_server is called, shut it down properly then.
105+ """Run the server until stop_server is called.
106+
107+ Shut it down properly then.
108 """
109 self._ftpd_running = True
110 self._ftpd_starting.release()
111@@ -242,4 +205,4 @@
112 def add_user(self, user, password):
113 """Add a user with write access."""
114 self._ftp_server.authorizer.add_user(user, password, self._root,
115- perm='elradfmw')
116+ perm='elradfmwM')
117
118=== modified file 'doc/en/release-notes/bzr-2.5.txt'
119--- doc/en/release-notes/bzr-2.5.txt 2012-03-12 18:34:04 +0000
120+++ doc/en/release-notes/bzr-2.5.txt 2012-03-15 16:12:19 +0000
121@@ -67,6 +67,8 @@
122 suite. This can include new facilities for writing tests, fixes to
123 spurious test failures and changes to the way things should be tested.
124
125+* Add support for pyftpdlib >= 0.7.0 and drop support for previous pyftpdlib
126+ versions. (Vincent Ladeuil, #956027)
127
128 bzr 2.5.0
129 #########

Subscribers

People subscribed via source and target branches