Merge lp:~diegosarmentero/ubuntuone-client/refactor-remove-windows-linux into lp:ubuntuone-client

Proposed by Diego Sarmentero on 2012-05-14
Status: Merged
Approved by: Manuel de la Peña on 2012-05-15
Approved revision: 1245
Merged at revision: 1243
Proposed branch: lp:~diegosarmentero/ubuntuone-client/refactor-remove-windows-linux
Merge into: lp:ubuntuone-client
Diff against target: 451 lines (+139/-189)
12 files modified
pylintrc (+1/-1)
tests/platform/credentials/__init__.py (+27/-0)
tests/platform/filesystem_notifications/test_windows.py (+1/-1)
tests/platform/filesystem_notifier/__init__.py (+27/-0)
tests/platform/filesystem_notifier/test_windows.py (+3/-1)
ubuntuone/platform/__init__.py (+35/-36)
ubuntuone/platform/filesystem_notifications/windows.py (+1/-1)
ubuntuone/platform/linux/__init__.py (+0/-72)
ubuntuone/platform/logger/__init__.py (+43/-0)
ubuntuone/platform/logger/linux.py (+1/-0)
ubuntuone/platform/windows/__init__.py (+0/-76)
ubuntuone/syncdaemon/volume_manager.py (+0/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-client/refactor-remove-windows-linux
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-05-15
Roberto Alsina (community) 2012-05-14 Approve on 2012-05-14
Review via email: mp+105705@code.launchpad.net

Commit Message

- Refactor platform, to move remaining modules inside windows and linux folders.

To post a comment you must log in.
Roberto Alsina (ralsina) :
review: Approve
1244. By Diego Sarmentero on 2012-05-14

Fixing pyinotify imports

Diego Sarmentero (diegosarmentero) wrote :

I think the __init__ from filesystem_notifications is pretty ugly, but the code right now has to be in that way because of lint restriction, maybe we could add this file to the ignore ones in pylintrc and leave the code like this:

if sys.platform == "win32":
    from ubuntuone.platform.filesystem_notifications import pyinotify_agnostic as pyinotify
    ...
else:
    import pyinotify
    ...

Opinions?

1245. By Diego Sarmentero on 2012-05-14

Fixed pyinotify imports

Manuel de la Peña (mandel) wrote :

SO can we use import as here:

335 +if sys.platform == "win32":
336 + from ubuntuone.platform.logger import windows
337 + source = windows
338 +else:
339 + from ubuntuone.platform.logger import linux
340 + source = linux

and instead do:

from ubuntuone.platform.logger import windows as source

review: Needs Fixing
Diego Sarmentero (diegosarmentero) wrote :

> SO can we use import as here:
>
> 335 +if sys.platform == "win32":
> 336 + from ubuntuone.platform.logger import windows
> 337 + source = windows
> 338 +else:
> 339 + from ubuntuone.platform.logger import linux
> 340 + source = linux
>
> and instead do:
>
> from ubuntuone.platform.logger import windows as source

This is done this way, because if we do: "as source" for windows and linux, the lint checker fails with:

38: redefinition of unused 'source' from line 35

Manuel de la Peña (mandel) wrote :

My lord.. stupid pyflakes!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pylintrc'
2--- pylintrc 2011-02-08 11:11:27 +0000
3+++ pylintrc 2012-05-14 21:27:19 +0000
4@@ -12,7 +12,7 @@
5
6 # ignore these specific files
7 # pylint has no idea what to do with this, but our wrapper does some magic
8-ignore=contrib/mocker.py,ubuntuone/syncdaemon/u1fsfsm.py,ubuntuone/platform/linux/__init__.py,ubuntuone/platform/__init__.py,ubuntuone/platform/windows/__init__.py,ubuntuone/platform/windows/pyinotify.py
9+ignore=contrib/mocker.py,ubuntuone/syncdaemon/u1fsfsm.py,ubuntuone/platform/linux/__init__.py,ubuntuone/platform/__init__.py,ubuntuone/platform/windows/__init__.py,ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py
10
11 [MESSAGES CONTROL]
12 # Disable some checkers
13
14=== added directory 'tests/platform/credentials'
15=== added file 'tests/platform/credentials/__init__.py'
16--- tests/platform/credentials/__init__.py 1970-01-01 00:00:00 +0000
17+++ tests/platform/credentials/__init__.py 2012-05-14 21:27:19 +0000
18@@ -0,0 +1,27 @@
19+# Copyright 2012 Canonical Ltd.
20+#
21+# This program is free software: you can redistribute it and/or modify it
22+# under the terms of the GNU General Public License version 3, as published
23+# by the Free Software Foundation.
24+#
25+# This program is distributed in the hope that it will be useful, but
26+# WITHOUT ANY WARRANTY; without even the implied warranties of
27+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
28+# PURPOSE. See the GNU General Public License for more details.
29+#
30+# You should have received a copy of the GNU General Public License along
31+# with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+# In addition, as a special exception, the copyright holders give
34+# permission to link the code of portions of this program with the
35+# OpenSSL library under certain conditions as described in each
36+# individual source file, and distribute linked combinations
37+# including the two.
38+# You must obey the GNU General Public License in all respects
39+# for all of the code used other than OpenSSL. If you modify
40+# file(s) with this exception, you may extend this exception to your
41+# version of the file(s), but you are not obligated to do so. If you
42+# do not wish to do so, delete this exception statement from your
43+# version. If you delete this exception statement from all source
44+# files in the program, then also delete it here.
45+"""Credentials test code."""
46
47=== renamed file 'tests/platform/linux/test_credentials.py' => 'tests/platform/credentials/test_linux.py'
48=== renamed file 'tests/platform/windows/test_credentials.py' => 'tests/platform/credentials/test_windows.py'
49=== modified file 'tests/platform/filesystem_notifications/test_windows.py'
50--- tests/platform/filesystem_notifications/test_windows.py 2012-04-30 15:19:03 +0000
51+++ tests/platform/filesystem_notifications/test_windows.py 2012-05-14 21:27:19 +0000
52@@ -43,7 +43,7 @@
53 from contrib.testing.testcase import BaseTwistedTestCase
54 from ubuntuone.devtools.handlers import MementoHandler
55 from ubuntuone.platform.os_helper import windows as os_helper
56-from ubuntuone.platform.windows.pyinotify import (
57+from ubuntuone.platform.filesystem_notifications.pyinotify_agnostic import (
58 ProcessEvent,
59 IN_CLOSE_WRITE,
60 IN_CREATE,
61
62=== added directory 'tests/platform/filesystem_notifier'
63=== added file 'tests/platform/filesystem_notifier/__init__.py'
64--- tests/platform/filesystem_notifier/__init__.py 1970-01-01 00:00:00 +0000
65+++ tests/platform/filesystem_notifier/__init__.py 2012-05-14 21:27:19 +0000
66@@ -0,0 +1,27 @@
67+# Copyright 2012 Canonical Ltd.
68+#
69+# This program is free software: you can redistribute it and/or modify it
70+# under the terms of the GNU General Public License version 3, as published
71+# by the Free Software Foundation.
72+#
73+# This program is distributed in the hope that it will be useful, but
74+# WITHOUT ANY WARRANTY; without even the implied warranties of
75+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
76+# PURPOSE. See the GNU General Public License for more details.
77+#
78+# You should have received a copy of the GNU General Public License along
79+# with this program. If not, see <http://www.gnu.org/licenses/>.
80+#
81+# In addition, as a special exception, the copyright holders give
82+# permission to link the code of portions of this program with the
83+# OpenSSL library under certain conditions as described in each
84+# individual source file, and distribute linked combinations
85+# including the two.
86+# You must obey the GNU General Public License in all respects
87+# for all of the code used other than OpenSSL. If you modify
88+# file(s) with this exception, you may extend this exception to your
89+# version of the file(s), but you are not obligated to do so. If you
90+# do not wish to do so, delete this exception statement from your
91+# version. If you delete this exception statement from all source
92+# files in the program, then also delete it here.
93+"""Platform/File System Notifier (Pyinotify agnostic) test code."""
94
95=== renamed file 'tests/platform/windows/test_pyinotify.py' => 'tests/platform/filesystem_notifier/test_windows.py'
96--- tests/platform/windows/test_pyinotify.py 2012-04-09 20:07:05 +0000
97+++ tests/platform/filesystem_notifier/test_windows.py 2012-05-14 21:27:19 +0000
98@@ -33,7 +33,9 @@
99 from twisted.internet import defer
100 from twisted.trial.unittest import TestCase
101
102-from ubuntuone.platform.windows.pyinotify import RawOutputFormat
103+from ubuntuone.platform.filesystem_notifications.pyinotify_agnostic import (
104+ RawOutputFormat)
105+
106
107 class RawOutputFormatTest(TestCase):
108 """Test te formatter to ensure it can deal with mbcs."""
109
110=== modified file 'ubuntuone/platform/__init__.py'
111--- ubuntuone/platform/__init__.py 2012-04-30 15:19:03 +0000
112+++ ubuntuone/platform/__init__.py 2012-05-14 21:27:19 +0000
113@@ -37,14 +37,14 @@
114 # and to avoid import ubuntuone.platform.X as source (it wont work)
115
116 if sys.platform == "win32":
117- from ubuntuone.platform import windows
118- source = windows
119+ platform = "win32"
120 else:
121- from ubuntuone.platform import linux
122- source = linux
123+ platform = "linux"
124
125 from ubuntuone.platform import ipc
126 from ubuntuone.platform import filesystem_notifications
127+from ubuntuone.platform import logger
128+from ubuntuone.platform import os_helper
129
130 # This imports needs to be here in order to be included in this namespace
131 from ubuntuone.platform import credentials
132@@ -72,40 +72,39 @@
133 return result
134
135
136-platform = source.platform
137-access = source.access
138-allow_writes = source.allow_writes
139-can_write = source.can_write
140-get_path_list = source.get_path_list
141-is_link = source.is_link
142-is_root = source.is_root
143-listdir = source.listdir
144-make_dir = source.make_dir
145-make_link = source.make_link
146-move_to_trash = source.move_to_trash
147-native_rename = source.native_rename
148-normpath = source.normpath
149-open_file = source.open_file
150-path_exists = source.path_exists
151-read_link = source.read_link
152-recursive_move = source.recursive_move
153-remove_dir = source.remove_dir
154-remove_file = source.remove_file
155-remove_link = source.remove_link
156-remove_tree = source.remove_tree
157-rename = source.rename
158-set_application_name = source.set_application_name
159-set_dir_readonly = source.set_dir_readonly
160-set_dir_readwrite = source.set_dir_readwrite
161-set_file_readonly = source.set_file_readonly
162-set_file_readwrite = source.set_file_readwrite
163-set_no_rights = source.set_no_rights
164-stat_path = source.stat_path
165-walk = source.walk
166+access = os_helper.access
167+allow_writes = os_helper.allow_writes
168+can_write = os_helper.can_write
169+get_path_list = os_helper.get_path_list
170+is_link = os_helper.is_link
171+is_root = os_helper.is_root
172+listdir = os_helper.listdir
173+make_dir = os_helper.make_dir
174+make_link = os_helper.make_link
175+move_to_trash = os_helper.move_to_trash
176+native_rename = os_helper.native_rename
177+normpath = os_helper.normpath
178+open_file = os_helper.open_file
179+path_exists = os_helper.path_exists
180+read_link = os_helper.read_link
181+recursive_move = os_helper.recursive_move
182+remove_dir = os_helper.remove_dir
183+remove_file = os_helper.remove_file
184+remove_link = os_helper.remove_link
185+remove_tree = os_helper.remove_tree
186+rename = os_helper.rename
187+set_application_name = os_helper.set_application_name
188+set_dir_readonly = os_helper.set_dir_readonly
189+set_dir_readwrite = os_helper.set_dir_readwrite
190+set_file_readonly = os_helper.set_file_readonly
191+set_file_readwrite = os_helper.set_file_readwrite
192+set_no_rights = os_helper.set_no_rights
193+stat_path = os_helper.stat_path
194+walk = os_helper.walk
195
196 # From Logger
197-setup_filesystem_logging = source.setup_filesystem_logging
198-get_filesystem_logger = source.get_filesystem_logger
199+setup_filesystem_logging = logger.setup_filesystem_logging
200+get_filesystem_logger = logger.get_filesystem_logger
201
202 # From File System Notifications
203 FilesystemMonitor = filesystem_notifications.FilesystemMonitor
204
205=== renamed file 'ubuntuone/platform/windows/pyinotify.py' => 'ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py'
206=== modified file 'ubuntuone/platform/filesystem_notifications/windows.py'
207--- ubuntuone/platform/filesystem_notifications/windows.py 2012-04-30 15:19:03 +0000
208+++ ubuntuone/platform/filesystem_notifications/windows.py 2012-05-14 21:27:19 +0000
209@@ -61,7 +61,7 @@
210 SetEvent,
211 WaitForMultipleObjects,
212 WAIT_OBJECT_0)
213-from ubuntuone.platform.windows.pyinotify import (
214+from ubuntuone.platform.filesystem_notifications.pyinotify_agnostic import (
215 Event,
216 WatchManagerError,
217 ProcessEvent,
218
219=== removed directory 'ubuntuone/platform/linux'
220=== removed file 'ubuntuone/platform/linux/__init__.py'
221--- ubuntuone/platform/linux/__init__.py 2012-04-30 18:56:56 +0000
222+++ ubuntuone/platform/linux/__init__.py 1970-01-01 00:00:00 +0000
223@@ -1,72 +0,0 @@
224-# ubuntuone.platform.linux - linux platform imports
225-#
226-# Copyright 2009-2012 Canonical Ltd.
227-#
228-# This program is free software: you can redistribute it and/or modify it
229-# under the terms of the GNU General Public License version 3, as published
230-# by the Free Software Foundation.
231-#
232-# This program is distributed in the hope that it will be useful, but
233-# WITHOUT ANY WARRANTY; without even the implied warranties of
234-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
235-# PURPOSE. See the GNU General Public License for more details.
236-#
237-# You should have received a copy of the GNU General Public License along
238-# with this program. If not, see <http://www.gnu.org/licenses/>.
239-#
240-# In addition, as a special exception, the copyright holders give
241-# permission to link the code of portions of this program with the
242-# OpenSSL library under certain conditions as described in each
243-# individual source file, and distribute linked combinations
244-# including the two.
245-# You must obey the GNU General Public License in all respects
246-# for all of the code used other than OpenSSL. If you modify
247-# file(s) with this exception, you may extend this exception to your
248-# version of the file(s), but you are not obligated to do so. If you
249-# do not wish to do so, delete this exception statement from your
250-# version. If you delete this exception statement from all source
251-# files in the program, then also delete it here.
252-"""
253-Linux import for ubuntuone-client
254-
255-This module has to have all linux specific modules and provide the api required
256-to support the linux platform."""
257-
258-platform = "linux"
259-
260-
261-from ubuntuone.platform.os_helper import (
262- access,
263- allow_writes,
264- can_write,
265- get_path_list,
266- is_link,
267- is_root,
268- listdir,
269- make_dir,
270- make_link,
271- move_to_trash,
272- native_rename,
273- normpath,
274- open_file,
275- path_exists,
276- read_link,
277- recursive_move,
278- remove_dir,
279- remove_file,
280- remove_link,
281- remove_tree,
282- rename,
283- set_application_name,
284- set_dir_readonly,
285- set_dir_readwrite,
286- set_file_readonly,
287- set_file_readwrite,
288- set_no_rights,
289- stat_path,
290- walk,
291-)
292-from ubuntuone.platform.linux.logger import (
293- setup_filesystem_logging,
294- get_filesystem_logger,
295-)
296
297=== added directory 'ubuntuone/platform/logger'
298=== added file 'ubuntuone/platform/logger/__init__.py'
299--- ubuntuone/platform/logger/__init__.py 1970-01-01 00:00:00 +0000
300+++ ubuntuone/platform/logger/__init__.py 2012-05-14 21:27:19 +0000
301@@ -0,0 +1,43 @@
302+# -*- coding: utf-8 *-*
303+#
304+# Copyright 2012 Canonical Ltd.
305+#
306+# This program is free software: you can redistribute it and/or modify it
307+# under the terms of the GNU General Public License version 3, as published
308+# by the Free Software Foundation.
309+#
310+# This program is distributed in the hope that it will be useful, but
311+# WITHOUT ANY WARRANTY; without even the implied warranties of
312+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
313+# PURPOSE. See the GNU General Public License for more details.
314+#
315+# You should have received a copy of the GNU General Public License along
316+# with this program. If not, see <http://www.gnu.org/licenses/>.
317+#
318+# In addition, as a special exception, the copyright holders give
319+# permission to link the code of portions of this program with the
320+# OpenSSL library under certain conditions as described in each
321+# individual source file, and distribute linked combinations
322+# including the two.
323+# You must obey the GNU General Public License in all respects
324+# for all of the code used other than OpenSSL. If you modify
325+# file(s) with this exception, you may extend this exception to your
326+# version of the file(s), but you are not obligated to do so. If you
327+# do not wish to do so, delete this exception statement from your
328+# version. If you delete this exception statement from all source
329+# files in the program, then also delete it here.
330+"""Logger module."""
331+
332+import sys
333+
334+
335+if sys.platform == "win32":
336+ from ubuntuone.platform.logger import windows
337+ source = windows
338+else:
339+ from ubuntuone.platform.logger import linux
340+ source = linux
341+
342+
343+get_filesystem_logger = source.get_filesystem_logger
344+setup_filesystem_logging = source.setup_filesystem_logging
345
346=== renamed file 'ubuntuone/platform/linux/logger.py' => 'ubuntuone/platform/logger/linux.py'
347--- ubuntuone/platform/linux/logger.py 2012-04-09 20:07:05 +0000
348+++ ubuntuone/platform/logger/linux.py 2012-05-14 21:27:19 +0000
349@@ -29,6 +29,7 @@
350 """Provide platform logging settings."""
351
352 import logging
353+
354 import pyinotify
355
356
357
358=== renamed file 'ubuntuone/platform/windows/logger.py' => 'ubuntuone/platform/logger/windows.py'
359=== removed directory 'ubuntuone/platform/windows'
360=== removed file 'ubuntuone/platform/windows/__init__.py'
361--- ubuntuone/platform/windows/__init__.py 2012-05-04 16:19:07 +0000
362+++ ubuntuone/platform/windows/__init__.py 1970-01-01 00:00:00 +0000
363@@ -1,76 +0,0 @@
364-# ubuntuone.platform.windows - windows platform imports
365-#
366-# Copyright 2010-2012 Canonical Ltd.
367-#
368-# This program is free software: you can redistribute it and/or modify it
369-# under the terms of the GNU General Public License version 3, as published
370-# by the Free Software Foundation.
371-#
372-# This program is distributed in the hope that it will be useful, but
373-# WITHOUT ANY WARRANTY; without even the implied warranties of
374-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
375-# PURPOSE. See the GNU General Public License for more details.
376-#
377-# You should have received a copy of the GNU General Public License along
378-# with this program. If not, see <http://www.gnu.org/licenses/>.
379-#
380-# In addition, as a special exception, the copyright holders give
381-# permission to link the code of portions of this program with the
382-# OpenSSL library under certain conditions as described in each
383-# individual source file, and distribute linked combinations
384-# including the two.
385-# You must obey the GNU General Public License in all respects
386-# for all of the code used other than OpenSSL. If you modify
387-# file(s) with this exception, you may extend this exception to your
388-# version of the file(s), but you are not obligated to do so. If you
389-# do not wish to do so, delete this exception statement from your
390-# version. If you delete this exception statement from all source
391-# files in the program, then also delete it here.
392-"""
393-Windows import for ubuntuone-client
394-
395-This module has to have all windows specific modules and provide the api
396-required to support the windows platform.
397-"""
398-
399-platform = "win32"
400-
401-
402-import logger
403-
404-from ubuntuone.platform.os_helper import (
405- access,
406- allow_writes,
407- can_write,
408- get_path_list,
409- is_link,
410- is_root,
411- listdir,
412- make_dir,
413- make_link,
414- move_to_trash,
415- native_rename,
416- normpath,
417- open_file,
418- path_exists,
419- read_link,
420- recursive_move,
421- remove_dir,
422- remove_file,
423- remove_link,
424- remove_tree,
425- rename,
426- set_application_name,
427- set_dir_readonly,
428- set_dir_readwrite,
429- set_file_readonly,
430- set_file_readwrite,
431- set_no_rights,
432- stat_path,
433- walk,
434-)
435-
436-from ubuntuone.platform.windows.logger import (
437- setup_filesystem_logging,
438- get_filesystem_logger,
439-)
440
441=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
442--- ubuntuone/syncdaemon/volume_manager.py 2012-04-09 20:07:05 +0000
443+++ ubuntuone/syncdaemon/volume_manager.py 2012-05-14 21:27:19 +0000
444@@ -1626,7 +1626,6 @@
445 .partial to .u1partial.
446
447 """
448- from ubuntuone.platform.linux import allow_writes
449 self.log.debug('upgrading from metadata 2 (bogus)')
450 for top in self._root_dir, self._shares_dir:
451 for dirpath, dirnames, filenames in walk(top):

Subscribers

People subscribed via source and target branches