Merge lp:~nataliabidart/magicicada-client/fix-lint-tests into lp:magicicada-client
- fix-lint-tests
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 1409 |
Merged at revision: | 1409 |
Proposed branch: | lp:~nataliabidart/magicicada-client/fix-lint-tests |
Merge into: | lp:magicicada-client |
Diff against target: |
3358 lines (+588/-592) 51 files modified
Makefile (+9/-6) dependencies.txt (+1/-0) run-tests (+0/-8) tests/platform/credentials/__init__.py (+1/-0) ubuntuone/logger.py (+9/-9) ubuntuone/platform/__init__.py (+2/-2) ubuntuone/platform/credentials/__init__.py (+36/-26) ubuntuone/platform/credentials/dbus_service.py (+16/-13) ubuntuone/platform/credentials/ipc_service.py (+1/-1) ubuntuone/platform/filesystem_notifications/monitor/__init__.py (+2/-2) ubuntuone/platform/filesystem_notifications/monitor/common.py (+8/-6) ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_client.py (+4/-4) ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_daemon.py (+14/-10) ubuntuone/platform/filesystem_notifications/monitor/linux.py (+11/-10) ubuntuone/platform/filesystem_notifications/monitor/windows.py (+18/-16) ubuntuone/platform/filesystem_notifications/notify_processor/common.py (+13/-12) ubuntuone/platform/filesystem_notifications/notify_processor/linux.py (+16/-15) ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py (+33/-31) ubuntuone/platform/ipc/ipc_client.py (+6/-8) ubuntuone/platform/ipc/linux.py (+3/-5) ubuntuone/platform/ipc/perspective_broker.py (+14/-15) ubuntuone/platform/notification/linux.py (+0/-2) ubuntuone/platform/notification/windows.py (+0/-2) ubuntuone/platform/os_helper/windows.py (+29/-23) ubuntuone/platform/sync_menu/linux.py (+45/-38) ubuntuone/platform/tools/__init__.py (+48/-39) ubuntuone/platform/tools/perspective_broker.py (+6/-7) ubuntuone/proxy/tunnel_client.py (+4/-3) ubuntuone/proxy/tunnel_server.py (+1/-1) ubuntuone/status/aggregator.py (+11/-16) ubuntuone/syncdaemon/__init__.py (+6/-10) ubuntuone/syncdaemon/action_queue.py (+7/-8) ubuntuone/syncdaemon/config.py (+1/-1) ubuntuone/syncdaemon/event_queue.py (+1/-1) ubuntuone/syncdaemon/events_nanny.py (+1/-1) ubuntuone/syncdaemon/file_shelf.py (+5/-8) ubuntuone/syncdaemon/filesystem_manager.py (+15/-20) ubuntuone/syncdaemon/filesystem_notifications.py (+7/-7) ubuntuone/syncdaemon/fsm/fsm.py (+28/-33) ubuntuone/syncdaemon/fsm/fsm_parser.py (+8/-11) ubuntuone/syncdaemon/hash_queue.py (+3/-2) ubuntuone/syncdaemon/interfaces.py (+0/-2) ubuntuone/syncdaemon/local_rescan.py (+14/-17) ubuntuone/syncdaemon/logger.py (+6/-8) ubuntuone/syncdaemon/offload_queue.py (+4/-4) ubuntuone/syncdaemon/states.py (+18/-20) ubuntuone/syncdaemon/status_listener.py (+1/-3) ubuntuone/syncdaemon/sync.py (+31/-38) ubuntuone/syncdaemon/tritcask.py (+28/-28) ubuntuone/syncdaemon/u1fsfsm.py (+2/-2) ubuntuone/syncdaemon/volume_manager.py (+41/-38) |
To merge this branch: | bzr merge lp:~nataliabidart/magicicada-client/fix-lint-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart | Approve | ||
Review via email: mp+271742@code.launchpad.net |
Commit message
- Fixed lint issues on ubuntuone/ folder.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' | |||
2 | --- Makefile 2015-09-19 21:11:52 +0000 | |||
3 | +++ Makefile 2015-09-19 23:19:46 +0000 | |||
4 | @@ -27,8 +27,8 @@ | |||
5 | 27 | # | 27 | # |
6 | 28 | # For further info, check http://launchpad.net/magicicada-client | 28 | # For further info, check http://launchpad.net/magicicada-client |
7 | 29 | 29 | ||
10 | 30 | ENV = $(CURDIR)/env | 30 | ENV = $(CURDIR)/.env |
11 | 31 | PROTOCOL_DIR = .protocol | 31 | PROTOCOL_DIR = $(CURDIR)/.protocol |
12 | 32 | PROTOCOL_LINK = ubuntuone/storageprotocol | 32 | PROTOCOL_LINK = ubuntuone/storageprotocol |
13 | 33 | 33 | ||
14 | 34 | deps: | 34 | deps: |
15 | @@ -39,7 +39,7 @@ | |||
16 | 39 | bzr branch lp:magicicada-protocol $(PROTOCOL_DIR) | 39 | bzr branch lp:magicicada-protocol $(PROTOCOL_DIR) |
17 | 40 | 40 | ||
18 | 41 | $(PROTOCOL_LINK): $(PROTOCOL_DIR) | 41 | $(PROTOCOL_LINK): $(PROTOCOL_DIR) |
20 | 42 | ln -s ../$(PROTOCOL_DIR)/$(PROTOCOL_LINK) $(PROTOCOL_LINK) | 42 | ln -s $(PROTOCOL_DIR)/$(PROTOCOL_LINK) $(PROTOCOL_LINK) |
21 | 43 | 43 | ||
22 | 44 | update-protocol: | 44 | update-protocol: |
23 | 45 | cd $(PROTOCOL_DIR) && bzr pull && python setup.py build | 45 | cd $(PROTOCOL_DIR) && bzr pull && python setup.py build |
24 | @@ -49,11 +49,14 @@ | |||
25 | 49 | lint: | 49 | lint: |
26 | 50 | virtualenv $(ENV) | 50 | virtualenv $(ENV) |
27 | 51 | $(ENV)/bin/pip install flake8 | 51 | $(ENV)/bin/pip install flake8 |
29 | 52 | $(ENV)/bin/flake8 --filename='*.py' ubuntuone tests | 52 | $(ENV)/bin/flake8 --filename='*.py' --exclude='u1fsfsm.py' ubuntuone |
30 | 53 | 53 | ||
32 | 54 | test: | 54 | test: lint |
33 | 55 | ./run-tests | 55 | ./run-tests |
34 | 56 | 56 | ||
35 | 57 | clean: | 57 | clean: |
37 | 58 | rm -rf _trial_temp $(PROTOCOL_DIR) $(PROTOCOL_LINK) | 58 | rm -rf build _trial_temp $(PROTOCOL_DIR) $(PROTOCOL_LINK) $(ENV) |
38 | 59 | find -name '*.pyc' -delete | 59 | find -name '*.pyc' -delete |
39 | 60 | |||
40 | 61 | .PHONY: | ||
41 | 62 | deps update-protocol bootstrap lint test clean | ||
42 | 60 | 63 | ||
43 | === modified file 'dependencies.txt' | |||
44 | --- dependencies.txt 2015-09-19 20:49:35 +0000 | |||
45 | +++ dependencies.txt 2015-09-19 23:19:46 +0000 | |||
46 | @@ -4,4 +4,5 @@ | |||
47 | 4 | python-gi | 4 | python-gi |
48 | 5 | python-protobuf | 5 | python-protobuf |
49 | 6 | python-pyinotify | 6 | python-pyinotify |
50 | 7 | python-qt4reactor | ||
51 | 7 | python-twisted | 8 | python-twisted |
52 | 8 | 9 | ||
53 | === modified file 'run-tests' | |||
54 | --- run-tests 2015-09-19 20:49:35 +0000 | |||
55 | +++ run-tests 2015-09-19 23:19:46 +0000 | |||
56 | @@ -43,12 +43,6 @@ | |||
57 | 43 | MODULE="tests" | 43 | MODULE="tests" |
58 | 44 | fi | 44 | fi |
59 | 45 | 45 | ||
60 | 46 | style_check() { | ||
61 | 47 | u1lint -i "$LINT_IGNORES" | ||
62 | 48 | # Don't run pep8 yet, as there are a LOT of warnings to fix | ||
63 | 49 | # pep8 --exclude '.bzr,.pc,build' . bin/* | ||
64 | 50 | } | ||
65 | 51 | |||
66 | 52 | SYSNAME=`uname -s` | 46 | SYSNAME=`uname -s` |
67 | 53 | 47 | ||
68 | 54 | if [ "$SYSNAME" == "Darwin" ]; then | 48 | if [ "$SYSNAME" == "Darwin" ]; then |
69 | @@ -73,5 +67,3 @@ | |||
70 | 73 | rm -rf build | 67 | rm -rf build |
71 | 74 | 68 | ||
72 | 75 | $PYTHON contrib/check-reactor-import | 69 | $PYTHON contrib/check-reactor-import |
73 | 76 | |||
74 | 77 | style_check | ||
75 | 78 | 70 | ||
76 | === modified file 'tests/platform/credentials/__init__.py' | |||
77 | --- tests/platform/credentials/__init__.py 2012-05-14 19:04:43 +0000 | |||
78 | +++ tests/platform/credentials/__init__.py 2015-09-19 23:19:46 +0000 | |||
79 | @@ -24,4 +24,5 @@ | |||
80 | 24 | # do not wish to do so, delete this exception statement from your | 24 | # do not wish to do so, delete this exception statement from your |
81 | 25 | # version. If you delete this exception statement from all source | 25 | # version. If you delete this exception statement from all source |
82 | 26 | # files in the program, then also delete it here. | 26 | # files in the program, then also delete it here. |
83 | 27 | |||
84 | 27 | """Credentials test code.""" | 28 | """Credentials test code.""" |
85 | 28 | 29 | ||
86 | === modified file 'ubuntuone/logger.py' | |||
87 | --- ubuntuone/logger.py 2012-04-09 20:07:05 +0000 | |||
88 | +++ ubuntuone/logger.py 2015-09-19 23:19:46 +0000 | |||
89 | @@ -225,8 +225,8 @@ | |||
90 | 225 | return sum(slave.handle(record) for slave in self.slaves) | 225 | return sum(slave.handle(record) for slave in self.slaves) |
91 | 226 | if record.levelno == logging.DEBUG: | 226 | if record.levelno == logging.DEBUG: |
92 | 227 | return logging.Handler.handle(self, record) | 227 | return logging.Handler.handle(self, record) |
95 | 228 | elif self.on_error and record.levelno >= logging.ERROR and \ | 228 | elif (self.on_error and record.levelno >= logging.ERROR and |
96 | 229 | record.levelno != NOTE: | 229 | record.levelno != NOTE): |
97 | 230 | # if it's >= ERROR keep it, but mark the dirty falg | 230 | # if it's >= ERROR keep it, but mark the dirty falg |
98 | 231 | self.dirty = True | 231 | self.dirty = True |
99 | 232 | return logging.Handler.handle(self, record) | 232 | return logging.Handler.handle(self, record) |
100 | @@ -243,8 +243,8 @@ | |||
101 | 243 | if exc_type is not None: | 243 | if exc_type is not None: |
102 | 244 | self.emit_debug() | 244 | self.emit_debug() |
103 | 245 | self.on_error = False | 245 | self.on_error = False |
106 | 246 | self.logger.error('unhandled exception', exc_info=(exc_type, | 246 | self.logger.error('unhandled exception', |
107 | 247 | exc_value, traceback)) | 247 | exc_info=(exc_type, exc_value, traceback)) |
108 | 248 | elif self.dirty: | 248 | elif self.dirty: |
109 | 249 | # emit all debug messages collected after the error | 249 | # emit all debug messages collected after the error |
110 | 250 | self.emit_debug() | 250 | self.emit_debug() |
111 | @@ -292,13 +292,13 @@ | |||
112 | 292 | return middle | 292 | return middle |
113 | 293 | 293 | ||
114 | 294 | 294 | ||
116 | 295 | ### configure the thing ### | 295 | # configure the thing # |
117 | 296 | LOGBACKUP = 5 # the number of log files to keep around | 296 | LOGBACKUP = 5 # the number of log files to keep around |
118 | 297 | 297 | ||
123 | 298 | basic_formatter = logging.Formatter(fmt="%(asctime)s - %(name)s - " \ | 298 | basic_formatter = logging.Formatter( |
124 | 299 | "%(levelname)s - %(message)s") | 299 | fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s") |
125 | 300 | debug_formatter = logging.Formatter(fmt="%(asctime)s %(name)s %(module)s " \ | 300 | debug_formatter = logging.Formatter( |
126 | 301 | "%(lineno)s %(funcName)s %(message)s") | 301 | fmt="%(asctime)s %(name)s %(module)s %(lineno)s %(funcName)s %(message)s") |
127 | 302 | 302 | ||
128 | 303 | # a constant to change the default DEBUG level value | 303 | # a constant to change the default DEBUG level value |
129 | 304 | _DEBUG_LOG_LEVEL = logging.DEBUG | 304 | _DEBUG_LOG_LEVEL = logging.DEBUG |
130 | 305 | 305 | ||
131 | === modified file 'ubuntuone/platform/__init__.py' | |||
132 | --- ubuntuone/platform/__init__.py 2013-05-29 13:45:19 +0000 | |||
133 | +++ ubuntuone/platform/__init__.py 2015-09-19 23:19:46 +0000 | |||
134 | @@ -55,8 +55,8 @@ | |||
135 | 55 | except UnicodeDecodeError: | 55 | except UnicodeDecodeError: |
136 | 56 | raise AssertionError('The path %r must be encoded in utf-8' % path) | 56 | raise AssertionError('The path %r must be encoded in utf-8' % path) |
137 | 57 | tilde = '~' | 57 | tilde = '~' |
140 | 58 | if not path.startswith(tilde) or \ | 58 | if (not path.startswith(tilde) or |
141 | 59 | (len(path) > 1 and path[1:2] != os.path.sep): | 59 | (len(path) > 1 and path[1:2] != os.path.sep)): |
142 | 60 | return path | 60 | return path |
143 | 61 | result = path.replace('~', user_home, 1) | 61 | result = path.replace('~', user_home, 1) |
144 | 62 | 62 | ||
145 | 63 | 63 | ||
146 | === modified file 'ubuntuone/platform/credentials/__init__.py' | |||
147 | --- ubuntuone/platform/credentials/__init__.py 2015-09-17 02:20:40 +0000 | |||
148 | +++ ubuntuone/platform/credentials/__init__.py 2015-09-19 23:19:46 +0000 | |||
149 | @@ -26,6 +26,7 @@ | |||
150 | 26 | # do not wish to do so, delete this exception statement from your | 26 | # do not wish to do so, delete this exception statement from your |
151 | 27 | # version. If you delete this exception statement from all source | 27 | # version. If you delete this exception statement from all source |
152 | 28 | # files in the program, then also delete it here. | 28 | # files in the program, then also delete it here. |
153 | 29 | |||
154 | 29 | """Common code for the credentials management.""" | 30 | """Common code for the credentials management.""" |
155 | 30 | 31 | ||
156 | 31 | import gettext | 32 | import gettext |
157 | @@ -179,12 +180,13 @@ | |||
158 | 179 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) | 180 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
159 | 180 | self._cleanup_signals.append(sig) | 181 | self._cleanup_signals.append(sig) |
160 | 181 | 182 | ||
163 | 182 | sig = proxy.connect_to_signal('CredentialsNotFound', | 183 | sig = proxy.connect_to_signal( |
164 | 183 | partial(self.callback, result={}, deferred=d)) | 184 | 'CredentialsNotFound', |
165 | 185 | partial(self.callback, result={}, deferred=d)) | ||
166 | 184 | self._cleanup_signals.append(sig) | 186 | self._cleanup_signals.append(sig) |
167 | 185 | 187 | ||
170 | 186 | sig = proxy.connect_to_signal('CredentialsError', | 188 | sig = proxy.connect_to_signal( |
171 | 187 | partial(self.errback, deferred=d)) | 189 | 'CredentialsError', partial(self.errback, deferred=d)) |
172 | 188 | self._cleanup_signals.append(sig) | 190 | self._cleanup_signals.append(sig) |
173 | 189 | 191 | ||
174 | 190 | done = defer.Deferred() | 192 | done = defer.Deferred() |
175 | @@ -212,12 +214,13 @@ | |||
176 | 212 | 214 | ||
177 | 213 | proxy = yield self.get_creds_proxy() | 215 | proxy = yield self.get_creds_proxy() |
178 | 214 | 216 | ||
181 | 215 | sig = proxy.connect_to_signal('CredentialsCleared', | 217 | sig = proxy.connect_to_signal( |
182 | 216 | partial(self.callback, result=None, deferred=d)) | 218 | 'CredentialsCleared', |
183 | 219 | partial(self.callback, result=None, deferred=d)) | ||
184 | 217 | self._cleanup_signals.append(sig) | 220 | self._cleanup_signals.append(sig) |
185 | 218 | 221 | ||
188 | 219 | sig = proxy.connect_to_signal('CredentialsError', | 222 | sig = proxy.connect_to_signal( |
189 | 220 | partial(self.errback, deferred=d)) | 223 | 'CredentialsError', partial(self.errback, deferred=d)) |
190 | 221 | self._cleanup_signals.append(sig) | 224 | self._cleanup_signals.append(sig) |
191 | 222 | 225 | ||
192 | 223 | done = defer.Deferred() | 226 | done = defer.Deferred() |
193 | @@ -248,16 +251,18 @@ | |||
194 | 248 | 251 | ||
195 | 249 | proxy = yield self.get_creds_proxy() | 252 | proxy = yield self.get_creds_proxy() |
196 | 250 | 253 | ||
199 | 251 | sig = proxy.connect_to_signal('CredentialsStored', | 254 | sig = proxy.connect_to_signal( |
200 | 252 | partial(self.callback, result=None, deferred=d)) | 255 | 'CredentialsStored', |
201 | 256 | partial(self.callback, result=None, deferred=d)) | ||
202 | 253 | self._cleanup_signals.append(sig) | 257 | self._cleanup_signals.append(sig) |
203 | 254 | 258 | ||
206 | 255 | sig = proxy.connect_to_signal('CredentialsError', | 259 | sig = proxy.connect_to_signal( |
207 | 256 | partial(self.errback, deferred=d)) | 260 | 'CredentialsError', partial(self.errback, deferred=d)) |
208 | 257 | self._cleanup_signals.append(sig) | 261 | self._cleanup_signals.append(sig) |
209 | 258 | 262 | ||
210 | 259 | done = defer.Deferred() | 263 | done = defer.Deferred() |
212 | 260 | proxy.store_credentials(token, | 264 | proxy.store_credentials( |
213 | 265 | token, | ||
214 | 261 | reply_handler=partial(self.callback, result=None, deferred=done), | 266 | reply_handler=partial(self.callback, result=None, deferred=done), |
215 | 262 | error_handler=partial(self.errback, deferred=done)) | 267 | error_handler=partial(self.errback, deferred=done)) |
216 | 263 | 268 | ||
217 | @@ -295,16 +300,18 @@ | |||
218 | 295 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) | 300 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
219 | 296 | self._cleanup_signals.append(sig) | 301 | self._cleanup_signals.append(sig) |
220 | 297 | 302 | ||
223 | 298 | sig = proxy.connect_to_signal('AuthorizationDenied', | 303 | sig = proxy.connect_to_signal( |
224 | 299 | partial(self.callback, result=None, deferred=d)) | 304 | 'AuthorizationDenied', |
225 | 305 | partial(self.callback, result=None, deferred=d)) | ||
226 | 300 | self._cleanup_signals.append(sig) | 306 | self._cleanup_signals.append(sig) |
227 | 301 | 307 | ||
230 | 302 | sig = proxy.connect_to_signal('CredentialsError', | 308 | sig = proxy.connect_to_signal( |
231 | 303 | partial(self.errback, deferred=d)) | 309 | 'CredentialsError', partial(self.errback, deferred=d)) |
232 | 304 | self._cleanup_signals.append(sig) | 310 | self._cleanup_signals.append(sig) |
233 | 305 | 311 | ||
234 | 306 | done = defer.Deferred() | 312 | done = defer.Deferred() |
236 | 307 | proxy.register({'window_id': str(window_id)}, | 313 | proxy.register( |
237 | 314 | {'window_id': str(window_id)}, | ||
238 | 308 | reply_handler=partial(self.callback, result=None, deferred=done), | 315 | reply_handler=partial(self.callback, result=None, deferred=done), |
239 | 309 | error_handler=partial(self.errback, deferred=done)) | 316 | error_handler=partial(self.errback, deferred=done)) |
240 | 310 | 317 | ||
241 | @@ -344,16 +351,18 @@ | |||
242 | 344 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) | 351 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
243 | 345 | self._cleanup_signals.append(sig) | 352 | self._cleanup_signals.append(sig) |
244 | 346 | 353 | ||
247 | 347 | sig = proxy.connect_to_signal('AuthorizationDenied', | 354 | sig = proxy.connect_to_signal( |
248 | 348 | partial(self.callback, result=None, deferred=d)) | 355 | 'AuthorizationDenied', |
249 | 356 | partial(self.callback, result=None, deferred=d)) | ||
250 | 349 | self._cleanup_signals.append(sig) | 357 | self._cleanup_signals.append(sig) |
251 | 350 | 358 | ||
254 | 351 | sig = proxy.connect_to_signal('CredentialsError', | 359 | sig = proxy.connect_to_signal( |
255 | 352 | partial(self.errback, deferred=d)) | 360 | 'CredentialsError', partial(self.errback, deferred=d)) |
256 | 353 | self._cleanup_signals.append(sig) | 361 | self._cleanup_signals.append(sig) |
257 | 354 | 362 | ||
258 | 355 | done = defer.Deferred() | 363 | done = defer.Deferred() |
260 | 356 | proxy.login({'window_id': str(window_id)}, | 364 | proxy.login( |
261 | 365 | {'window_id': str(window_id)}, | ||
262 | 357 | reply_handler=partial(self.callback, result=None, deferred=done), | 366 | reply_handler=partial(self.callback, result=None, deferred=done), |
263 | 358 | error_handler=partial(self.errback, deferred=done)) | 367 | error_handler=partial(self.errback, deferred=done)) |
264 | 359 | 368 | ||
265 | @@ -384,12 +393,13 @@ | |||
266 | 384 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) | 393 | sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
267 | 385 | self._cleanup_signals.append(sig) | 394 | self._cleanup_signals.append(sig) |
268 | 386 | 395 | ||
271 | 387 | sig = proxy.connect_to_signal('CredentialsError', | 396 | sig = proxy.connect_to_signal( |
272 | 388 | partial(self.errback, deferred=d)) | 397 | 'CredentialsError', partial(self.errback, deferred=d)) |
273 | 389 | self._cleanup_signals.append(sig) | 398 | self._cleanup_signals.append(sig) |
274 | 390 | 399 | ||
275 | 391 | done = defer.Deferred() | 400 | done = defer.Deferred() |
277 | 392 | proxy.login_email_password({'email': email, 'password': password}, | 401 | proxy.login_email_password( |
278 | 402 | {'email': email, 'password': password}, | ||
279 | 393 | reply_handler=partial(self.callback, result=None, deferred=done), | 403 | reply_handler=partial(self.callback, result=None, deferred=done), |
280 | 394 | error_handler=partial(self.errback, deferred=done)) | 404 | error_handler=partial(self.errback, deferred=done)) |
281 | 395 | 405 | ||
282 | 396 | 406 | ||
283 | === modified file 'ubuntuone/platform/credentials/dbus_service.py' | |||
284 | --- ubuntuone/platform/credentials/dbus_service.py 2015-09-17 02:20:40 +0000 | |||
285 | +++ ubuntuone/platform/credentials/dbus_service.py 2015-09-19 23:19:46 +0000 | |||
286 | @@ -71,7 +71,7 @@ | |||
287 | 71 | member, app_name) | 71 | member, app_name) |
288 | 72 | 72 | ||
289 | 73 | if app_name != APP_NAME: | 73 | if app_name != APP_NAME: |
291 | 74 | logger.info('Received %r but app_name %r does not match %r, ' \ | 74 | logger.info('Received %r but app_name %r does not match %r, ' |
292 | 75 | 'exiting.', member, app_name, APP_NAME) | 75 | 'exiting.', member, app_name, APP_NAME) |
293 | 76 | return | 76 | return |
294 | 77 | 77 | ||
295 | @@ -89,9 +89,9 @@ | |||
296 | 89 | """Get the SSO dbus proxy.""" | 89 | """Get the SSO dbus proxy.""" |
297 | 90 | bus = dbus.SessionBus() | 90 | bus = dbus.SessionBus() |
298 | 91 | # register signal handlers for each kind of error | 91 | # register signal handlers for each kind of error |
302 | 92 | self.sso_match = bus.add_signal_receiver(self._signal_handler, | 92 | self.sso_match = bus.add_signal_receiver( |
303 | 93 | member_keyword='member', | 93 | self._signal_handler, member_keyword='member', |
304 | 94 | dbus_interface=ubuntu_sso.DBUS_CREDENTIALS_IFACE) | 94 | dbus_interface=ubuntu_sso.DBUS_CREDENTIALS_IFACE) |
305 | 95 | try: | 95 | try: |
306 | 96 | obj = bus.get_object(ubuntu_sso.DBUS_BUS_NAME, | 96 | obj = bus.get_object(ubuntu_sso.DBUS_BUS_NAME, |
307 | 97 | ubuntu_sso.DBUS_CREDENTIALS_PATH, | 97 | ubuntu_sso.DBUS_CREDENTIALS_PATH, |
308 | @@ -133,7 +133,6 @@ | |||
309 | 133 | self.shutdown_func() | 133 | self.shutdown_func() |
310 | 134 | 134 | ||
311 | 135 | # Operator not preceded by a space (fails with dbus decorators) | 135 | # Operator not preceded by a space (fails with dbus decorators) |
312 | 136 | # pylint: disable=C0322 | ||
313 | 137 | 136 | ||
314 | 138 | @dbus.service.signal(DBUS_CREDENTIALS_IFACE) | 137 | @dbus.service.signal(DBUS_CREDENTIALS_IFACE) |
315 | 139 | def AuthorizationDenied(self): | 138 | def AuthorizationDenied(self): |
316 | @@ -182,8 +181,8 @@ | |||
317 | 182 | def find_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): | 181 | def find_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): |
318 | 183 | """Ask the Magicicada credentials.""" | 182 | """Ask the Magicicada credentials.""" |
319 | 184 | self.ref_count += 1 | 183 | self.ref_count += 1 |
322 | 185 | self.sso_proxy.find_credentials(APP_NAME, | 184 | self.sso_proxy.find_credentials( |
323 | 186 | dbus.Dictionary({}, signature='ss'), | 185 | APP_NAME, dbus.Dictionary({}, signature='ss'), |
324 | 187 | reply_handler=reply_handler, error_handler=error_handler) | 186 | reply_handler=reply_handler, error_handler=error_handler) |
325 | 188 | 187 | ||
326 | 189 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, | 188 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, |
327 | @@ -218,8 +217,8 @@ | |||
328 | 218 | def clear_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): | 217 | def clear_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): |
329 | 219 | """Clear the Magicicada credentials.""" | 218 | """Clear the Magicicada credentials.""" |
330 | 220 | self.ref_count += 1 | 219 | self.ref_count += 1 |
333 | 221 | self.sso_proxy.clear_credentials(APP_NAME, | 220 | self.sso_proxy.clear_credentials( |
334 | 222 | dbus.Dictionary({}, signature='ss'), | 221 | APP_NAME, dbus.Dictionary({}, signature='ss'), |
335 | 223 | reply_handler=reply_handler, error_handler=error_handler) | 222 | reply_handler=reply_handler, error_handler=error_handler) |
336 | 224 | 223 | ||
337 | 225 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, | 224 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, |
338 | @@ -229,7 +228,8 @@ | |||
339 | 229 | reply_handler=NO_OP, error_handler=NO_OP): | 228 | reply_handler=NO_OP, error_handler=NO_OP): |
340 | 230 | """Store the token for Magicicada application.""" | 229 | """Store the token for Magicicada application.""" |
341 | 231 | self.ref_count += 1 | 230 | self.ref_count += 1 |
343 | 232 | self.sso_proxy.store_credentials(APP_NAME, credentials, | 231 | self.sso_proxy.store_credentials( |
344 | 232 | APP_NAME, credentials, | ||
345 | 233 | reply_handler=reply_handler, error_handler=error_handler) | 233 | reply_handler=reply_handler, error_handler=error_handler) |
346 | 234 | 234 | ||
347 | 235 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, | 235 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, |
348 | @@ -240,7 +240,8 @@ | |||
349 | 240 | self.ref_count += 1 | 240 | self.ref_count += 1 |
350 | 241 | params = dict(UI_PARAMS) | 241 | params = dict(UI_PARAMS) |
351 | 242 | params.update(args) | 242 | params.update(args) |
353 | 243 | self.sso_proxy.register(APP_NAME, params, | 243 | self.sso_proxy.register( |
354 | 244 | APP_NAME, params, | ||
355 | 244 | reply_handler=reply_handler, error_handler=error_handler) | 245 | reply_handler=reply_handler, error_handler=error_handler) |
356 | 245 | 246 | ||
357 | 246 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, | 247 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, |
358 | @@ -251,7 +252,8 @@ | |||
359 | 251 | self.ref_count += 1 | 252 | self.ref_count += 1 |
360 | 252 | params = dict(UI_PARAMS) | 253 | params = dict(UI_PARAMS) |
361 | 253 | params.update(args) | 254 | params.update(args) |
363 | 254 | self.sso_proxy.login(APP_NAME, params, | 255 | self.sso_proxy.login( |
364 | 256 | APP_NAME, params, | ||
365 | 255 | reply_handler=reply_handler, error_handler=error_handler) | 257 | reply_handler=reply_handler, error_handler=error_handler) |
366 | 256 | 258 | ||
367 | 257 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, | 259 | @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE, |
368 | @@ -263,7 +265,8 @@ | |||
369 | 263 | self.ref_count += 1 | 265 | self.ref_count += 1 |
370 | 264 | params = dict(UI_PARAMS) | 266 | params = dict(UI_PARAMS) |
371 | 265 | params.update(args) | 267 | params.update(args) |
373 | 266 | self.sso_proxy.login_email_password(APP_NAME, params, | 268 | self.sso_proxy.login_email_password( |
374 | 269 | APP_NAME, params, | ||
375 | 267 | reply_handler=reply_handler, error_handler=error_handler) | 270 | reply_handler=reply_handler, error_handler=error_handler) |
376 | 268 | 271 | ||
377 | 269 | 272 | ||
378 | 270 | 273 | ||
379 | === modified file 'ubuntuone/platform/credentials/ipc_service.py' | |||
380 | --- ubuntuone/platform/credentials/ipc_service.py 2015-09-17 02:20:40 +0000 | |||
381 | +++ ubuntuone/platform/credentials/ipc_service.py 2015-09-19 23:19:46 +0000 | |||
382 | @@ -58,7 +58,7 @@ | |||
383 | 58 | 58 | ||
384 | 59 | if app_name != APP_NAME: | 59 | if app_name != APP_NAME: |
385 | 60 | # This fixed bug #818190: filter signals not related to APP_NAME | 60 | # This fixed bug #818190: filter signals not related to APP_NAME |
387 | 61 | logger.info('Received %r but app_name %r does not match %r, ' \ | 61 | logger.info('Received %r but app_name %r does not match %r, ' |
388 | 62 | 'exiting.', self.signal_name, app_name, APP_NAME) | 62 | 'exiting.', self.signal_name, app_name, APP_NAME) |
389 | 63 | return | 63 | return |
390 | 64 | 64 | ||
391 | 65 | 65 | ||
392 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/__init__.py' | |||
393 | --- ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2012-09-19 17:39:26 +0000 | |||
394 | +++ ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2015-09-19 23:19:46 +0000 | |||
395 | @@ -34,8 +34,8 @@ | |||
396 | 34 | from twisted.internet import defer | 34 | from twisted.internet import defer |
397 | 35 | 35 | ||
398 | 36 | DEFAULT_MONITOR = 'default' | 36 | DEFAULT_MONITOR = 'default' |
401 | 37 | logger = logging.getLogger('ubuntuone.SyncDaemon.platform.' + | 37 | logger = logging.getLogger( |
402 | 38 | 'filesystem_notifications.monitor') | 38 | 'ubuntuone.SyncDaemon.platform.filesystem_notifications.monitor') |
403 | 39 | 39 | ||
404 | 40 | 40 | ||
405 | 41 | class NoAvailableMonitorError(Exception): | 41 | class NoAvailableMonitorError(Exception): |
406 | 42 | 42 | ||
407 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/common.py' | |||
408 | --- ubuntuone/platform/filesystem_notifications/monitor/common.py 2013-01-16 00:08:52 +0000 | |||
409 | +++ ubuntuone/platform/filesystem_notifications/monitor/common.py 2015-09-19 23:19:46 +0000 | |||
410 | @@ -104,8 +104,9 @@ | |||
411 | 104 | # platform watch used to deal with the platform details | 104 | # platform watch used to deal with the platform details |
412 | 105 | self.platform_watch = PlatformWatch(self.path, self.process_events) | 105 | self.platform_watch = PlatformWatch(self.path, self.process_events) |
413 | 106 | 106 | ||
416 | 107 | self.log = logging.getLogger('ubuntuone.SyncDaemon.platform.common.' + | 107 | self.log = logging.getLogger( |
417 | 108 | 'filesystem_notifications.Watch') | 108 | 'ubuntuone.SyncDaemon.platform.common.filesystem_notifications.' |
418 | 109 | 'Watch') | ||
419 | 109 | self.log.setLevel(TRACE) | 110 | self.log.setLevel(TRACE) |
420 | 110 | 111 | ||
421 | 111 | def process_events(self, action, file_name, cookie, syncdaemon_path): | 112 | def process_events(self, action, file_name, cookie, syncdaemon_path): |
422 | @@ -249,8 +250,9 @@ | |||
423 | 249 | 250 | ||
424 | 250 | def __init__(self, processor): | 251 | def __init__(self, processor): |
425 | 251 | """Init the manager to keep trak of the different watches.""" | 252 | """Init the manager to keep trak of the different watches.""" |
428 | 252 | self.log = logging.getLogger('ubuntuone.SyncDaemon.platform.common.' | 253 | self.log = logging.getLogger( |
429 | 253 | + 'filesystem_notifications.WatchManager') | 254 | 'ubuntuone.SyncDaemon.platform.common.filesystem_notifications.' |
430 | 255 | 'WatchManager') | ||
431 | 254 | self.log.setLevel(TRACE) | 256 | self.log.setLevel(TRACE) |
432 | 255 | self._processor = processor | 257 | self._processor = processor |
433 | 256 | # use the platform manager to perform the actual actions | 258 | # use the platform manager to perform the actual actions |
434 | @@ -388,8 +390,8 @@ | |||
435 | 388 | """Add watch to a dir.""" | 390 | """Add watch to a dir.""" |
436 | 389 | # the logic to check if the watch is already set | 391 | # the logic to check if the watch is already set |
437 | 390 | # is all in WatchManager.add_watch | 392 | # is all in WatchManager.add_watch |
440 | 391 | return self._watch_manager.add_watch(dirpath, | 393 | return self._watch_manager.add_watch( |
441 | 392 | self.filesystem_monitor_mask) | 394 | dirpath, self.filesystem_monitor_mask) |
442 | 393 | 395 | ||
443 | 394 | def add_watches_to_udf_ancestors(self, volume): | 396 | def add_watches_to_udf_ancestors(self, volume): |
444 | 395 | """Add a inotify watch to volume's ancestors if it's an UDF.""" | 397 | """Add a inotify watch to volume's ancestors if it's an UDF.""" |
445 | 396 | 398 | ||
446 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_client.py' | |||
447 | --- ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_client.py 2013-01-14 21:42:39 +0000 | |||
448 | +++ ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_client.py 2015-09-19 23:19:46 +0000 | |||
449 | @@ -78,8 +78,8 @@ | |||
450 | 78 | self.watching = False | 78 | self.watching = False |
451 | 79 | self.ignore_paths = [] | 79 | self.ignore_paths = [] |
452 | 80 | # Create stream with folder to watch | 80 | # Create stream with folder to watch |
455 | 81 | self.stream = fsevents.Stream(self._process_events, | 81 | self.stream = fsevents.Stream( |
456 | 82 | path, file_events=True) | 82 | self._process_events, path, file_events=True) |
457 | 83 | 83 | ||
458 | 84 | def _process_events(self, event): | 84 | def _process_events(self, event): |
459 | 85 | """Receive the filesystem event and move it to the main thread.""" | 85 | """Receive the filesystem event and move it to the main thread.""" |
460 | @@ -90,8 +90,8 @@ | |||
461 | 90 | action, cookie, file_name = (event.mask, event.cookie, event.name) | 90 | action, cookie, file_name = (event.mask, event.cookie, event.name) |
462 | 91 | 91 | ||
463 | 92 | syncdaemon_path = os.path.join(self.path, file_name) | 92 | syncdaemon_path = os.path.join(self.path, file_name) |
466 | 93 | self.process_events(action, file_name, cookie, | 93 | self.process_events( |
467 | 94 | syncdaemon_path) | 94 | action, file_name, cookie, syncdaemon_path) |
468 | 95 | 95 | ||
469 | 96 | def start_watching(self): | 96 | def start_watching(self): |
470 | 97 | """Start watching.""" | 97 | """Start watching.""" |
471 | 98 | 98 | ||
472 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_daemon.py' | |||
473 | --- ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_daemon.py 2012-09-18 23:46:47 +0000 | |||
474 | +++ ubuntuone/platform/filesystem_notifications/monitor/darwin/fsevents_daemon.py 2015-09-19 23:19:46 +0000 | |||
475 | @@ -137,8 +137,8 @@ | |||
476 | 137 | class PyInotifyEventsFactory(fseventsd.FsEventsFactory): | 137 | class PyInotifyEventsFactory(fseventsd.FsEventsFactory): |
477 | 138 | """Factory that process events and converts them in pyinotify ones.""" | 138 | """Factory that process events and converts them in pyinotify ones.""" |
478 | 139 | 139 | ||
481 | 140 | def __init__(self, processor, | 140 | def __init__( |
482 | 141 | ignored_events=DARWIN_IGNORED_ACTIONS): | 141 | self, processor, ignored_events=DARWIN_IGNORED_ACTIONS): |
483 | 142 | """Create a new instance.""" | 142 | """Create a new instance.""" |
484 | 143 | # old style class | 143 | # old style class |
485 | 144 | fseventsd.FsEventsFactory.__init__(self) | 144 | fseventsd.FsEventsFactory.__init__(self) |
486 | @@ -157,9 +157,9 @@ | |||
487 | 157 | def path_is_not_interesting(self, path): | 157 | def path_is_not_interesting(self, path): |
488 | 158 | """Return if the factory is interested in the path.""" | 158 | """Return if the factory is interested in the path.""" |
489 | 159 | is_watched = any(path.startswith(watched_path) | 159 | is_watched = any(path.startswith(watched_path) |
491 | 160 | for watched_path in self.watched_paths) | 160 | for watched_path in self.watched_paths) |
492 | 161 | is_ignored = any(path.startswith(ignored_path) | 161 | is_ignored = any(path.startswith(ignored_path) |
494 | 162 | for ignored_path in self.ignored_paths) | 162 | for ignored_path in self.ignored_paths) |
495 | 163 | return not is_watched or (is_watched and is_ignored) | 163 | return not is_watched or (is_watched and is_ignored) |
496 | 164 | 164 | ||
497 | 165 | def is_create(self, event): | 165 | def is_create(self, event): |
498 | @@ -233,8 +233,9 @@ | |||
499 | 233 | # path of the event. A delete means that we moved from a | 233 | # path of the event. A delete means that we moved from a |
500 | 234 | # watched path for a not watched one and we care about the | 234 | # watched path for a not watched one and we care about the |
501 | 235 | # FIRST path of the event | 235 | # FIRST path of the event |
504 | 236 | path = event.event_paths[1] if is_create\ | 236 | path = ( |
505 | 237 | else event.event_paths[0] | 237 | event.event_paths[1] if is_create else event.event_paths[0] |
506 | 238 | ) | ||
507 | 238 | path = get_syncdaemon_valid_path(path) | 239 | path = get_syncdaemon_valid_path(path) |
508 | 239 | head, tail = os.path.split(path) | 240 | head, tail = os.path.split(path) |
509 | 240 | event_raw_data = { | 241 | event_raw_data = { |
510 | @@ -287,7 +288,8 @@ | |||
511 | 287 | if not path[-1] == os.path.sep: | 288 | if not path[-1] == os.path.sep: |
512 | 288 | path += os.path.sep | 289 | path += os.path.sep |
513 | 289 | 290 | ||
515 | 290 | is_ignored_child = any(ignored in path for ignored in self.ignored_paths) | 291 | is_ignored_child = any( |
516 | 292 | ignored in path for ignored in self.ignored_paths) | ||
517 | 291 | return path in self.ignored_paths or is_ignored_child | 293 | return path in self.ignored_paths or is_ignored_child |
518 | 292 | 294 | ||
519 | 293 | def process_event(self, event): | 295 | def process_event(self, event): |
520 | @@ -400,9 +402,11 @@ | |||
521 | 400 | if not dirpath[-1] == os.path.sep: | 402 | if not dirpath[-1] == os.path.sep: |
522 | 401 | dirpath = dirpath + os.path.sep | 403 | dirpath = dirpath + os.path.sep |
523 | 402 | 404 | ||
527 | 403 | # if we are watching a parent dir we can just ensure that it is not ignored | 405 | # if we are watching a parent dir we can just ensure that it is not |
528 | 404 | if any(dirpath.startswith(watched_path) for watched_path in | 406 | # ignored |
529 | 405 | self._factory.watched_paths): | 407 | parent_watched = any(dirpath.startswith(watched_path) |
530 | 408 | for watched_path in self._factory.watched_paths) | ||
531 | 409 | if parent_watched: | ||
532 | 406 | if dirpath in self._factory.ignored_paths: | 410 | if dirpath in self._factory.ignored_paths: |
533 | 407 | self._factory.ignored_paths.remove(dirpath) | 411 | self._factory.ignored_paths.remove(dirpath) |
534 | 408 | defer.returnValue(True) | 412 | defer.returnValue(True) |
535 | 409 | 413 | ||
536 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/linux.py' | |||
537 | --- ubuntuone/platform/filesystem_notifications/monitor/linux.py 2012-07-18 09:05:26 +0000 | |||
538 | +++ ubuntuone/platform/filesystem_notifications/monitor/linux.py 2015-09-19 23:19:46 +0000 | |||
539 | @@ -98,8 +98,9 @@ | |||
540 | 98 | if event.mask & pyinotify.IN_ISDIR: | 98 | if event.mask & pyinotify.IN_ISDIR: |
541 | 99 | unsubscribed_udfs = set() | 99 | unsubscribed_udfs = set() |
542 | 100 | for udf in self._get_udfs(event.pathname): | 100 | for udf in self._get_udfs(event.pathname): |
545 | 101 | self.log.info("Got MOVED_FROM on path %r, unsubscribing " | 101 | self.log.info( |
546 | 102 | "udf %s", event.pathname, udf) | 102 | "Got MOVED_FROM on path %r, unsubscribing udf %s", |
547 | 103 | event.pathname, udf) | ||
548 | 103 | self.monitor.fs.vm.unsubscribe_udf(udf.volume_id) | 104 | self.monitor.fs.vm.unsubscribe_udf(udf.volume_id) |
549 | 104 | unsubscribed_udfs.add(udf) | 105 | unsubscribed_udfs.add(udf) |
550 | 105 | self._unwatch_ancestors(unsubscribed_udfs) | 106 | self._unwatch_ancestors(unsubscribed_udfs) |
551 | @@ -109,8 +110,9 @@ | |||
552 | 109 | if event.mask & pyinotify.IN_ISDIR: | 110 | if event.mask & pyinotify.IN_ISDIR: |
553 | 110 | deleted_udfs = set() | 111 | deleted_udfs = set() |
554 | 111 | for udf in self._get_udfs(event.pathname): | 112 | for udf in self._get_udfs(event.pathname): |
557 | 112 | self.log.info("Got DELETE on path %r, deleting udf %s", | 113 | self.log.info( |
558 | 113 | event.pathname, udf) | 114 | "Got DELETE on path %r, deleting udf %s", |
559 | 115 | event.pathname, udf) | ||
560 | 114 | self.monitor.fs.vm.delete_volume(udf.volume_id) | 116 | self.monitor.fs.vm.delete_volume(udf.volume_id) |
561 | 115 | deleted_udfs.add(udf) | 117 | deleted_udfs.add(udf) |
562 | 116 | self._unwatch_ancestors(deleted_udfs) | 118 | self._unwatch_ancestors(deleted_udfs) |
563 | @@ -124,8 +126,8 @@ | |||
564 | 124 | 126 | ||
565 | 125 | # collect the ancestors of all the still subscribed UDFs except | 127 | # collect the ancestors of all the still subscribed UDFs except |
566 | 126 | # the received ones | 128 | # the received ones |
569 | 127 | sub_udfs = (u for u in self.monitor.fs.vm.udfs.itervalues() \ | 129 | sub_udfs = ( |
570 | 128 | if u.subscribed) | 130 | u for u in self.monitor.fs.vm.udfs.itervalues() if u.subscribed) |
571 | 129 | udf_remain = set(sub_udfs) - udfs | 131 | udf_remain = set(sub_udfs) - udfs |
572 | 130 | ancestors_to_keep = set() | 132 | ancestors_to_keep = set() |
573 | 131 | for udf in udf_remain: | 133 | for udf in udf_remain: |
574 | @@ -150,7 +152,7 @@ | |||
575 | 150 | self._processor = notify_processor.NotifyProcessor(self, ignore_config) | 152 | self._processor = notify_processor.NotifyProcessor(self, ignore_config) |
576 | 151 | self._inotify_notifier_gral = pyinotify.Notifier(wm, self._processor) | 153 | self._inotify_notifier_gral = pyinotify.Notifier(wm, self._processor) |
577 | 152 | self._inotify_reader_gral = self._hook_inotify_to_twisted( | 154 | self._inotify_reader_gral = self._hook_inotify_to_twisted( |
579 | 153 | wm, self._inotify_notifier_gral) | 155 | wm, self._inotify_notifier_gral) |
580 | 154 | self._general_watchs = {} | 156 | self._general_watchs = {} |
581 | 155 | 157 | ||
582 | 156 | # ancestors inotify | 158 | # ancestors inotify |
583 | @@ -158,7 +160,7 @@ | |||
584 | 158 | antr_processor = _AncestorsINotifyProcessor(self) | 160 | antr_processor = _AncestorsINotifyProcessor(self) |
585 | 159 | self._inotify_notifier_antr = pyinotify.Notifier(wm, antr_processor) | 161 | self._inotify_notifier_antr = pyinotify.Notifier(wm, antr_processor) |
586 | 160 | self._inotify_reader_antr = self._hook_inotify_to_twisted( | 162 | self._inotify_reader_antr = self._hook_inotify_to_twisted( |
588 | 161 | wm, self._inotify_notifier_antr) | 163 | wm, self._inotify_notifier_antr) |
589 | 162 | self._ancestors_watchs = {} | 164 | self._ancestors_watchs = {} |
590 | 163 | 165 | ||
591 | 164 | @classmethod | 166 | @classmethod |
592 | @@ -180,11 +182,10 @@ | |||
593 | 180 | 182 | ||
594 | 181 | class MyReader(abstract.FileDescriptor): | 183 | class MyReader(abstract.FileDescriptor): |
595 | 182 | """Chain between inotify and twisted.""" | 184 | """Chain between inotify and twisted.""" |
597 | 183 | # will never pass a fd to write, pylint: disable-msg=W0223 | 185 | # will never pass a fd to write |
598 | 184 | 186 | ||
599 | 185 | def fileno(self): | 187 | def fileno(self): |
600 | 186 | """Returns the fileno to select().""" | 188 | """Returns the fileno to select().""" |
601 | 187 | # pylint: disable-msg=W0212 | ||
602 | 188 | return wm._fd | 189 | return wm._fd |
603 | 189 | 190 | ||
604 | 190 | def doRead(self): | 191 | def doRead(self): |
605 | 191 | 192 | ||
606 | === modified file 'ubuntuone/platform/filesystem_notifications/monitor/windows.py' | |||
607 | --- ubuntuone/platform/filesystem_notifications/monitor/windows.py 2013-01-14 21:42:39 +0000 | |||
608 | +++ ubuntuone/platform/filesystem_notifications/monitor/windows.py 2015-09-19 23:19:46 +0000 | |||
609 | @@ -120,8 +120,9 @@ | |||
610 | 120 | self.path = os.path.abspath(path) | 120 | self.path = os.path.abspath(path) |
611 | 121 | self.process_events = process_events | 121 | self.process_events = process_events |
612 | 122 | self.watching = False | 122 | self.watching = False |
615 | 123 | self.log = logging.getLogger('ubuntuone.SyncDaemon.platform.windows.' + | 123 | self.log = logging.getLogger( |
616 | 124 | 'filesystem_notifications.Watch') | 124 | 'ubuntuone.SyncDaemon.platform.windows.filesystem_notifications.' |
617 | 125 | 'Watch') | ||
618 | 125 | self.log.setLevel(logging.DEBUG) | 126 | self.log.setLevel(logging.DEBUG) |
619 | 126 | self._buf_size = buf_size | 127 | self._buf_size = buf_size |
620 | 127 | self._mask = mask | 128 | self._mask = mask |
621 | @@ -143,9 +144,9 @@ | |||
622 | 143 | # and then use the proc_fun | 144 | # and then use the proc_fun |
623 | 144 | for action, file_name in events: | 145 | for action, file_name in events: |
624 | 145 | syncdaemon_path = get_syncdaemon_valid_path( | 146 | syncdaemon_path = get_syncdaemon_valid_path( |
628 | 146 | os.path.join(self.path, file_name)) | 147 | os.path.join(self.path, file_name)) |
629 | 147 | self.process_events(action, file_name, str(uuid4()), | 148 | self.process_events( |
630 | 148 | syncdaemon_path) | 149 | action, file_name, str(uuid4()), syncdaemon_path) |
631 | 149 | 150 | ||
632 | 150 | def _call_deferred(self, f, *args): | 151 | def _call_deferred(self, f, *args): |
633 | 151 | """Executes the deferred call avoiding possible race conditions.""" | 152 | """Executes the deferred call avoiding possible race conditions.""" |
634 | @@ -156,9 +157,10 @@ | |||
635 | 156 | """Wrap _watch, and errback on any unhandled error.""" | 157 | """Wrap _watch, and errback on any unhandled error.""" |
636 | 157 | try: | 158 | try: |
637 | 158 | self._watch() | 159 | self._watch() |
641 | 159 | except Exception: | 160 | except Exception as e: |
642 | 160 | reactor.callFromThread(self._call_deferred, | 161 | reactor.callFromThread( |
643 | 161 | self._watch_started_deferred.errback, Failure()) | 162 | self._call_deferred, self._watch_started_deferred.errback, |
644 | 163 | Failure(e)) | ||
645 | 162 | 164 | ||
646 | 163 | def _watch(self): | 165 | def _watch(self): |
647 | 164 | """Watch a path that is a directory.""" | 166 | """Watch a path that is a directory.""" |
648 | @@ -201,13 +203,13 @@ | |||
649 | 201 | self._overlapped, | 203 | self._overlapped, |
650 | 202 | ) | 204 | ) |
651 | 203 | if not self._watch_started_deferred.called: | 205 | if not self._watch_started_deferred.called: |
654 | 204 | reactor.callFromThread(self._call_deferred, | 206 | reactor.callFromThread( |
655 | 205 | self._watch_started_deferred.callback, True) | 207 | self._call_deferred, self._watch_started_deferred.callback, |
656 | 208 | True) | ||
657 | 206 | # wait for an event and ensure that we either stop or read the | 209 | # wait for an event and ensure that we either stop or read the |
658 | 207 | # data | 210 | # data |
662 | 208 | rc = WaitForMultipleObjects((self._wait_stop, | 211 | rc = WaitForMultipleObjects( |
663 | 209 | self._overlapped.hEvent), | 212 | (self._wait_stop, self._overlapped.hEvent), 0, INFINITE) |
661 | 210 | 0, INFINITE) | ||
664 | 211 | if rc == WAIT_OBJECT_0: | 213 | if rc == WAIT_OBJECT_0: |
665 | 212 | # Stop event | 214 | # Stop event |
666 | 213 | break | 215 | break |
667 | @@ -215,9 +217,9 @@ | |||
668 | 215 | data = GetOverlappedResult(handle, self._overlapped, True) | 217 | data = GetOverlappedResult(handle, self._overlapped, True) |
669 | 216 | # lets ead the data and store it in the results | 218 | # lets ead the data and store it in the results |
670 | 217 | events = FILE_NOTIFY_INFORMATION(buf, data) | 219 | events = FILE_NOTIFY_INFORMATION(buf, data) |
674 | 218 | self.log.debug('Got from ReadDirectoryChangesW %r.', | 220 | self.log.debug( |
675 | 219 | [(ACTIONS_NAMES[action], path) \ | 221 | 'Got from ReadDirectoryChangesW %r.', |
676 | 220 | for action, path in events]) | 222 | [(ACTIONS_NAMES[action], path) for action, path in events]) |
677 | 221 | reactor.callFromThread(self._process_events, events) | 223 | reactor.callFromThread(self._process_events, events) |
678 | 222 | 224 | ||
679 | 223 | def start_watching(self): | 225 | def start_watching(self): |
680 | 224 | 226 | ||
681 | === modified file 'ubuntuone/platform/filesystem_notifications/notify_processor/common.py' | |||
682 | --- ubuntuone/platform/filesystem_notifications/notify_processor/common.py 2012-07-13 11:26:31 +0000 | |||
683 | +++ ubuntuone/platform/filesystem_notifications/notify_processor/common.py 2015-09-19 23:19:46 +0000 | |||
684 | @@ -99,8 +99,8 @@ | |||
685 | 99 | """ | 99 | """ |
686 | 100 | 100 | ||
687 | 101 | def __init__(self, monitor, ignore_config=None): | 101 | def __init__(self, monitor, ignore_config=None): |
690 | 102 | self.general_processor = GeneralINotifyProcessor(monitor, | 102 | self.general_processor = GeneralINotifyProcessor( |
691 | 103 | self.handle_dir_delete, NAME_TRANSLATIONS, | 103 | monitor, self.handle_dir_delete, NAME_TRANSLATIONS, |
692 | 104 | path_is_ignored, IN_IGNORED, ignore_config=ignore_config) | 104 | path_is_ignored, IN_IGNORED, ignore_config=ignore_config) |
693 | 105 | self.held_event = None | 105 | self.held_event = None |
694 | 106 | 106 | ||
695 | @@ -130,10 +130,10 @@ | |||
696 | 130 | # on someplatforms we just get IN_MODIFY, lets always fake | 130 | # on someplatforms we just get IN_MODIFY, lets always fake |
697 | 131 | # an OPEN & CLOSE_WRITE couple | 131 | # an OPEN & CLOSE_WRITE couple |
698 | 132 | raw_open = raw_close = { | 132 | raw_open = raw_close = { |
703 | 133 | 'wd': event.wd, | 133 | 'wd': event.wd, |
704 | 134 | 'dir': event.dir, | 134 | 'dir': event.dir, |
705 | 135 | 'name': event.name, | 135 | 'name': event.name, |
706 | 136 | 'path': event.path} | 136 | 'path': event.path} |
707 | 137 | # caculate the open mask | 137 | # caculate the open mask |
708 | 138 | raw_open['mask'] = IN_OPEN | 138 | raw_open['mask'] = IN_OPEN |
709 | 139 | # create the event using the raw data, then fix the pathname param | 139 | # create the event using the raw data, then fix the pathname param |
710 | @@ -165,7 +165,7 @@ | |||
711 | 165 | self.general_processor.eq_push(evtname + "CREATE", path=event.pathname) | 165 | self.general_processor.eq_push(evtname + "CREATE", path=event.pathname) |
712 | 166 | if not event.dir: | 166 | if not event.dir: |
713 | 167 | self.general_processor.eq_push('FS_FILE_CLOSE_WRITE', | 167 | self.general_processor.eq_push('FS_FILE_CLOSE_WRITE', |
715 | 168 | path=event.pathname) | 168 | path=event.pathname) |
716 | 169 | 169 | ||
717 | 170 | def _fake_delete_create_event(self, event): | 170 | def _fake_delete_create_event(self, event): |
718 | 171 | """Fake the deletion and the creation.""" | 171 | """Fake the deletion and the creation.""" |
719 | @@ -182,7 +182,7 @@ | |||
720 | 182 | self.general_processor.eq_push(evtname + "CREATE", path=event.pathname) | 182 | self.general_processor.eq_push(evtname + "CREATE", path=event.pathname) |
721 | 183 | if not event.dir: | 183 | if not event.dir: |
722 | 184 | self.general_processor.eq_push('FS_FILE_CLOSE_WRITE', | 184 | self.general_processor.eq_push('FS_FILE_CLOSE_WRITE', |
724 | 185 | path=event.pathname) | 185 | path=event.pathname) |
725 | 186 | 186 | ||
726 | 187 | def process_IN_MOVED_TO(self, event): | 187 | def process_IN_MOVED_TO(self, event): |
727 | 188 | """Capture the MOVED_TO to maybe syntethize FILE_MOVED.""" | 188 | """Capture the MOVED_TO to maybe syntethize FILE_MOVED.""" |
728 | @@ -206,7 +206,8 @@ | |||
729 | 206 | evtname = "FS_DIR_" | 206 | evtname = "FS_DIR_" |
730 | 207 | else: | 207 | else: |
731 | 208 | evtname = "FS_FILE_" | 208 | evtname = "FS_FILE_" |
733 | 209 | self.general_processor.eq_push(evtname + "MOVE", | 209 | self.general_processor.eq_push( |
734 | 210 | evtname + "MOVE", | ||
735 | 210 | path_from=self.held_event.pathname, | 211 | path_from=self.held_event.pathname, |
736 | 211 | path_to=event.pathname) | 212 | path_to=event.pathname) |
737 | 212 | elif is_to_forreal: | 213 | elif is_to_forreal: |
738 | @@ -223,7 +224,7 @@ | |||
739 | 223 | # We should never get here, I really do not know how we | 224 | # We should never get here, I really do not know how we |
740 | 224 | # got here | 225 | # got here |
741 | 225 | self.general_processor.log.warn( | 226 | self.general_processor.log.warn( |
743 | 226 | 'Cookie does not match the previoues held event!') | 227 | 'Cookie does not match the previoues held event!') |
744 | 227 | self.general_processor.log.warn('Ignoring %s', event) | 228 | self.general_processor.log.warn('Ignoring %s', event) |
745 | 228 | 229 | ||
746 | 229 | def process_default(self, event): | 230 | def process_default(self, event): |
747 | @@ -240,8 +241,8 @@ | |||
748 | 240 | self.general_processor.rm_watch(fullpath) | 241 | self.general_processor.rm_watch(fullpath) |
749 | 241 | 242 | ||
750 | 242 | # handle the case of move a dir to a non-watched directory | 243 | # handle the case of move a dir to a non-watched directory |
753 | 243 | paths = self.general_processor.get_paths_starting_with(fullpath, | 244 | paths = self.general_processor.get_paths_starting_with( |
754 | 244 | include_base=False) | 245 | fullpath, include_base=False) |
755 | 245 | 246 | ||
756 | 246 | paths.sort(reverse=True) | 247 | paths.sort(reverse=True) |
757 | 247 | for path, is_dir in paths: | 248 | for path, is_dir in paths: |
758 | 248 | 249 | ||
759 | === modified file 'ubuntuone/platform/filesystem_notifications/notify_processor/linux.py' | |||
760 | --- ubuntuone/platform/filesystem_notifications/notify_processor/linux.py 2012-07-13 11:26:31 +0000 | |||
761 | +++ ubuntuone/platform/filesystem_notifications/notify_processor/linux.py 2015-09-19 23:19:46 +0000 | |||
762 | @@ -79,10 +79,10 @@ | |||
763 | 79 | event.name.decode("utf8") | 79 | event.name.decode("utf8") |
764 | 80 | except UnicodeDecodeError: | 80 | except UnicodeDecodeError: |
765 | 81 | dirname = event.path.decode("utf8") | 81 | dirname = event.path.decode("utf8") |
770 | 82 | self.general_processor.invnames_log.info("%s in %r: path %r", | 82 | self.general_processor.invnames_log.info( |
771 | 83 | event.maskname, dirname, event.name) | 83 | "%s in %r: path %r", event.maskname, dirname, event.name) |
772 | 84 | self.general_processor.monitor.eq.push('FS_INVALID_NAME', | 84 | self.general_processor.monitor.eq.push( |
773 | 85 | dirname=dirname, filename=event.name) | 85 | 'FS_INVALID_NAME', dirname=dirname, filename=event.name) |
774 | 86 | else: | 86 | else: |
775 | 87 | real_func(self, event) | 87 | real_func(self, event) |
776 | 88 | return func | 88 | return func |
777 | @@ -95,8 +95,8 @@ | |||
778 | 95 | FS_(DIR|FILE)_MOVE event when possible. | 95 | FS_(DIR|FILE)_MOVE event when possible. |
779 | 96 | """ | 96 | """ |
780 | 97 | def __init__(self, monitor, ignore_config=None): | 97 | def __init__(self, monitor, ignore_config=None): |
783 | 98 | self.general_processor = GeneralINotifyProcessor(monitor, | 98 | self.general_processor = GeneralINotifyProcessor( |
784 | 99 | self.handle_dir_delete, NAME_TRANSLATIONS, | 99 | monitor, self.handle_dir_delete, NAME_TRANSLATIONS, |
785 | 100 | self.platform_is_ignored, pyinotify.IN_IGNORED, | 100 | self.platform_is_ignored, pyinotify.IN_IGNORED, |
786 | 101 | ignore_config=ignore_config) | 101 | ignore_config=ignore_config) |
787 | 102 | self.held_event = None | 102 | self.held_event = None |
788 | @@ -218,12 +218,13 @@ | |||
789 | 218 | path=t_path) | 218 | path=t_path) |
790 | 219 | if not event.dir: | 219 | if not event.dir: |
791 | 220 | self.general_processor.eq_push( | 220 | self.general_processor.eq_push( |
793 | 221 | 'FS_FILE_CLOSE_WRITE', path=t_path) | 221 | 'FS_FILE_CLOSE_WRITE', path=t_path) |
794 | 222 | else: | 222 | else: |
795 | 223 | self.general_processor.monitor.inotify_watch_fix( | 223 | self.general_processor.monitor.inotify_watch_fix( |
799 | 224 | f_path, t_path) | 224 | f_path, t_path) |
800 | 225 | self.general_processor.eq_push(evtname + "MOVE", | 225 | self.general_processor.eq_push( |
801 | 226 | path_from=f_path, path_to=t_path) | 226 | evtname + "MOVE", path_from=f_path, |
802 | 227 | path_to=t_path) | ||
803 | 227 | elif is_to_forreal: | 228 | elif is_to_forreal: |
804 | 228 | # this is the case of a MOVE from something ignored | 229 | # this is the case of a MOVE from something ignored |
805 | 229 | # to a valid filename | 230 | # to a valid filename |
806 | @@ -235,7 +236,7 @@ | |||
807 | 235 | path=t_path) | 236 | path=t_path) |
808 | 236 | if not event.dir: | 237 | if not event.dir: |
809 | 237 | self.general_processor.eq_push( | 238 | self.general_processor.eq_push( |
811 | 238 | 'FS_FILE_CLOSE_WRITE', path=t_path) | 239 | 'FS_FILE_CLOSE_WRITE', path=t_path) |
812 | 239 | 240 | ||
813 | 240 | else: | 241 | else: |
814 | 241 | # this is the case of a MOVE from something valid | 242 | # this is the case of a MOVE from something valid |
815 | @@ -259,8 +260,8 @@ | |||
816 | 259 | self.general_processor.push_event(event) | 260 | self.general_processor.push_event(event) |
817 | 260 | if not event.dir: | 261 | if not event.dir: |
818 | 261 | t_path = os.path.join(event.path, event.name) | 262 | t_path = os.path.join(event.path, event.name) |
821 | 262 | self.general_processor.eq_push('FS_FILE_CLOSE_WRITE', | 263 | self.general_processor.eq_push( |
822 | 263 | path=t_path) | 264 | 'FS_FILE_CLOSE_WRITE', path=t_path) |
823 | 264 | 265 | ||
824 | 265 | @validate_filename | 266 | @validate_filename |
825 | 266 | def process_default(self, event): | 267 | def process_default(self, event): |
826 | @@ -293,8 +294,8 @@ | |||
827 | 293 | self.general_processor.rm_watch(fullpath) | 294 | self.general_processor.rm_watch(fullpath) |
828 | 294 | 295 | ||
829 | 295 | # handle the case of move a dir to a non-watched directory | 296 | # handle the case of move a dir to a non-watched directory |
832 | 296 | paths = self.general_processor.get_paths_starting_with(fullpath, | 297 | paths = self.general_processor.get_paths_starting_with( |
833 | 297 | include_base=False) | 298 | fullpath, include_base=False) |
834 | 298 | 299 | ||
835 | 299 | paths.sort(reverse=True) | 300 | paths.sort(reverse=True) |
836 | 300 | for path, is_dir in paths: | 301 | for path, is_dir in paths: |
837 | 301 | 302 | ||
838 | === modified file 'ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py' | |||
839 | --- ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py 2012-07-02 09:10:10 +0000 | |||
840 | +++ ubuntuone/platform/filesystem_notifications/pyinotify_agnostic.py 2015-09-19 23:19:46 +0000 | |||
841 | @@ -18,16 +18,20 @@ | |||
842 | 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
843 | 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
844 | 20 | # THE SOFTWARE. | 20 | # THE SOFTWARE. |
845 | 21 | |||
846 | 21 | """Platform agnostic code grabed from pyinotify.""" | 22 | """Platform agnostic code grabed from pyinotify.""" |
847 | 23 | |||
848 | 22 | import logging | 24 | import logging |
849 | 23 | import os | 25 | import os |
850 | 24 | import sys | 26 | import sys |
851 | 25 | 27 | ||
852 | 28 | |||
853 | 26 | COMPATIBILITY_MODE = False | 29 | COMPATIBILITY_MODE = False |
854 | 30 | IN_ISDIR = '???' | ||
855 | 31 | |||
856 | 27 | 32 | ||
857 | 28 | class PyinotifyError(Exception): | 33 | class PyinotifyError(Exception): |
858 | 29 | """Indicates exceptions raised by a Pyinotify class.""" | 34 | """Indicates exceptions raised by a Pyinotify class.""" |
859 | 30 | pass | ||
860 | 31 | 35 | ||
861 | 32 | 36 | ||
862 | 33 | class RawOutputFormat: | 37 | class RawOutputFormat: |
863 | @@ -121,36 +125,34 @@ | |||
864 | 121 | # The idea here is 'configuration-as-code' - this way, we get | 125 | # The idea here is 'configuration-as-code' - this way, we get |
865 | 122 | # our nice class constants, but we also get nice human-friendly text | 126 | # our nice class constants, but we also get nice human-friendly text |
866 | 123 | # mappings to do lookups against as well, for free: | 127 | # mappings to do lookups against as well, for free: |
897 | 124 | FLAG_COLLECTIONS = {'OP_FLAGS': { | 128 | FLAG_COLLECTIONS = { |
898 | 125 | 'IN_ACCESS' : 0x00000001, # File was accessed | 129 | 'OP_FLAGS': { |
899 | 126 | 'IN_MODIFY' : 0x00000002, # File was modified | 130 | 'IN_ACCESS': 0x00000001, # File was accessed |
900 | 127 | 'IN_ATTRIB' : 0x00000004, # Metadata changed | 131 | 'IN_MODIFY': 0x00000002, # File was modified |
901 | 128 | 'IN_CLOSE_WRITE' : 0x00000008, # Writable file was closed | 132 | 'IN_ATTRIB': 0x00000004, # Metadata changed |
902 | 129 | 'IN_CLOSE_NOWRITE' : 0x00000010, # Unwritable file closed | 133 | 'IN_CLOSE_WRITE': 0x00000008, # Writable file was closed |
903 | 130 | 'IN_OPEN' : 0x00000020, # File was opened | 134 | 'IN_CLOSE_NOWRITE': 0x00000010, # Unwritable file closed |
904 | 131 | 'IN_MOVED_FROM' : 0x00000040, # File was moved from X | 135 | 'IN_OPEN': 0x00000020, # File was opened |
905 | 132 | 'IN_MOVED_TO' : 0x00000080, # File was moved to Y | 136 | 'IN_MOVED_FROM': 0x00000040, # File was moved from X |
906 | 133 | 'IN_CREATE' : 0x00000100, # Subfile was created | 137 | 'IN_MOVED_TO': 0x00000080, # File was moved to Y |
907 | 134 | 'IN_DELETE' : 0x00000200, # Subfile was deleted | 138 | 'IN_CREATE': 0x00000100, # Subfile was created |
908 | 135 | 'IN_DELETE_SELF' : 0x00000400, # Self (watched item itself) | 139 | 'IN_DELETE': 0x00000200, # Subfile was deleted |
909 | 136 | # was deleted | 140 | 'IN_DELETE_SELF': 0x00000400, # Self was deleted |
910 | 137 | 'IN_MOVE_SELF' : 0x00000800, # Self(watched item itself) was moved | 141 | 'IN_MOVE_SELF': 0x00000800, # Self was moved |
911 | 138 | }, | 142 | }, |
912 | 139 | 'EVENT_FLAGS': { | 143 | 'EVENT_FLAGS': { |
913 | 140 | 'IN_UNMOUNT' : 0x00002000, # Backing fs was unmounted | 144 | 'IN_UNMOUNT': 0x00002000, # Backing fs was unmounted |
914 | 141 | 'IN_Q_OVERFLOW' : 0x00004000, # Event queued overflowed | 145 | 'IN_Q_OVERFLOW': 0x00004000, # Event queued overflowed |
915 | 142 | 'IN_IGNORED' : 0x00008000, # File was ignored | 146 | 'IN_IGNORED': 0x00008000, # File was ignored |
916 | 143 | }, | 147 | }, |
917 | 144 | 'SPECIAL_FLAGS': { | 148 | 'SPECIAL_FLAGS': { |
918 | 145 | 'IN_ONLYDIR' : 0x01000000, # only watch the path if it is a | 149 | 'IN_ONLYDIR': 0x01000000, # only watch the path if it is a dir |
919 | 146 | # directory | 150 | 'IN_DONT_FOLLOW': 0x02000000, # don't follow a symlink |
920 | 147 | 'IN_DONT_FOLLOW' : 0x02000000, # don't follow a symlink | 151 | 'IN_MASK_ADD': 0x20000000, # add to the mask of an existing watch |
921 | 148 | 'IN_MASK_ADD' : 0x20000000, # add to the mask of an already | 152 | 'IN_ISDIR': 0x40000000, # event occurred against dir |
922 | 149 | # existing watch | 153 | 'IN_ONESHOT': 0x80000000, # only send event once |
923 | 150 | 'IN_ISDIR' : 0x40000000, # event occurred against dir | 154 | }, |
924 | 151 | 'IN_ONESHOT' : 0x80000000, # only send event once | 155 | } |
895 | 152 | }, | ||
896 | 153 | } | ||
925 | 154 | 156 | ||
926 | 155 | def maskname(mask): | 157 | def maskname(mask): |
927 | 156 | """ | 158 | """ |
928 | 157 | 159 | ||
929 | === modified file 'ubuntuone/platform/ipc/ipc_client.py' | |||
930 | --- ubuntuone/platform/ipc/ipc_client.py 2012-10-25 14:54:57 +0000 | |||
931 | +++ ubuntuone/platform/ipc/ipc_client.py 2015-09-19 23:19:46 +0000 | |||
932 | @@ -127,11 +127,11 @@ | |||
933 | 127 | for current_key, current_index in callbacks_names: | 127 | for current_key, current_index in callbacks_names: |
934 | 128 | try: | 128 | try: |
935 | 129 | kwargs[current_key] = RemoteHandler( | 129 | kwargs[current_key] = RemoteHandler( |
937 | 130 | kwargs[current_key]) | 130 | kwargs[current_key]) |
938 | 131 | except KeyError: | 131 | except KeyError: |
939 | 132 | if len(args) >= current_index + 1: | 132 | if len(args) >= current_index + 1: |
940 | 133 | fixed_args[current_index] = RemoteHandler( | 133 | fixed_args[current_index] = RemoteHandler( |
942 | 134 | args[current_index]) | 134 | args[current_index]) |
943 | 135 | fixed_args = tuple(fixed_args) | 135 | fixed_args = tuple(fixed_args) |
944 | 136 | return function(*fixed_args, **kwargs) | 136 | return function(*fixed_args, **kwargs) |
945 | 137 | return callbacks_wrapper | 137 | return callbacks_wrapper |
946 | @@ -778,7 +778,6 @@ | |||
947 | 778 | @defer.inlineCallbacks | 778 | @defer.inlineCallbacks |
948 | 779 | def connect(self): | 779 | def connect(self): |
949 | 780 | """Connect to the syncdaemon service.""" | 780 | """Connect to the syncdaemon service.""" |
950 | 781 | # pylint: disable=W0702 | ||
951 | 782 | yield self.connection_lock.acquire() | 781 | yield self.connection_lock.acquire() |
952 | 783 | try: | 782 | try: |
953 | 784 | if self.client is None: | 783 | if self.client is None: |
954 | @@ -789,12 +788,11 @@ | |||
955 | 789 | yield self._request_remote_objects(root) | 788 | yield self._request_remote_objects(root) |
956 | 790 | yield self.register_to_signals() | 789 | yield self.register_to_signals() |
957 | 791 | defer.returnValue(self) | 790 | defer.returnValue(self) |
959 | 792 | except Exception, e: | 791 | except Exception as e: |
960 | 793 | raise SyncDaemonClientConnectionError( | 792 | raise SyncDaemonClientConnectionError( |
962 | 794 | 'Could not connect to the syncdaemon ipc.', e) | 793 | 'Could not connect to the syncdaemon ipc.', e) |
963 | 795 | finally: | 794 | finally: |
964 | 796 | self.connection_lock.release() | 795 | self.connection_lock.release() |
965 | 797 | # pylint: disable=W0702 | ||
966 | 798 | 796 | ||
967 | 799 | @defer.inlineCallbacks | 797 | @defer.inlineCallbacks |
968 | 800 | def reconnect(self): | 798 | def reconnect(self): |
969 | @@ -804,9 +802,9 @@ | |||
970 | 804 | yield self._request_remote_objects(root) | 802 | yield self._request_remote_objects(root) |
971 | 805 | yield self.register_to_signals() | 803 | yield self.register_to_signals() |
972 | 806 | defer.returnValue(self) | 804 | defer.returnValue(self) |
974 | 807 | except Exception, e: | 805 | except Exception as e: |
975 | 808 | raise SyncDaemonClientConnectionError( | 806 | raise SyncDaemonClientConnectionError( |
977 | 809 | 'Could not reconnect to the syncdaemon ipc.', e) | 807 | 'Could not reconnect to the syncdaemon ipc.', e) |
978 | 810 | 808 | ||
979 | 811 | def is_connected(self): | 809 | def is_connected(self): |
980 | 812 | """Return if the client is connected.""" | 810 | """Return if the client is connected.""" |
981 | 813 | 811 | ||
982 | === modified file 'ubuntuone/platform/ipc/linux.py' | |||
983 | --- ubuntuone/platform/ipc/linux.py 2012-10-22 13:31:02 +0000 | |||
984 | +++ ubuntuone/platform/ipc/linux.py 2015-09-19 23:19:46 +0000 | |||
985 | @@ -44,7 +44,6 @@ | |||
986 | 44 | ) | 44 | ) |
987 | 45 | 45 | ||
988 | 46 | # Disable the "Invalid Name" check here, as we have lots of DBus style names | 46 | # Disable the "Invalid Name" check here, as we have lots of DBus style names |
989 | 47 | # pylint: disable-msg=C0103 | ||
990 | 48 | 47 | ||
991 | 49 | DBUS_IFACE_NAME = 'com.ubuntuone.SyncDaemon' | 48 | DBUS_IFACE_NAME = 'com.ubuntuone.SyncDaemon' |
992 | 50 | DBUS_IFACE_SYNC_NAME = DBUS_IFACE_NAME + '.SyncDaemon' | 49 | DBUS_IFACE_SYNC_NAME = DBUS_IFACE_NAME + '.SyncDaemon' |
993 | @@ -391,8 +390,7 @@ | |||
994 | 391 | in_signature='ss', out_signature='a{ss}') | 390 | in_signature='ss', out_signature='a{ss}') |
995 | 392 | def get_metadata_by_node(self, share_id, node_id): | 391 | def get_metadata_by_node(self, share_id, node_id): |
996 | 393 | """Return the metadata (as a dict) for the specified share/node.""" | 392 | """Return the metadata (as a dict) for the specified share/node.""" |
999 | 394 | return self.service.file_system.get_metadata_by_node(share_id, | 393 | return self.service.file_system.get_metadata_by_node(share_id, node_id) |
998 | 395 | node_id) | ||
1000 | 396 | 394 | ||
1001 | 397 | @dbus.service.method(DBUS_IFACE_FS_NAME, | 395 | @dbus.service.method(DBUS_IFACE_FS_NAME, |
1002 | 398 | in_signature='s', out_signature='a{ss}') | 396 | in_signature='s', out_signature='a{ss}') |
1003 | @@ -403,7 +401,7 @@ | |||
1004 | 403 | 401 | ||
1005 | 404 | """ | 402 | """ |
1006 | 405 | return self.service.file_system.get_metadata_and_quick_tree_synced( | 403 | return self.service.file_system.get_metadata_and_quick_tree_synced( |
1008 | 406 | path) | 404 | path) |
1009 | 407 | 405 | ||
1010 | 408 | @dbus.service.method(DBUS_IFACE_FS_NAME, | 406 | @dbus.service.method(DBUS_IFACE_FS_NAME, |
1011 | 409 | in_signature='', out_signature='aa{ss}') | 407 | in_signature='', out_signature='aa{ss}') |
1012 | @@ -851,7 +849,7 @@ | |||
1013 | 851 | """Report an error in changing the public access of a file.""" | 849 | """Report an error in changing the public access of a file.""" |
1014 | 852 | 850 | ||
1015 | 853 | @dbus.service.signal(DBUS_IFACE_PUBLIC_FILES_NAME, | 851 | @dbus.service.signal(DBUS_IFACE_PUBLIC_FILES_NAME, |
1017 | 854 | signature='aa{ss}') | 852 | signature='aa{ss}') |
1018 | 855 | def PublicFilesList(self, files): | 853 | def PublicFilesList(self, files): |
1019 | 856 | """Notify the list of public files.""" | 854 | """Notify the list of public files.""" |
1020 | 857 | 855 | ||
1021 | 858 | 856 | ||
1022 | === modified file 'ubuntuone/platform/ipc/perspective_broker.py' | |||
1023 | --- ubuntuone/platform/ipc/perspective_broker.py 2012-10-22 13:31:02 +0000 | |||
1024 | +++ ubuntuone/platform/ipc/perspective_broker.py 2015-09-19 23:19:46 +0000 | |||
1025 | @@ -179,8 +179,8 @@ | |||
1026 | 179 | for current_client in self.clients_per_signal[signal_name]: | 179 | for current_client in self.clients_per_signal[signal_name]: |
1027 | 180 | try: | 180 | try: |
1028 | 181 | d = current_client.callRemote(signal_name, *args, **kwargs) | 181 | d = current_client.callRemote(signal_name, *args, **kwargs) |
1031 | 182 | d.addErrback(self._ignore_no_such_method, signal_name, | 182 | d.addErrback( |
1032 | 183 | current_client) | 183 | self._ignore_no_such_method, signal_name, current_client) |
1033 | 184 | d.addErrback(self._other_failure, signal_name, current_client) | 184 | d.addErrback(self._other_failure, signal_name, current_client) |
1034 | 185 | except DeadReferenceError: | 185 | except DeadReferenceError: |
1035 | 186 | dead_clients.add(current_client) | 186 | dead_clients.add(current_client) |
1036 | @@ -500,8 +500,7 @@ | |||
1037 | 500 | 500 | ||
1038 | 501 | def get_metadata_by_node(self, share_id, node_id): | 501 | def get_metadata_by_node(self, share_id, node_id): |
1039 | 502 | """Return the metadata (as a dict) for the specified share/node.""" | 502 | """Return the metadata (as a dict) for the specified share/node.""" |
1042 | 503 | return self.service.file_system.get_metadata_by_node(share_id, | 503 | return self.service.file_system.get_metadata_by_node(share_id, node_id) |
1041 | 504 | node_id) | ||
1043 | 505 | 504 | ||
1044 | 506 | def get_metadata_and_quick_tree_synced(self, path): | 505 | def get_metadata_and_quick_tree_synced(self, path): |
1045 | 507 | """Return the metadata (as a dict) for the specified path. | 506 | """Return the metadata (as a dict) for the specified path. |
1046 | @@ -510,7 +509,7 @@ | |||
1047 | 510 | 509 | ||
1048 | 511 | """ | 510 | """ |
1049 | 512 | return self.service.file_system.get_metadata_and_quick_tree_synced( | 511 | return self.service.file_system.get_metadata_and_quick_tree_synced( |
1051 | 513 | path) | 512 | path) |
1052 | 514 | 513 | ||
1053 | 515 | def get_dirty_nodes(self): | 514 | def get_dirty_nodes(self): |
1054 | 516 | """Return a list of dirty nodes.""" | 515 | """Return a list of dirty nodes.""" |
1055 | @@ -528,16 +527,16 @@ | |||
1056 | 528 | 527 | ||
1057 | 529 | # calls that will be accessible remotely | 528 | # calls that will be accessible remotely |
1058 | 530 | remote_calls = [ | 529 | remote_calls = [ |
1069 | 531 | 'get_shares', | 530 | 'get_shares', |
1070 | 532 | 'accept_share', | 531 | 'accept_share', |
1071 | 533 | 'reject_share', | 532 | 'reject_share', |
1072 | 534 | 'delete_share', | 533 | 'delete_share', |
1073 | 535 | 'subscribe', | 534 | 'subscribe', |
1074 | 536 | 'unsubscribe', | 535 | 'unsubscribe', |
1075 | 537 | 'create_share', | 536 | 'create_share', |
1076 | 538 | 'create_shares', | 537 | 'create_shares', |
1077 | 539 | 'refresh_shares', | 538 | 'refresh_shares', |
1078 | 540 | 'get_shared', | 539 | 'get_shared', |
1079 | 541 | ] | 540 | ] |
1080 | 542 | 541 | ||
1081 | 543 | signal_mapping = { | 542 | signal_mapping = { |
1082 | 544 | 543 | ||
1083 | === modified file 'ubuntuone/platform/notification/linux.py' | |||
1084 | --- ubuntuone/platform/notification/linux.py 2015-09-17 02:20:40 +0000 | |||
1085 | +++ ubuntuone/platform/notification/linux.py 2015-09-19 23:19:46 +0000 | |||
1086 | @@ -46,11 +46,9 @@ | |||
1087 | 46 | class Notification(AbstractNotification): | 46 | class Notification(AbstractNotification): |
1088 | 47 | """Notification of the end user.""" | 47 | """Notification of the end user.""" |
1089 | 48 | 48 | ||
1090 | 49 | # pylint: disable=W0231 | ||
1091 | 50 | def __init__(self, application_name=APPLICATION_NAME): | 49 | def __init__(self, application_name=APPLICATION_NAME): |
1092 | 51 | self.application_name = application_name | 50 | self.application_name = application_name |
1093 | 52 | self.notification = None | 51 | self.notification = None |
1094 | 53 | # pylint: enable=W0231 | ||
1095 | 54 | 52 | ||
1096 | 55 | def send_notification(self, title, message, icon=ICON_NAME, append=False): | 53 | def send_notification(self, title, message, icon=ICON_NAME, append=False): |
1097 | 56 | """Send a notification using the underlying library.""" | 54 | """Send a notification using the underlying library.""" |
1098 | 57 | 55 | ||
1099 | === modified file 'ubuntuone/platform/notification/windows.py' | |||
1100 | --- ubuntuone/platform/notification/windows.py 2015-09-17 02:20:40 +0000 | |||
1101 | +++ ubuntuone/platform/notification/windows.py 2015-09-19 23:19:46 +0000 | |||
1102 | @@ -38,10 +38,8 @@ | |||
1103 | 38 | class Notification(AbstractNotification): | 38 | class Notification(AbstractNotification): |
1104 | 39 | """Notification of the end user.""" | 39 | """Notification of the end user.""" |
1105 | 40 | 40 | ||
1106 | 41 | # pylint: disable=W0231 | ||
1107 | 42 | def __init__(self, application_name=APPLICATION_NAME): | 41 | def __init__(self, application_name=APPLICATION_NAME): |
1108 | 43 | self.application_name = application_name | 42 | self.application_name = application_name |
1109 | 44 | # pylint: enable=W0231 | ||
1110 | 45 | 43 | ||
1111 | 46 | def send_notification(self, title, message, icon=None, append=False): | 44 | def send_notification(self, title, message, icon=None, append=False): |
1112 | 47 | """Send a notification using the underlying library.""" | 45 | """Send a notification using the underlying library.""" |
1113 | 48 | 46 | ||
1114 | === modified file 'ubuntuone/platform/os_helper/windows.py' | |||
1115 | --- ubuntuone/platform/os_helper/windows.py 2013-02-10 22:54:07 +0000 | |||
1116 | +++ ubuntuone/platform/os_helper/windows.py 2015-09-19 23:19:46 +0000 | |||
1117 | @@ -76,8 +76,7 @@ | |||
1118 | 76 | from comtypes.client import CreateObject | 76 | from comtypes.client import CreateObject |
1119 | 77 | from comtypes.persist import IPersistFile | 77 | from comtypes.persist import IPersistFile |
1120 | 78 | 78 | ||
1123 | 79 | # ugly trick to stop pylint for complaining about | 79 | # ugly trick to stop pylint for complaining about WindowsError on Linux |
1122 | 80 | # WindowsError on Linux | ||
1124 | 81 | if sys.platform != 'win32': | 80 | if sys.platform != 'win32': |
1125 | 82 | WindowsError = None | 81 | WindowsError = None |
1126 | 83 | 82 | ||
1127 | @@ -161,7 +160,7 @@ | |||
1128 | 161 | 'unicode_path': 'Path %r should be unicode.', | 160 | 'unicode_path': 'Path %r should be unicode.', |
1129 | 162 | 'long_path': 'Path %r should start with the LONG_PATH_PREFIX.', | 161 | 'long_path': 'Path %r should start with the LONG_PATH_PREFIX.', |
1130 | 163 | 'illegal_path': '%r should not contain any character from' + | 162 | 'illegal_path': '%r should not contain any character from' + |
1132 | 164 | ' WINDOWS_ILLEGAL_CHARS_MAP.', | 163 | ' WINDOWS_ILLEGAL_CHARS_MAP.', |
1133 | 165 | } | 164 | } |
1134 | 166 | messages = _add_method_info(messages, method_name) | 165 | messages = _add_method_info(messages, method_name) |
1135 | 167 | 166 | ||
1136 | @@ -171,8 +170,8 @@ | |||
1137 | 171 | 170 | ||
1138 | 172 | path = path.replace(LONG_PATH_PREFIX, u'') | 171 | path = path.replace(LONG_PATH_PREFIX, u'') |
1139 | 173 | drive, path = os.path.splitdrive(path) | 172 | drive, path = os.path.splitdrive(path) |
1142 | 174 | assert not any(c in WINDOWS_ILLEGAL_CHARS_MAP for c in path), \ | 173 | assert not any(c in WINDOWS_ILLEGAL_CHARS_MAP for c in path), ( |
1143 | 175 | messages['illegal_path'] % path | 174 | messages['illegal_path'] % path) |
1144 | 176 | 175 | ||
1145 | 177 | 176 | ||
1146 | 178 | def assert_syncdaemon_path(path, method_name=None): | 177 | def assert_syncdaemon_path(path, method_name=None): |
1147 | @@ -465,9 +464,9 @@ | |||
1148 | 465 | for group_sid, attributes in groups: | 464 | for group_sid, attributes in groups: |
1149 | 466 | # set the attributes of the group only if not null | 465 | # set the attributes of the group only if not null |
1150 | 467 | if attributes: | 466 | if attributes: |
1154 | 468 | dacl.AddAccessAllowedAceEx(ACL_REVISION, | 467 | dacl.AddAccessAllowedAceEx( |
1155 | 469 | CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, attributes, | 468 | ACL_REVISION, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, |
1156 | 470 | group_sid) | 469 | attributes, group_sid) |
1157 | 471 | # the dacl has all the info of the diff groups passed in the parameters | 470 | # the dacl has all the info of the diff groups passed in the parameters |
1158 | 472 | security_descriptor.SetSecurityDescriptorDacl(1, dacl, 0) | 471 | security_descriptor.SetSecurityDescriptorDacl(1, dacl, 0) |
1159 | 473 | SetFileSecurity(path, DACL_SECURITY_INFORMATION, security_descriptor) | 472 | SetFileSecurity(path, DACL_SECURITY_INFORMATION, security_descriptor) |
1160 | @@ -625,9 +624,8 @@ | |||
1161 | 625 | # function from win32 which will allow to replace the destination path if | 624 | # function from win32 which will allow to replace the destination path if |
1162 | 626 | # exists and the user has the proper rights. For further information, see: | 625 | # exists and the user has the proper rights. For further information, see: |
1163 | 627 | # http://msdn.microsoft.com/en-us/library/aa365240(v=vs.85).aspx | 626 | # http://msdn.microsoft.com/en-us/library/aa365240(v=vs.85).aspx |
1167 | 628 | flag = MOVEFILE_COPY_ALLOWED | \ | 627 | flag = (MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | |
1168 | 629 | MOVEFILE_WRITE_THROUGH | \ | 628 | MOVEFILE_REPLACE_EXISTING) |
1166 | 630 | MOVEFILE_REPLACE_EXISTING | ||
1169 | 631 | try: | 629 | try: |
1170 | 632 | MoveFileExW(path_from, path_to, flag) | 630 | MoveFileExW(path_from, path_to, flag) |
1171 | 633 | except PyWinError, e: | 631 | except PyWinError, e: |
1172 | @@ -757,8 +755,10 @@ | |||
1173 | 757 | # return those paths that are system paths. Those paths are the ones that | 755 | # return those paths that are system paths. Those paths are the ones that |
1174 | 758 | # we do not want to work with. | 756 | # we do not want to work with. |
1175 | 759 | 757 | ||
1178 | 760 | return map(_unicode_to_bytes, [p for p in os.listdir(directory) if not | 758 | return map( |
1179 | 761 | native_is_system_path(os.path.join(directory, p))]) | 759 | _unicode_to_bytes, |
1180 | 760 | [p for p in os.listdir(directory) | ||
1181 | 761 | if not native_is_system_path(os.path.join(directory, p))]) | ||
1182 | 762 | 762 | ||
1183 | 763 | 763 | ||
1184 | 764 | @windowspath() | 764 | @windowspath() |
1185 | @@ -780,10 +780,14 @@ | |||
1186 | 780 | dirpath = _unicode_to_bytes(dirpath.replace(LONG_PATH_PREFIX, u'')) | 780 | dirpath = _unicode_to_bytes(dirpath.replace(LONG_PATH_PREFIX, u'')) |
1187 | 781 | if native_is_system_path(dirpath): | 781 | if native_is_system_path(dirpath): |
1188 | 782 | continue | 782 | continue |
1193 | 783 | dirnames = map(_unicode_to_bytes, [p for p in dirnames if | 783 | dirnames = map( |
1194 | 784 | not native_is_system_path(os.path.join(dirpath, p))]) | 784 | _unicode_to_bytes, |
1195 | 785 | filenames = map(_unicode_to_bytes, [p for p in filenames if not | 785 | [p for p in dirnames |
1196 | 786 | native_is_system_path(os.path.join(dirpath, p))]) | 786 | if not native_is_system_path(os.path.join(dirpath, p))]) |
1197 | 787 | filenames = map( | ||
1198 | 788 | _unicode_to_bytes, | ||
1199 | 789 | [p for p in filenames | ||
1200 | 790 | if not native_is_system_path(os.path.join(dirpath, p))]) | ||
1201 | 787 | yield dirpath, dirnames, filenames | 791 | yield dirpath, dirnames, filenames |
1202 | 788 | 792 | ||
1203 | 789 | 793 | ||
1204 | @@ -807,8 +811,9 @@ | |||
1205 | 807 | ace = dacl.GetAce(index) | 811 | ace = dacl.GetAce(index) |
1206 | 808 | if _has_read_mask(ace[1]): | 812 | if _has_read_mask(ace[1]): |
1207 | 809 | sids.append(ace[2]) | 813 | sids.append(ace[2]) |
1210 | 810 | return (USER_SID in sids or EVERYONE_SID in sids) and\ | 814 | return ( |
1211 | 811 | os.access(path, os.R_OK) | 815 | (USER_SID in sids or EVERYONE_SID in sids) and os.access(path, os.R_OK) |
1212 | 816 | ) | ||
1213 | 812 | 817 | ||
1214 | 813 | 818 | ||
1215 | 814 | @windowspath() | 819 | @windowspath() |
1216 | @@ -831,8 +836,9 @@ | |||
1217 | 831 | ace = dacl.GetAce(index) | 836 | ace = dacl.GetAce(index) |
1218 | 832 | if _has_read_mask(ace[1]): | 837 | if _has_read_mask(ace[1]): |
1219 | 833 | sids.append(ace[2]) | 838 | sids.append(ace[2]) |
1222 | 834 | return (USER_SID in sids or EVERYONE_SID in sids) and\ | 839 | return ( |
1223 | 835 | os.access(path, os.R_OK) | 840 | (USER_SID in sids or EVERYONE_SID in sids) and os.access(path, os.R_OK) |
1224 | 841 | ) | ||
1225 | 836 | 842 | ||
1226 | 837 | 843 | ||
1227 | 838 | @windowspath() | 844 | @windowspath() |
1228 | @@ -863,8 +869,8 @@ | |||
1229 | 863 | # the shell code does not know how to deal with long paths, lets | 869 | # the shell code does not know how to deal with long paths, lets |
1230 | 864 | # try to move it to the trash if it is short enough, else we remove it | 870 | # try to move it to the trash if it is short enough, else we remove it |
1231 | 865 | no_prefix_path = path.replace(LONG_PATH_PREFIX, u'') | 871 | no_prefix_path = path.replace(LONG_PATH_PREFIX, u'') |
1234 | 866 | flags = shellcon.FOF_ALLOWUNDO | shellcon.FOF_NOCONFIRMATION | \ | 872 | flags = (shellcon.FOF_ALLOWUNDO | shellcon.FOF_NOCONFIRMATION | |
1235 | 867 | shellcon.FOF_NOERRORUI | shellcon.FOF_SILENT | 873 | shellcon.FOF_NOERRORUI | shellcon.FOF_SILENT) |
1236 | 868 | result = shell.SHFileOperation((0, shellcon.FO_DELETE, | 874 | result = shell.SHFileOperation((0, shellcon.FO_DELETE, |
1237 | 869 | no_prefix_path, None, flags)) | 875 | no_prefix_path, None, flags)) |
1238 | 870 | 876 | ||
1239 | 871 | 877 | ||
1240 | === modified file 'ubuntuone/platform/sync_menu/linux.py' | |||
1241 | --- ubuntuone/platform/sync_menu/linux.py 2015-09-17 02:20:40 +0000 | |||
1242 | +++ ubuntuone/platform/sync_menu/linux.py 2015-09-19 23:19:46 +0000 | |||
1243 | @@ -89,40 +89,42 @@ | |||
1244 | 89 | self.open_u1 = Dbusmenu.Menuitem() | 89 | self.open_u1 = Dbusmenu.Menuitem() |
1245 | 90 | self.open_u1.property_set(Dbusmenu.MENUITEM_PROP_LABEL, OPEN_U1) | 90 | self.open_u1.property_set(Dbusmenu.MENUITEM_PROP_LABEL, OPEN_U1) |
1246 | 91 | self.open_u1_folder = Dbusmenu.Menuitem() | 91 | self.open_u1_folder = Dbusmenu.Menuitem() |
1249 | 92 | self.open_u1_folder.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 92 | self.open_u1_folder.property_set( |
1250 | 93 | OPEN_U1_FOLDER) | 93 | Dbusmenu.MENUITEM_PROP_LABEL, OPEN_U1_FOLDER) |
1251 | 94 | self.share_file = Dbusmenu.Menuitem() | 94 | self.share_file = Dbusmenu.Menuitem() |
1254 | 95 | self.share_file.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 95 | self.share_file.property_set( |
1255 | 96 | SHARE_A_FILE) | 96 | Dbusmenu.MENUITEM_PROP_LABEL, SHARE_A_FILE) |
1256 | 97 | 97 | ||
1257 | 98 | self.go_to_web = Dbusmenu.Menuitem() | 98 | self.go_to_web = Dbusmenu.Menuitem() |
1260 | 99 | self.go_to_web.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 99 | self.go_to_web.property_set( |
1261 | 100 | GO_TO_WEB) | 100 | Dbusmenu.MENUITEM_PROP_LABEL, GO_TO_WEB) |
1262 | 101 | 101 | ||
1263 | 102 | self.transfers = TransfersMenu(status) | 102 | self.transfers = TransfersMenu(status) |
1266 | 103 | self.transfers.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 103 | self.transfers.property_set( |
1267 | 104 | TRANSFERS) | 104 | Dbusmenu.MENUITEM_PROP_LABEL, TRANSFERS) |
1268 | 105 | 105 | ||
1269 | 106 | self.more_storage = Dbusmenu.Menuitem() | 106 | self.more_storage = Dbusmenu.Menuitem() |
1272 | 107 | self.more_storage.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 107 | self.more_storage.property_set( |
1273 | 108 | MORE_STORAGE) | 108 | Dbusmenu.MENUITEM_PROP_LABEL, MORE_STORAGE) |
1274 | 109 | 109 | ||
1275 | 110 | self.get_help = Dbusmenu.Menuitem() | 110 | self.get_help = Dbusmenu.Menuitem() |
1278 | 111 | self.get_help.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 111 | self.get_help.property_set( |
1279 | 112 | GET_HELP) | 112 | Dbusmenu.MENUITEM_PROP_LABEL, GET_HELP) |
1280 | 113 | 113 | ||
1281 | 114 | # Connect signals | 114 | # Connect signals |
1285 | 115 | self.open_u1.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 115 | self.open_u1.connect( |
1286 | 116 | self.open_control_panel) | 116 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_control_panel) |
1287 | 117 | self.open_u1_folder.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 117 | self.open_u1_folder.connect( |
1288 | 118 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | ||
1289 | 118 | self.open_ubuntu_one_folder) | 119 | self.open_ubuntu_one_folder) |
1297 | 119 | self.share_file.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 120 | self.share_file.connect( |
1298 | 120 | self.open_share_file_tab) | 121 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_share_file_tab) |
1299 | 121 | self.go_to_web.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 122 | self.go_to_web.connect( |
1300 | 122 | self.open_go_to_web) | 123 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_go_to_web) |
1301 | 123 | self.get_help.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 124 | self.get_help.connect( |
1302 | 124 | self.open_web_help) | 125 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_web_help) |
1303 | 125 | self.more_storage.connect(Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | 126 | self.more_storage.connect( |
1304 | 127 | Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, | ||
1305 | 126 | self.open_get_more_storage) | 128 | self.open_get_more_storage) |
1306 | 127 | 129 | ||
1307 | 128 | # Add items | 130 | # Add items |
1308 | @@ -172,11 +174,12 @@ | |||
1309 | 172 | def _open_uri(self, uri, timestamp=0): | 174 | def _open_uri(self, uri, timestamp=0): |
1310 | 173 | """Open an uri Using the default handler and the action timestamp""" | 175 | """Open an uri Using the default handler and the action timestamp""" |
1311 | 174 | try: | 176 | try: |
1313 | 175 | Gio.AppInfo.launch_default_for_uri(uri, self._get_launch_context(timestamp)) | 177 | Gio.AppInfo.launch_default_for_uri( |
1314 | 178 | uri, self._get_launch_context(timestamp)) | ||
1315 | 176 | except glib.GError as e: | 179 | except glib.GError as e: |
1317 | 177 | logger.warning('Failed to open the uri %s: %s.' % (uri, e)) | 180 | logger.warning('Failed to open the uri %s: %s.', uri, e) |
1318 | 178 | 181 | ||
1320 | 179 | def _open_control_panel_by_command_line(self, timestamp, args = ''): | 182 | def _open_control_panel_by_command_line(self, timestamp, args=''): |
1321 | 180 | """Open the control panel by command line""" | 183 | """Open the control panel by command line""" |
1322 | 181 | flags = Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION | 184 | flags = Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION |
1323 | 182 | command_line = CLIENT_COMMAND_LINE | 185 | command_line = CLIENT_COMMAND_LINE |
1324 | @@ -184,7 +187,8 @@ | |||
1325 | 184 | command_line += ' ' + args | 187 | command_line += ' ' + args |
1326 | 185 | 188 | ||
1327 | 186 | try: | 189 | try: |
1329 | 187 | app = Gio.AppInfo.create_from_commandline(command_line, 'Magicicada', flags) | 190 | app = Gio.AppInfo.create_from_commandline( |
1330 | 191 | command_line, 'Magicicada', flags) | ||
1331 | 188 | 192 | ||
1332 | 189 | if app: | 193 | if app: |
1333 | 190 | app.launch([], self._get_launch_context(timestamp)) | 194 | app.launch([], self._get_launch_context(timestamp)) |
1334 | @@ -205,11 +209,13 @@ | |||
1335 | 205 | 209 | ||
1336 | 206 | def open_ubuntu_one_folder(self, menuitem=None, timestamp=0): | 210 | def open_ubuntu_one_folder(self, menuitem=None, timestamp=0): |
1337 | 207 | """Open the Magicicada folder.""" | 211 | """Open the Magicicada folder.""" |
1339 | 208 | self._open_uri("file://" + self._syncdaemon_service.get_rootdir(), timestamp) | 212 | self._open_uri( |
1340 | 213 | "file://" + self._syncdaemon_service.get_rootdir(), timestamp) | ||
1341 | 209 | 214 | ||
1342 | 210 | def open_share_file_tab(self, menuitem=None, timestamp=0): | 215 | def open_share_file_tab(self, menuitem=None, timestamp=0): |
1343 | 211 | """Open the Control Panel in the Share Tab.""" | 216 | """Open the Control Panel in the Share Tab.""" |
1345 | 212 | self._open_control_panel_by_command_line(timestamp, "--switch-to share_links") | 217 | self._open_control_panel_by_command_line( |
1346 | 218 | timestamp, "--switch-to share_links") | ||
1347 | 213 | 219 | ||
1348 | 214 | def open_go_to_web(self, menuitem=None, timestamp=0): | 220 | def open_go_to_web(self, menuitem=None, timestamp=0): |
1349 | 215 | """Open the Magicicada Help Page""" | 221 | """Open the Magicicada Help Page""" |
1350 | @@ -234,7 +240,7 @@ | |||
1351 | 234 | if not self.timer: | 240 | if not self.timer: |
1352 | 235 | logger.debug("Updating Transfers.") | 241 | logger.debug("Updating Transfers.") |
1353 | 236 | delay = int(max(0, min(DELAY_BETWEEN_UPDATES, | 242 | delay = int(max(0, min(DELAY_BETWEEN_UPDATES, |
1355 | 237 | self.next_update - time.time()))) | 243 | self.next_update - time.time()))) |
1356 | 238 | self.timer = status.aggregator.Timer(delay) | 244 | self.timer = status.aggregator.Timer(delay) |
1357 | 239 | self.timer.addCallback(self._timeout) | 245 | self.timer.addCallback(self._timeout) |
1358 | 240 | 246 | ||
1359 | @@ -268,16 +274,16 @@ | |||
1360 | 268 | self.child_delete(self._transfers_items[item_transfer]) | 274 | self.child_delete(self._transfers_items[item_transfer]) |
1361 | 269 | for item in recent_transfers: | 275 | for item in recent_transfers: |
1362 | 270 | recent_file = Dbusmenu.Menuitem() | 276 | recent_file = Dbusmenu.Menuitem() |
1365 | 271 | recent_file.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 277 | recent_file.property_set( |
1366 | 272 | item.replace('_', '__')) | 278 | Dbusmenu.MENUITEM_PROP_LABEL, item.replace('_', '__')) |
1367 | 273 | self.child_add_position(recent_file, 0) | 279 | self.child_add_position(recent_file, 0) |
1368 | 274 | temp_transfers[item] = recent_file | 280 | temp_transfers[item] = recent_file |
1369 | 275 | self._transfers_items = temp_transfers | 281 | self._transfers_items = temp_transfers |
1370 | 276 | 282 | ||
1371 | 277 | if self.separator is None: | 283 | if self.separator is None: |
1372 | 278 | self.separator = Dbusmenu.Menuitem() | 284 | self.separator = Dbusmenu.Menuitem() |
1375 | 279 | self.separator.property_set(Dbusmenu.MENUITEM_PROP_TYPE, | 285 | self.separator.property_set( |
1376 | 280 | Dbusmenu.CLIENT_TYPES_SEPARATOR) | 286 | Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR) |
1377 | 281 | self.child_append(self.separator) | 287 | self.child_append(self.separator) |
1378 | 282 | 288 | ||
1379 | 283 | items_added = 0 | 289 | items_added = 0 |
1380 | @@ -290,7 +296,8 @@ | |||
1381 | 290 | upload_item.property_set_int( | 296 | upload_item.property_set_int( |
1382 | 291 | SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE, | 297 | SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE, |
1383 | 292 | percentage) | 298 | percentage) |
1385 | 293 | logger.debug("Current transfer %s progress update: %r", | 299 | logger.debug( |
1386 | 300 | "Current transfer %s progress update: %r", | ||
1387 | 294 | item, percentage) | 301 | item, percentage) |
1388 | 295 | items_added += 1 | 302 | items_added += 1 |
1389 | 296 | else: | 303 | else: |
1390 | @@ -304,9 +311,10 @@ | |||
1391 | 304 | size, written = uploading_data[item] | 311 | size, written = uploading_data[item] |
1392 | 305 | percentage = written * 100 / size | 312 | percentage = written * 100 / size |
1393 | 306 | uploading_file = Dbusmenu.Menuitem() | 313 | uploading_file = Dbusmenu.Menuitem() |
1397 | 307 | uploading_file.property_set(Dbusmenu.MENUITEM_PROP_LABEL, | 314 | uploading_file.property_set( |
1398 | 308 | item.replace('_', '__')) | 315 | Dbusmenu.MENUITEM_PROP_LABEL, item.replace('_', '__')) |
1399 | 309 | uploading_file.property_set(Dbusmenu.MENUITEM_PROP_TYPE, | 316 | uploading_file.property_set( |
1400 | 317 | Dbusmenu.MENUITEM_PROP_TYPE, | ||
1401 | 310 | SyncMenu.PROGRESS_MENUITEM_TYPE) | 318 | SyncMenu.PROGRESS_MENUITEM_TYPE) |
1402 | 311 | uploading_file.property_set_int( | 319 | uploading_file.property_set_int( |
1403 | 312 | SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE, | 320 | SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE, |
1404 | @@ -321,4 +329,3 @@ | |||
1405 | 321 | UbuntuOneSyncMenu = UbuntuOneSyncMenuLinux | 329 | UbuntuOneSyncMenu = UbuntuOneSyncMenuLinux |
1406 | 322 | else: | 330 | else: |
1407 | 323 | UbuntuOneSyncMenu = DummySyncMenu | 331 | UbuntuOneSyncMenu = DummySyncMenu |
1408 | 324 | |||
1409 | 325 | 332 | ||
1410 | === modified file 'ubuntuone/platform/tools/__init__.py' | |||
1411 | --- ubuntuone/platform/tools/__init__.py 2013-01-12 00:28:17 +0000 | |||
1412 | +++ ubuntuone/platform/tools/__init__.py 2015-09-19 23:19:46 +0000 | |||
1413 | @@ -99,7 +99,7 @@ | |||
1414 | 99 | self.proxy.wait_connected() | 99 | self.proxy.wait_connected() |
1415 | 100 | self.log.debug('wait_connected: Done!') | 100 | self.log.debug('wait_connected: Done!') |
1416 | 101 | d.callback(True) | 101 | d.callback(True) |
1418 | 102 | except Exception, e: # catch all errors, pylint: disable=W0703 | 102 | except Exception as e: |
1419 | 103 | self.log.debug('Not connected: %s', e) | 103 | self.log.debug('Not connected: %s', e) |
1420 | 104 | d.errback() | 104 | d.errback() |
1421 | 105 | 105 | ||
1422 | @@ -202,7 +202,7 @@ | |||
1423 | 202 | try: | 202 | try: |
1424 | 203 | if success_filter(*args): | 203 | if success_filter(*args): |
1425 | 204 | d.callback(args) | 204 | d.callback(args) |
1427 | 205 | except Exception, e: | 205 | except Exception as e: |
1428 | 206 | logger.exception('wait_for_signals: success_handler failed:') | 206 | logger.exception('wait_for_signals: success_handler failed:') |
1429 | 207 | d.errback(IPCError(e.__class__.__name__, args, e.message)) | 207 | d.errback(IPCError(e.__class__.__name__, args, e.message)) |
1430 | 208 | 208 | ||
1431 | @@ -211,7 +211,7 @@ | |||
1432 | 211 | try: | 211 | try: |
1433 | 212 | if error_filter(*args): | 212 | if error_filter(*args): |
1434 | 213 | d.errback(IPCError(signal_error, args)) | 213 | d.errback(IPCError(signal_error, args)) |
1436 | 214 | except Exception, e: | 214 | except Exception as e: |
1437 | 215 | logger.exception('wait_for_signals: error_handler failed:') | 215 | logger.exception('wait_for_signals: error_handler failed:') |
1438 | 216 | d.errback(IPCError(e.__class__.__name__, args, e.message)) | 216 | d.errback(IPCError(e.__class__.__name__, args, e.message)) |
1439 | 217 | 217 | ||
1440 | @@ -278,8 +278,9 @@ | |||
1441 | 278 | @log_call(logger.debug) | 278 | @log_call(logger.debug) |
1442 | 279 | def accept_share(self, share_id): | 279 | def accept_share(self, share_id): |
1443 | 280 | """Accept the share with id: share_id.""" | 280 | """Accept the share with id: share_id.""" |
1446 | 281 | d = self.wait_for_signals(signal_ok='ShareAnswerResponse', | 281 | d = self.wait_for_signals( |
1447 | 282 | success_filter=lambda info: info['volume_id'] == share_id) | 282 | signal_ok='ShareAnswerResponse', |
1448 | 283 | success_filter=lambda info: info['volume_id'] == share_id) | ||
1449 | 283 | self.proxy.call_method('shares', 'accept_share', share_id) | 284 | self.proxy.call_method('shares', 'accept_share', share_id) |
1450 | 284 | result, = yield d | 285 | result, = yield d |
1451 | 285 | defer.returnValue(result) | 286 | defer.returnValue(result) |
1452 | @@ -288,8 +289,9 @@ | |||
1453 | 288 | @log_call(logger.debug) | 289 | @log_call(logger.debug) |
1454 | 289 | def reject_share(self, share_id): | 290 | def reject_share(self, share_id): |
1455 | 290 | """Reject the share with id: share_id.""" | 291 | """Reject the share with id: share_id.""" |
1458 | 291 | d = self.wait_for_signals(signal_ok='ShareAnswerResponse', | 292 | d = self.wait_for_signals( |
1459 | 292 | success_filter=lambda info: info['volume_id'] == share_id) | 293 | signal_ok='ShareAnswerResponse', |
1460 | 294 | success_filter=lambda info: info['volume_id'] == share_id) | ||
1461 | 293 | self.proxy.call_method('shares', 'reject_share', share_id) | 295 | self.proxy.call_method('shares', 'reject_share', share_id) |
1462 | 294 | result, = yield d | 296 | result, = yield d |
1463 | 295 | defer.returnValue(result) | 297 | defer.returnValue(result) |
1464 | @@ -298,9 +300,10 @@ | |||
1465 | 298 | @log_call(logger.debug) | 300 | @log_call(logger.debug) |
1466 | 299 | def subscribe_share(self, share_id): | 301 | def subscribe_share(self, share_id): |
1467 | 300 | """Subscribe to a share given its id.""" | 302 | """Subscribe to a share given its id.""" |
1471 | 301 | d = self.wait_for_signals('ShareSubscribed', 'ShareSubscribeError', | 303 | d = self.wait_for_signals( |
1472 | 302 | success_filter=lambda info: info['volume_id'] == share_id, | 304 | 'ShareSubscribed', 'ShareSubscribeError', |
1473 | 303 | error_filter=lambda info, _: info['volume_id'] == share_id) | 305 | success_filter=lambda info: info['volume_id'] == share_id, |
1474 | 306 | error_filter=lambda info, _: info['volume_id'] == share_id) | ||
1475 | 304 | self.proxy.call_method('shares', 'subscribe', share_id) | 307 | self.proxy.call_method('shares', 'subscribe', share_id) |
1476 | 305 | result, = yield d | 308 | result, = yield d |
1477 | 306 | defer.returnValue(result) | 309 | defer.returnValue(result) |
1478 | @@ -309,9 +312,10 @@ | |||
1479 | 309 | @log_call(logger.debug) | 312 | @log_call(logger.debug) |
1480 | 310 | def unsubscribe_share(self, share_id): | 313 | def unsubscribe_share(self, share_id): |
1481 | 311 | """Unsubscribe from a share given its id.""" | 314 | """Unsubscribe from a share given its id.""" |
1485 | 312 | d = self.wait_for_signals('ShareUnSubscribed', 'ShareUnSubscribeError', | 315 | d = self.wait_for_signals( |
1486 | 313 | success_filter=lambda info: info['volume_id'] == share_id, | 316 | 'ShareUnSubscribed', 'ShareUnSubscribeError', |
1487 | 314 | error_filter=lambda info, _: info['volume_id'] == share_id) | 317 | success_filter=lambda info: info['volume_id'] == share_id, |
1488 | 318 | error_filter=lambda info, _: info['volume_id'] == share_id) | ||
1489 | 315 | self.proxy.call_method('shares', 'unsubscribe', share_id) | 319 | self.proxy.call_method('shares', 'unsubscribe', share_id) |
1490 | 316 | result, = yield d | 320 | result, = yield d |
1491 | 317 | defer.returnValue(result) | 321 | defer.returnValue(result) |
1492 | @@ -333,8 +337,8 @@ | |||
1493 | 333 | @log_call(logger.debug) | 337 | @log_call(logger.debug) |
1494 | 334 | def offer_share(self, path, username, name, access_level): | 338 | def offer_share(self, path, username, name, access_level): |
1495 | 335 | """Offer a share at the specified path to user with id: username.""" | 339 | """Offer a share at the specified path to user with id: username.""" |
1498 | 336 | return self.proxy.call_method('shares', 'create_share', path, | 340 | return self.proxy.call_method( |
1499 | 337 | username, name, access_level) | 341 | 'shares', 'create_share', path, username, name, access_level) |
1500 | 338 | 342 | ||
1501 | 339 | @defer.inlineCallbacks | 343 | @defer.inlineCallbacks |
1502 | 340 | @log_call(logger.debug) | 344 | @log_call(logger.debug) |
1503 | @@ -349,9 +353,10 @@ | |||
1504 | 349 | @log_call(logger.debug) | 353 | @log_call(logger.debug) |
1505 | 350 | def create_folder(self, path): | 354 | def create_folder(self, path): |
1506 | 351 | """Create a user defined folder in the specified path.""" | 355 | """Create a user defined folder in the specified path.""" |
1510 | 352 | d = self.wait_for_signals('FolderCreated', 'FolderCreateError', | 356 | d = self.wait_for_signals( |
1511 | 353 | success_filter=lambda info: info['path'] == path, | 357 | 'FolderCreated', 'FolderCreateError', |
1512 | 354 | error_filter=lambda info, _: info['path'] == path) | 358 | success_filter=lambda info: info['path'] == path, |
1513 | 359 | error_filter=lambda info, _: info['path'] == path) | ||
1514 | 355 | 360 | ||
1515 | 356 | self.proxy.call_method('folders', 'create', path) | 361 | self.proxy.call_method('folders', 'create', path) |
1516 | 357 | 362 | ||
1517 | @@ -362,9 +367,10 @@ | |||
1518 | 362 | @log_call(logger.info) | 367 | @log_call(logger.info) |
1519 | 363 | def delete_folder(self, folder_id): | 368 | def delete_folder(self, folder_id): |
1520 | 364 | """Delete a user defined folder given its id.""" | 369 | """Delete a user defined folder given its id.""" |
1524 | 365 | d = self.wait_for_signals('FolderDeleted', 'FolderDeleteError', | 370 | d = self.wait_for_signals( |
1525 | 366 | success_filter=lambda info: info['volume_id'] == folder_id, | 371 | 'FolderDeleted', 'FolderDeleteError', |
1526 | 367 | error_filter=lambda info, _: info['volume_id'] == folder_id) | 372 | success_filter=lambda info: info['volume_id'] == folder_id, |
1527 | 373 | error_filter=lambda info, _: info['volume_id'] == folder_id) | ||
1528 | 368 | 374 | ||
1529 | 369 | self.proxy.call_method('folders', 'delete', folder_id) | 375 | self.proxy.call_method('folders', 'delete', folder_id) |
1530 | 370 | 376 | ||
1531 | @@ -375,9 +381,10 @@ | |||
1532 | 375 | @log_call(logger.debug) | 381 | @log_call(logger.debug) |
1533 | 376 | def subscribe_folder(self, folder_id): | 382 | def subscribe_folder(self, folder_id): |
1534 | 377 | """Subscribe to a user defined folder given its id.""" | 383 | """Subscribe to a user defined folder given its id.""" |
1538 | 378 | d = self.wait_for_signals('FolderSubscribed', 'FolderSubscribeError', | 384 | d = self.wait_for_signals( |
1539 | 379 | success_filter=lambda info: info['volume_id'] == folder_id, | 385 | 'FolderSubscribed', 'FolderSubscribeError', |
1540 | 380 | error_filter=lambda info, _: info['volume_id'] == folder_id) | 386 | success_filter=lambda info: info['volume_id'] == folder_id, |
1541 | 387 | error_filter=lambda info, _: info['volume_id'] == folder_id) | ||
1542 | 381 | 388 | ||
1543 | 382 | self.proxy.call_method('folders', 'subscribe', folder_id) | 389 | self.proxy.call_method('folders', 'subscribe', folder_id) |
1544 | 383 | 390 | ||
1545 | @@ -389,9 +396,9 @@ | |||
1546 | 389 | def unsubscribe_folder(self, folder_id): | 396 | def unsubscribe_folder(self, folder_id): |
1547 | 390 | """Unsubscribe from a user defined folder given its id.""" | 397 | """Unsubscribe from a user defined folder given its id.""" |
1548 | 391 | d = self.wait_for_signals( | 398 | d = self.wait_for_signals( |
1552 | 392 | 'FolderUnSubscribed', 'FolderUnSubscribeError', | 399 | 'FolderUnSubscribed', 'FolderUnSubscribeError', |
1553 | 393 | success_filter=lambda info: info['volume_id'] == folder_id, | 400 | success_filter=lambda info: info['volume_id'] == folder_id, |
1554 | 394 | error_filter=lambda info, _: info['volume_id'] == folder_id) | 401 | error_filter=lambda info, _: info['volume_id'] == folder_id) |
1555 | 395 | 402 | ||
1556 | 396 | self.proxy.call_method('folders', 'unsubscribe', folder_id) | 403 | self.proxy.call_method('folders', 'unsubscribe', folder_id) |
1557 | 397 | 404 | ||
1558 | @@ -524,8 +531,8 @@ | |||
1559 | 524 | @log_call(logger.debug) | 531 | @log_call(logger.debug) |
1560 | 525 | def set_throttling_limits(self, read_limit, write_limit): | 532 | def set_throttling_limits(self, read_limit, write_limit): |
1561 | 526 | """Set the read and write limits.""" | 533 | """Set the read and write limits.""" |
1564 | 527 | return self.proxy.call_method('config', 'set_throttling_limits', | 534 | return self.proxy.call_method( |
1565 | 528 | read_limit, write_limit) | 535 | 'config', 'set_throttling_limits', read_limit, write_limit) |
1566 | 529 | 536 | ||
1567 | 530 | def is_setting_enabled(self, setting_name): | 537 | def is_setting_enabled(self, setting_name): |
1568 | 531 | """Return whether 'setting_name' is enabled.""" | 538 | """Return whether 'setting_name' is enabled.""" |
1569 | @@ -665,8 +672,8 @@ | |||
1570 | 665 | else: | 672 | else: |
1571 | 666 | out.write("Shared list:\n") | 673 | out.write("Shared list:\n") |
1572 | 667 | for share in shares: | 674 | for share in shares: |
1575 | 668 | msg_template = ' id=%s name=%s accepted=%s ' + \ | 675 | msg_template = ( |
1576 | 669 | 'access_level=%s to=%s path=%s\n' | 676 | ' id=%s name=%s accepted=%s access_level=%s to=%s path=%s\n') |
1577 | 670 | out.write(msg_template % (share['volume_id'], share['name'], | 677 | out.write(msg_template % (share['volume_id'], share['name'], |
1578 | 671 | bool(share['accepted']), | 678 | bool(share['accepted']), |
1579 | 672 | share['access_level'], | 679 | share['access_level'], |
1580 | @@ -730,8 +737,8 @@ | |||
1581 | 730 | out.write("Current uploads: 0\n") | 737 | out.write("Current uploads: 0\n") |
1582 | 731 | for upload in uploads: | 738 | for upload in uploads: |
1583 | 732 | out.write(" path: %s\n" % upload['path']) | 739 | out.write(" path: %s\n" % upload['path']) |
1586 | 733 | out.write(" deflated size: %s\n" % \ | 740 | out.write( |
1587 | 734 | upload.get('deflated_size', 'N/A')) | 741 | " deflated size: %s\n" % upload.get('deflated_size', 'N/A')) |
1588 | 735 | out.write(" bytes written: %s\n" % upload['n_bytes_written']) | 742 | out.write(" bytes written: %s\n" % upload['n_bytes_written']) |
1589 | 736 | 743 | ||
1590 | 737 | 744 | ||
1591 | @@ -743,8 +750,8 @@ | |||
1592 | 743 | out.write("Current downloads: 0\n") | 750 | out.write("Current downloads: 0\n") |
1593 | 744 | for download in downloads: | 751 | for download in downloads: |
1594 | 745 | out.write(" path: %s\n" % download['path']) | 752 | out.write(" path: %s\n" % download['path']) |
1597 | 746 | out.write(" deflated size: %s\n" % \ | 753 | out.write( |
1598 | 747 | download.get('deflated_size', 'N/A')) | 754 | " deflated size: %s\n" % download.get('deflated_size', 'N/A')) |
1599 | 748 | out.write(" bytes read: %s\n" % download['n_bytes_read']) | 755 | out.write(" bytes read: %s\n" % download['n_bytes_read']) |
1600 | 749 | 756 | ||
1601 | 750 | 757 | ||
1602 | @@ -802,8 +809,9 @@ | |||
1603 | 802 | def show_waiting_content(waiting_ops, out): | 809 | def show_waiting_content(waiting_ops, out): |
1604 | 803 | """Print the waiting_content result.""" | 810 | """Print the waiting_content result.""" |
1605 | 804 | out.write("Warning: this option is deprecated! Use '--waiting' instead\n") | 811 | out.write("Warning: this option is deprecated! Use '--waiting' instead\n") |
1608 | 805 | value_tpl = "operation='%(operation)s' node_id='%(node)s' " + \ | 812 | value_tpl = ( |
1609 | 806 | "share_id='%(share)s' path='%(path)s'" | 813 | "operation='%(operation)s' node_id='%(node)s' share_id='%(share)s' " |
1610 | 814 | "path='%(path)s'") | ||
1611 | 807 | for value in waiting_ops: | 815 | for value in waiting_ops: |
1612 | 808 | str_value = value_tpl % value | 816 | str_value = value_tpl % value |
1613 | 809 | out.write("%s\n" % str_value) | 817 | out.write("%s\n" % str_value) |
1614 | @@ -822,8 +830,9 @@ | |||
1615 | 822 | if not nodes: | 830 | if not nodes: |
1616 | 823 | out.write(" No dirty nodes.\n") | 831 | out.write(" No dirty nodes.\n") |
1617 | 824 | return | 832 | return |
1620 | 825 | node_line_tpl = "mdid: %(mdid)s volume_id: %(share_id)s " + \ | 833 | node_line_tpl = ( |
1621 | 826 | "node_id: %(node_id)s is_dir: %(is_dir)s path: %(path)s\n" | 834 | "mdid: %(mdid)s volume_id: %(share_id)s node_id: %(node_id)s " |
1622 | 835 | "is_dir: %(is_dir)s path: %(path)s\n") | ||
1623 | 827 | out.write(" Dirty nodes:\n") | 836 | out.write(" Dirty nodes:\n") |
1624 | 828 | for node in nodes: | 837 | for node in nodes: |
1625 | 829 | assert isinstance(node['path'], unicode) | 838 | assert isinstance(node['path'], unicode) |
1626 | 830 | 839 | ||
1627 | === modified file 'ubuntuone/platform/tools/perspective_broker.py' | |||
1628 | --- ubuntuone/platform/tools/perspective_broker.py 2012-12-27 02:10:00 +0000 | |||
1629 | +++ ubuntuone/platform/tools/perspective_broker.py 2015-09-19 23:19:46 +0000 | |||
1630 | @@ -119,8 +119,8 @@ | |||
1631 | 119 | return attr | 119 | return attr |
1632 | 120 | 120 | ||
1633 | 121 | def __init__(self, bus=None): | 121 | def __init__(self, bus=None): |
1636 | 122 | self.log = logging.getLogger('ubuntuone.platform.tools.' + | 122 | self.log = logging.getLogger( |
1637 | 123 | 'perspective_broker') | 123 | 'ubuntuone.platform.tools.perspective_broker') |
1638 | 124 | self.client = UbuntuOneClient() | 124 | self.client = UbuntuOneClient() |
1639 | 125 | self.connected = None | 125 | self.connected = None |
1640 | 126 | self.connected_signals = defaultdict(set) | 126 | self.connected_signals = defaultdict(set) |
1641 | @@ -167,8 +167,8 @@ | |||
1642 | 167 | # may happen in the case we reconnected and the server side objects | 167 | # may happen in the case we reconnected and the server side objects |
1643 | 168 | # for gc | 168 | # for gc |
1644 | 169 | yield self._reconnect_client() | 169 | yield self._reconnect_client() |
1647 | 170 | result = yield self.call_method(client_kind, method_name, | 170 | result = yield self.call_method( |
1648 | 171 | *args, **kwargs) | 171 | client_kind, method_name, *args, **kwargs) |
1649 | 172 | except RemoteError as e: | 172 | except RemoteError as e: |
1650 | 173 | # Wrap RemoteErrors in IPCError to match DBus interface's | 173 | # Wrap RemoteErrors in IPCError to match DBus interface's |
1651 | 174 | # behavior: | 174 | # behavior: |
1652 | @@ -191,9 +191,8 @@ | |||
1653 | 191 | client_kind, callback = self._SIGNAL_MAPPING[signal_name] | 191 | client_kind, callback = self._SIGNAL_MAPPING[signal_name] |
1654 | 192 | client = getattr(self.client, client_kind) | 192 | client = getattr(self.client, client_kind) |
1655 | 193 | if len(self.connected_signals[signal_name]) == 0: | 193 | if len(self.connected_signals[signal_name]) == 0: |
1659 | 194 | setattr(client, callback, | 194 | f = lambda *args, **kw: self._handler(signal_name, *args, **kw) |
1660 | 195 | lambda *args, **kwargs: | 195 | setattr(client, callback, f) |
1658 | 196 | self._handler(signal_name, *args, **kwargs)) | ||
1661 | 197 | # do remember the connected signal in case we need to reconnect | 196 | # do remember the connected signal in case we need to reconnect |
1662 | 198 | self.connected_signals[signal_name].add(handler) | 197 | self.connected_signals[signal_name].add(handler) |
1663 | 199 | return handler | 198 | return handler |
1664 | 200 | 199 | ||
1665 | === modified file 'ubuntuone/proxy/tunnel_client.py' | |||
1666 | --- ubuntuone/proxy/tunnel_client.py 2015-09-17 02:20:40 +0000 | |||
1667 | +++ ubuntuone/proxy/tunnel_client.py 2015-09-19 23:19:46 +0000 | |||
1668 | @@ -135,8 +135,8 @@ | |||
1669 | 135 | """A connectSSL going thru the tunnel.""" | 135 | """A connectSSL going thru the tunnel.""" |
1670 | 136 | logger.info("Connecting (SSL) to %r:%r via tunnel at %r:%r", | 136 | logger.info("Connecting (SSL) to %r:%r via tunnel at %r:%r", |
1671 | 137 | host, port, self.tunnel_host, self.tunnel_port) | 137 | host, port, self.tunnel_host, self.tunnel_port) |
1674 | 138 | tunnel_factory = TunnelClientFactory(host, port, factory, self.cookie, | 138 | tunnel_factory = TunnelClientFactory( |
1675 | 139 | contextFactory) | 139 | host, port, factory, self.cookie, contextFactory) |
1676 | 140 | return reactor.connectTCP(self.tunnel_host, self.tunnel_port, | 140 | return reactor.connectTCP(self.tunnel_host, self.tunnel_port, |
1677 | 141 | tunnel_factory, *args, **kwargs) | 141 | tunnel_factory, *args, **kwargs) |
1678 | 142 | 142 | ||
1679 | @@ -175,7 +175,8 @@ | |||
1680 | 175 | self.finish_timeout() | 175 | self.finish_timeout() |
1681 | 176 | logger.info("Tunnel process exit status %r.", status) | 176 | logger.info("Tunnel process exit status %r.", status) |
1682 | 177 | if not self.client_d.called: | 177 | if not self.client_d.called: |
1684 | 178 | logger.debug("Tunnel process exited before TunnelClient created. Falling back to reactor") | 178 | logger.debug("Tunnel process exited before TunnelClient created. " |
1685 | 179 | "Falling back to reactor") | ||
1686 | 179 | self.client_d.callback(reactor) | 180 | self.client_d.callback(reactor) |
1687 | 180 | 181 | ||
1688 | 181 | def outReceived(self, data): | 182 | def outReceived(self, data): |
1689 | 182 | 183 | ||
1690 | === modified file 'ubuntuone/proxy/tunnel_server.py' | |||
1691 | --- ubuntuone/proxy/tunnel_server.py 2015-09-17 02:20:40 +0000 | |||
1692 | +++ ubuntuone/proxy/tunnel_server.py 2015-09-19 23:19:46 +0000 | |||
1693 | @@ -260,7 +260,7 @@ | |||
1694 | 260 | raise | 260 | raise |
1695 | 261 | 261 | ||
1696 | 262 | credentials = yield Keyring().get_credentials( | 262 | credentials = yield Keyring().get_credentials( |
1698 | 263 | str(self.proxy_domain)) | 263 | str(self.proxy_domain)) |
1699 | 264 | if "username" in credentials: | 264 | if "username" in credentials: |
1700 | 265 | self.proxy_credentials = credentials | 265 | self.proxy_credentials = credentials |
1701 | 266 | logger.info("Connecting again with keyring credentials") | 266 | logger.info("Connecting again with keyring credentials") |
1702 | 267 | 267 | ||
1703 | === modified file 'ubuntuone/status/aggregator.py' | |||
1704 | --- ubuntuone/status/aggregator.py 2015-09-17 02:20:40 +0000 | |||
1705 | +++ ubuntuone/status/aggregator.py 2015-09-19 23:19:46 +0000 | |||
1706 | @@ -51,8 +51,9 @@ | |||
1707 | 51 | Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string) | 51 | Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string) |
1708 | 52 | 52 | ||
1709 | 53 | UBUNTUONE_TITLE = Q_("Magicicada") | 53 | UBUNTUONE_TITLE = Q_("Magicicada") |
1712 | 54 | UBUNTUONE_END = Q_("Magicicada file services will be " | 54 | UBUNTUONE_END = Q_( |
1713 | 55 | "shutting down on June 1st, 2014.\nThanks for your support.") | 55 | "Magicicada file services will be shutting down on June 1st, 2014.\n" |
1714 | 56 | "Thanks for your support.") | ||
1715 | 56 | NEW_UDFS_SENDER = Q_("New cloud folder(s) available") | 57 | NEW_UDFS_SENDER = Q_("New cloud folder(s) available") |
1716 | 57 | FINAL_COMPLETED = Q_("File synchronization completed.") | 58 | FINAL_COMPLETED = Q_("File synchronization completed.") |
1717 | 58 | 59 | ||
1718 | @@ -373,9 +374,8 @@ | |||
1719 | 373 | def __init__(self, *args): | 374 | def __init__(self, *args): |
1720 | 374 | """Initialize this instance.""" | 375 | """Initialize this instance.""" |
1721 | 375 | super(FileDiscoveryGatheringState, self).__init__(*args) | 376 | super(FileDiscoveryGatheringState, self).__init__(*args) |
1725 | 376 | self.timer = DeadlineTimer(self.initial_delay, | 377 | self.timer = DeadlineTimer( |
1726 | 377 | self.initial_timeout, | 378 | self.initial_delay, self.initial_timeout, clock=self.clock) |
1724 | 378 | clock=self.clock) | ||
1727 | 379 | self.timer.addCallback(self._timeout) | 379 | self.timer.addCallback(self._timeout) |
1728 | 380 | 380 | ||
1729 | 381 | def _timeout(self, result): | 381 | def _timeout(self, result): |
1730 | @@ -624,7 +624,6 @@ | |||
1731 | 624 | """Create a new toggleable notification object.""" | 624 | """Create a new toggleable notification object.""" |
1732 | 625 | return self.notification_switch.get_notification() | 625 | return self.notification_switch.get_notification() |
1733 | 626 | 626 | ||
1734 | 627 | # pylint: disable=W0201 | ||
1735 | 628 | def reset(self): | 627 | def reset(self): |
1736 | 629 | """Reset all counters and notifications.""" | 628 | """Reset all counters and notifications.""" |
1737 | 630 | self.download_done = 0 | 629 | self.download_done = 0 |
1738 | @@ -647,7 +646,6 @@ | |||
1739 | 647 | self.final_status_bubble = FinalStatusBubble(self) | 646 | self.final_status_bubble = FinalStatusBubble(self) |
1740 | 648 | self.progress = {} | 647 | self.progress = {} |
1741 | 649 | self.to_do = {} | 648 | self.to_do = {} |
1742 | 650 | # pylint: enable=W0201 | ||
1743 | 651 | 649 | ||
1744 | 652 | def register_progress_listener(self, listener): | 650 | def register_progress_listener(self, listener): |
1745 | 653 | """Register a callable object to be notified.""" | 651 | """Register a callable object to be notified.""" |
1746 | @@ -736,11 +734,9 @@ | |||
1747 | 736 | if command.deflated_size is not None: | 734 | if command.deflated_size is not None: |
1748 | 737 | self.to_do[ | 735 | self.to_do[ |
1749 | 738 | (command.share_id, command.node_id)] = command.deflated_size | 736 | (command.share_id, command.node_id)] = command.deflated_size |
1750 | 739 | # pylint: disable=W0201 | ||
1751 | 740 | if not self.downloading_filename: | 737 | if not self.downloading_filename: |
1752 | 741 | self.downloading_filename = os.path.basename( | 738 | self.downloading_filename = os.path.basename( |
1753 | 742 | self.files_downloading[0].path) | 739 | self.files_downloading[0].path) |
1754 | 743 | # pylint: enable=W0201 | ||
1755 | 744 | self.update_progressbar() | 740 | self.update_progressbar() |
1756 | 745 | logger.debug( | 741 | logger.debug( |
1757 | 746 | "queueing command (total: %d): %s", | 742 | "queueing command (total: %d): %s", |
1758 | @@ -770,11 +766,9 @@ | |||
1759 | 770 | if command.deflated_size is not None: | 766 | if command.deflated_size is not None: |
1760 | 771 | self.to_do[ | 767 | self.to_do[ |
1761 | 772 | (command.share_id, command.node_id)] = command.deflated_size | 768 | (command.share_id, command.node_id)] = command.deflated_size |
1762 | 773 | # pylint: disable=W0201 | ||
1763 | 774 | if not self.uploading_filename: | 769 | if not self.uploading_filename: |
1764 | 775 | self.uploading_filename = os.path.basename( | 770 | self.uploading_filename = os.path.basename( |
1765 | 776 | self.files_uploading[0].path) | 771 | self.files_uploading[0].path) |
1766 | 777 | # pylint: enable=W0201 | ||
1767 | 778 | self.update_progressbar() | 772 | self.update_progressbar() |
1768 | 779 | logger.debug( | 773 | logger.debug( |
1769 | 780 | "queueing command (total: %d): %s", len(self.to_do), | 774 | "queueing command (total: %d): %s", len(self.to_do), |
1770 | @@ -839,8 +833,8 @@ | |||
1771 | 839 | def start_sync_menu(self): | 833 | def start_sync_menu(self): |
1772 | 840 | """Create the sync menu and register the progress listener.""" | 834 | """Create the sync menu and register the progress listener.""" |
1773 | 841 | if self.syncdaemon_service is not None: | 835 | if self.syncdaemon_service is not None: |
1776 | 842 | self.sync_menu = sync_menu.UbuntuOneSyncMenu(self, | 836 | self.sync_menu = sync_menu.UbuntuOneSyncMenu( |
1777 | 843 | self.syncdaemon_service) | 837 | self, self.syncdaemon_service) |
1778 | 844 | self.aggregator.register_connection_listener( | 838 | self.aggregator.register_connection_listener( |
1779 | 845 | self.sync_menu.sync_status_changed) | 839 | self.sync_menu.sync_status_changed) |
1780 | 846 | self.aggregator.register_progress_listener( | 840 | self.aggregator.register_progress_listener( |
1781 | @@ -855,8 +849,9 @@ | |||
1782 | 855 | uploading = [] | 849 | uploading = [] |
1783 | 856 | for upload in self.aggregator.files_uploading: | 850 | for upload in self.aggregator.files_uploading: |
1784 | 857 | if upload.deflated_size not in (0, None): | 851 | if upload.deflated_size not in (0, None): |
1787 | 858 | uploading.append((upload.path, upload.deflated_size, | 852 | uploading.append( |
1788 | 859 | upload.n_bytes_written)) | 853 | (upload.path, upload.deflated_size, upload.n_bytes_written) |
1789 | 854 | ) | ||
1790 | 860 | return uploading | 855 | return uploading |
1791 | 861 | 856 | ||
1792 | 862 | def files_downloading(self): | 857 | def files_downloading(self): |
1793 | @@ -874,7 +869,7 @@ | |||
1794 | 874 | self.notification.send_notification( | 869 | self.notification.send_notification( |
1795 | 875 | UBUNTUONE_TITLE, status_event.one()) | 870 | UBUNTUONE_TITLE, status_event.one()) |
1796 | 876 | 871 | ||
1798 | 877 | def file_unpublished(self, public_url): # pylint: disable=W0613 | 872 | def file_unpublished(self, public_url): |
1799 | 878 | """A file was unpublished.""" | 873 | """A file was unpublished.""" |
1800 | 879 | self.notification.send_notification( | 874 | self.notification.send_notification( |
1801 | 880 | UBUNTUONE_TITLE, FileUnpublishingStatus().one()) | 875 | UBUNTUONE_TITLE, FileUnpublishingStatus().one()) |
1802 | 881 | 876 | ||
1803 | === modified file 'ubuntuone/syncdaemon/__init__.py' | |||
1804 | --- ubuntuone/syncdaemon/__init__.py 2015-09-17 02:20:40 +0000 | |||
1805 | +++ ubuntuone/syncdaemon/__init__.py 2015-09-19 23:19:46 +0000 | |||
1806 | @@ -29,16 +29,12 @@ | |||
1807 | 29 | """Client module.""" | 29 | """Client module.""" |
1808 | 30 | 30 | ||
1809 | 31 | # required capabilities | 31 | # required capabilities |
1820 | 32 | REQUIRED_CAPS = frozenset(["no-content", | 32 | REQUIRED_CAPS = frozenset( |
1821 | 33 | "account-info", | 33 | ["no-content", "account-info", "resumable-uploads", "fix462230", "volumes", |
1822 | 34 | "resumable-uploads", | 34 | "generations"]) |
1823 | 35 | "fix462230", | 35 | |
1824 | 36 | "volumes", | 36 | |
1825 | 37 | "generations", | 37 | # Sync Menu data constants |
1816 | 38 | ]) | ||
1817 | 39 | |||
1818 | 40 | |||
1819 | 41 | #Sync Menu data constants | ||
1826 | 42 | RECENT_TRANSFERS = 'recent-transfers' | 38 | RECENT_TRANSFERS = 'recent-transfers' |
1827 | 43 | UPLOADING = 'uploading' | 39 | UPLOADING = 'uploading' |
1828 | 44 | DOWNLOADING = 'downloading' | 40 | DOWNLOADING = 'downloading' |
1829 | 45 | 41 | ||
1830 | === modified file 'ubuntuone/syncdaemon/action_queue.py' | |||
1831 | --- ubuntuone/syncdaemon/action_queue.py 2015-09-17 02:20:40 +0000 | |||
1832 | +++ ubuntuone/syncdaemon/action_queue.py 2015-09-19 23:19:46 +0000 | |||
1833 | @@ -543,7 +543,7 @@ | |||
1834 | 543 | upload.deflated_size = tempfile.tell() | 543 | upload.deflated_size = tempfile.tell() |
1835 | 544 | 544 | ||
1836 | 545 | upload.magic_hash = magic_hasher.content_hash() | 545 | upload.magic_hash = magic_hasher.content_hash() |
1838 | 546 | except Exception, e: # pylint: disable-msg=W0703 | 546 | except Exception as e: |
1839 | 547 | failed = True | 547 | failed = True |
1840 | 548 | if tempfile is not None: | 548 | if tempfile is not None: |
1841 | 549 | tempfile.close() | 549 | tempfile.close() |
1842 | @@ -564,7 +564,7 @@ | |||
1843 | 564 | try: | 564 | try: |
1844 | 565 | try: | 565 | try: |
1845 | 566 | fileobj = fileobj_factory() | 566 | fileobj = fileobj_factory() |
1847 | 567 | except StandardError, e: | 567 | except StandardError as e: |
1848 | 568 | # maybe the user deleted the file before we got to upload it | 568 | # maybe the user deleted the file before we got to upload it |
1849 | 569 | upload.log.warn("Unable to build fileobj (%s: '%s') so " | 569 | upload.log.warn("Unable to build fileobj (%s: '%s') so " |
1850 | 570 | "cancelling the upload.", type(e), e) | 570 | "cancelling the upload.", type(e), e) |
1851 | @@ -884,7 +884,6 @@ | |||
1852 | 884 | def on_lookup_ok(results): | 884 | def on_lookup_ok(results): |
1853 | 885 | """Get a random host from the SRV result.""" | 885 | """Get a random host from the SRV result.""" |
1854 | 886 | logger.debug('SRV lookup done, choosing a server.') | 886 | logger.debug('SRV lookup done, choosing a server.') |
1855 | 887 | # pylint: disable-msg=W0612 | ||
1856 | 888 | records, auth, add = results | 887 | records, auth, add = results |
1857 | 889 | if not records: | 888 | if not records: |
1858 | 890 | raise ValueError('No available records.') | 889 | raise ValueError('No available records.') |
1859 | @@ -1312,7 +1311,6 @@ | |||
1860 | 1312 | """Base of all the action queue commands.""" | 1311 | """Base of all the action queue commands.""" |
1861 | 1313 | 1312 | ||
1862 | 1314 | # the info used in the protocol errors is hidden, but very useful! | 1313 | # the info used in the protocol errors is hidden, but very useful! |
1863 | 1315 | # pylint: disable-msg=W0212 | ||
1864 | 1316 | suppressed_error_messages = ( | 1314 | suppressed_error_messages = ( |
1865 | 1317 | [x for x in protocol_errors._error_mapping.values() | 1315 | [x for x in protocol_errors._error_mapping.values() |
1866 | 1318 | if x is not protocol_errors.InternalError] + | 1316 | if x is not protocol_errors.InternalError] + |
1867 | @@ -1393,7 +1391,7 @@ | |||
1868 | 1393 | for (name, marker, deferred) in waiting_structure: | 1391 | for (name, marker, deferred) in waiting_structure: |
1869 | 1394 | try: | 1392 | try: |
1870 | 1395 | value = yield deferred | 1393 | value = yield deferred |
1872 | 1396 | except Exception, e: | 1394 | except Exception as e: |
1873 | 1397 | # on first failure, errback the marker resolved flag, and | 1395 | # on first failure, errback the marker resolved flag, and |
1874 | 1398 | # quit waiting for other deferreds | 1396 | # quit waiting for other deferreds |
1875 | 1399 | self.log.error("failed %r", marker) | 1397 | self.log.error("failed %r", marker) |
1876 | @@ -2487,8 +2485,8 @@ | |||
1877 | 2487 | """A streaming decompressor.""" | 2485 | """A streaming decompressor.""" |
1878 | 2488 | self.n_bytes_read += len(bytes) | 2486 | self.n_bytes_read += len(bytes) |
1879 | 2489 | self.fileobj.write(self.gunzip.decompress(bytes)) | 2487 | self.fileobj.write(self.gunzip.decompress(bytes)) |
1882 | 2490 | self.fileobj.flush() # not strictly necessary but nice to | 2488 | # not strictly necessary but nice to see the downloaded size |
1883 | 2491 | # see the downloaded size | 2489 | self.fileobj.flush() |
1884 | 2492 | self.progress_hook() | 2490 | self.progress_hook() |
1885 | 2493 | 2491 | ||
1886 | 2494 | def progress_hook(self): | 2492 | def progress_hook(self): |
1887 | @@ -2608,7 +2606,8 @@ | |||
1888 | 2608 | def cleanup(self): | 2606 | def cleanup(self): |
1889 | 2609 | """Cleanup: stop the producer.""" | 2607 | """Cleanup: stop the producer.""" |
1890 | 2610 | self.log.debug('cleanup') | 2608 | self.log.debug('cleanup') |
1892 | 2611 | if self.upload_req is not None and self.upload_req.producer is not None: | 2609 | if (self.upload_req is not None and |
1893 | 2610 | self.upload_req.producer is not None): | ||
1894 | 2612 | self.log.debug('stopping the producer') | 2611 | self.log.debug('stopping the producer') |
1895 | 2613 | self.upload_req.producer.stopProducing() | 2612 | self.upload_req.producer.stopProducing() |
1896 | 2614 | 2613 | ||
1897 | 2615 | 2614 | ||
1898 | === modified file 'ubuntuone/syncdaemon/config.py' | |||
1899 | --- ubuntuone/syncdaemon/config.py 2015-09-19 21:04:46 +0000 | |||
1900 | +++ ubuntuone/syncdaemon/config.py 2015-09-19 23:19:46 +0000 | |||
1901 | @@ -260,7 +260,7 @@ | |||
1902 | 260 | # override the default in the new setting | 260 | # override the default in the new setting |
1903 | 261 | current.value = old.value | 261 | current.value = old.value |
1904 | 262 | cp.set('logging', 'level', current) | 262 | cp.set('logging', 'level', current) |
1906 | 263 | #else, we ignore the setting as we have a non-default | 263 | # else, we ignore the setting as we have a non-default |
1907 | 264 | # value in logging-level (newer setting wins) | 264 | # value in logging-level (newer setting wins) |
1908 | 265 | logger.warning("Found deprecated config option 'log_level'" | 265 | logger.warning("Found deprecated config option 'log_level'" |
1909 | 266 | " in section: MAIN") | 266 | " in section: MAIN") |
1910 | 267 | 267 | ||
1911 | === modified file 'ubuntuone/syncdaemon/event_queue.py' | |||
1912 | --- ubuntuone/syncdaemon/event_queue.py 2012-08-08 13:21:13 +0000 | |||
1913 | +++ ubuntuone/syncdaemon/event_queue.py 2015-09-19 23:19:46 +0000 | |||
1914 | @@ -105,7 +105,7 @@ | |||
1915 | 105 | 'AQ_DELTA_ERROR': ('volume_id', 'error'), | 105 | 'AQ_DELTA_ERROR': ('volume_id', 'error'), |
1916 | 106 | 'AQ_DELTA_NOT_POSSIBLE': ('volume_id',), | 106 | 'AQ_DELTA_NOT_POSSIBLE': ('volume_id',), |
1917 | 107 | 'AQ_RESCAN_FROM_SCRATCH_OK': ('volume_id', 'delta_content', | 107 | 'AQ_RESCAN_FROM_SCRATCH_OK': ('volume_id', 'delta_content', |
1919 | 108 | 'end_generation', 'free_bytes'), # must always be full | 108 | 'end_generation', 'free_bytes'), |
1920 | 109 | 'AQ_RESCAN_FROM_SCRATCH_ERROR': ('volume_id', 'error'), | 109 | 'AQ_RESCAN_FROM_SCRATCH_ERROR': ('volume_id', 'error'), |
1921 | 110 | 110 | ||
1922 | 111 | 'SV_SHARE_CHANGED': ('info',), | 111 | 'SV_SHARE_CHANGED': ('info',), |
1923 | 112 | 112 | ||
1924 | === modified file 'ubuntuone/syncdaemon/events_nanny.py' | |||
1925 | --- ubuntuone/syncdaemon/events_nanny.py 2012-04-09 20:07:05 +0000 | |||
1926 | +++ ubuntuone/syncdaemon/events_nanny.py 2015-09-19 23:19:46 +0000 | |||
1927 | @@ -41,7 +41,7 @@ | |||
1928 | 41 | """ | 41 | """ |
1929 | 42 | def __init__(self, fsm, eq, hq): | 42 | def __init__(self, fsm, eq, hq): |
1930 | 43 | self.logger = logging.getLogger( | 43 | self.logger = logging.getLogger( |
1932 | 44 | 'ubuntuone.SyncDaemon.DownloadFinishedNanny') | 44 | 'ubuntuone.SyncDaemon.DownloadFinishedNanny') |
1933 | 45 | self.fsm = fsm | 45 | self.fsm = fsm |
1934 | 46 | self.eq = eq | 46 | self.eq = eq |
1935 | 47 | self.hq = hq | 47 | self.hq = hq |
1936 | 48 | 48 | ||
1937 | === modified file 'ubuntuone/syncdaemon/file_shelf.py' | |||
1938 | --- ubuntuone/syncdaemon/file_shelf.py 2012-04-09 20:07:05 +0000 | |||
1939 | +++ ubuntuone/syncdaemon/file_shelf.py 2015-09-19 23:19:46 +0000 | |||
1940 | @@ -108,7 +108,6 @@ | |||
1941 | 108 | 108 | ||
1942 | 109 | def keys(self): | 109 | def keys(self): |
1943 | 110 | """ returns a iterator over the keys """ | 110 | """ returns a iterator over the keys """ |
1944 | 111 | # pylint: disable-msg=W0612 | ||
1945 | 112 | splitext = os.path.splitext | 111 | splitext = os.path.splitext |
1946 | 113 | for dirpath, dirnames, filenames in walk(self._path): | 112 | for dirpath, dirnames, filenames in walk(self._path): |
1947 | 114 | for filename in filenames: | 113 | for filename in filenames: |
1948 | @@ -125,7 +124,6 @@ | |||
1949 | 125 | 124 | ||
1950 | 126 | def __contains__(self, key): | 125 | def __contains__(self, key): |
1951 | 127 | """ returns if the file storage has that key """ | 126 | """ returns if the file storage has that key """ |
1952 | 128 | # this method surely has some effect! pylint: disable-msg=W0104 | ||
1953 | 129 | try: | 127 | try: |
1954 | 130 | self[key] | 128 | self[key] |
1955 | 131 | except KeyError: | 129 | except KeyError: |
1956 | @@ -205,7 +203,6 @@ | |||
1957 | 205 | To get len(keys) we need to iterate over the full key set. | 203 | To get len(keys) we need to iterate over the full key set. |
1958 | 206 | """ | 204 | """ |
1959 | 207 | counter = 0 | 205 | counter = 0 |
1960 | 208 | # pylint: disable-msg=W0612 | ||
1961 | 209 | for key in self.keys(): | 206 | for key in self.keys(): |
1962 | 210 | counter += 1 | 207 | counter += 1 |
1963 | 211 | return counter | 208 | return counter |
1964 | @@ -343,9 +340,8 @@ | |||
1965 | 343 | self._queue.append(k) | 340 | self._queue.append(k) |
1966 | 344 | else: | 341 | else: |
1967 | 345 | self._refcount[k] -= 1 | 342 | self._refcount[k] -= 1 |
1971 | 346 | if not (len(self._queue) == len(self._cache) \ | 343 | if (not (len(self._queue) == len(self._cache) == |
1972 | 347 | == len(self._refcount) \ | 344 | len(self._refcount) == sum(self._refcount.itervalues()))): |
1970 | 348 | == sum(self._refcount.itervalues())): | ||
1973 | 349 | # create a custom exception for this error | 345 | # create a custom exception for this error |
1974 | 350 | raise CacheInconsistencyError(len(self._queue), | 346 | raise CacheInconsistencyError(len(self._queue), |
1975 | 351 | len(self._cache), | 347 | len(self._cache), |
1976 | @@ -357,5 +353,6 @@ | |||
1977 | 357 | """Exception representing a inconsistency in the cache""" | 353 | """Exception representing a inconsistency in the cache""" |
1978 | 358 | 354 | ||
1979 | 359 | def __str__(self): | 355 | def __str__(self): |
1982 | 360 | return "Inconsistency in the cache: queue: %d cache: %d refcount: %d" \ | 356 | return ( |
1983 | 361 | " sum(refcount.values): %d" % self.args | 357 | "Inconsistency in the cache: queue: %d cache: %d refcount: %d " |
1984 | 358 | "sum(refcount.values): %d" % self.args) | ||
1985 | 362 | 359 | ||
1986 | === modified file 'ubuntuone/syncdaemon/filesystem_manager.py' | |||
1987 | --- ubuntuone/syncdaemon/filesystem_manager.py 2015-09-17 02:20:40 +0000 | |||
1988 | +++ ubuntuone/syncdaemon/filesystem_manager.py 2015-09-19 23:19:46 +0000 | |||
1989 | @@ -198,7 +198,7 @@ | |||
1990 | 198 | 198 | ||
1991 | 199 | class ShareNodeDict(dict): | 199 | class ShareNodeDict(dict): |
1992 | 200 | """Cache for node_id and share.""" | 200 | """Cache for node_id and share.""" |
1994 | 201 | # pylint: disable-msg=W0612 | 201 | |
1995 | 202 | def __getitem__(self, key): | 202 | def __getitem__(self, key): |
1996 | 203 | share_id, node_id = key | 203 | share_id, node_id = key |
1997 | 204 | if node_id is None: | 204 | if node_id is None: |
1998 | @@ -337,8 +337,8 @@ | |||
1999 | 337 | # ensure that we can write in the partials_dir | 337 | # ensure that we can write in the partials_dir |
2000 | 338 | set_dir_readwrite(self.partials_dir) | 338 | set_dir_readwrite(self.partials_dir) |
2001 | 339 | self.fs = TritcaskShelf(FSM_ROW_TYPE, db) | 339 | self.fs = TritcaskShelf(FSM_ROW_TYPE, db) |
2004 | 340 | self.old_fs = file_shelf.CachedFileShelf(fsmdir, cache_size=1500, | 340 | self.old_fs = file_shelf.CachedFileShelf( |
2005 | 341 | cache_compact_threshold=4) | 341 | fsmdir, cache_size=1500, cache_compact_threshold=4) |
2006 | 342 | self.trash = TrashTritcaskShelf(TRASH_ROW_TYPE, db) | 342 | self.trash = TrashTritcaskShelf(TRASH_ROW_TYPE, db) |
2007 | 343 | self.move_limbo = TrashTritcaskShelf(MOVE_LIMBO_ROW_TYPE, db) | 343 | self.move_limbo = TrashTritcaskShelf(MOVE_LIMBO_ROW_TYPE, db) |
2008 | 344 | self.shares = {} | 344 | self.shares = {} |
2009 | @@ -415,8 +415,8 @@ | |||
2010 | 415 | base_path.endswith('Magicicada/Shared With Me'): | 415 | base_path.endswith('Magicicada/Shared With Me'): |
2011 | 416 | realpath = os.path.realpath(mdobj['path']) | 416 | realpath = os.path.realpath(mdobj['path']) |
2012 | 417 | mdobj['path'] = realpath | 417 | mdobj['path'] = realpath |
2015 | 418 | if base_path.startswith('/') and \ | 418 | if (base_path.startswith('/') and base_path.endswith('Magicicada') |
2016 | 419 | base_path.endswith('Magicicada') and name == 'My Files': | 419 | and name == 'My Files'): |
2017 | 420 | mdobj['path'] = base_path | 420 | mdobj['path'] = base_path |
2018 | 421 | 421 | ||
2019 | 422 | def _migrate_trash_to_tritcask(self): | 422 | def _migrate_trash_to_tritcask(self): |
2020 | @@ -766,7 +766,7 @@ | |||
2021 | 766 | for _, v in self.fs.items(): | 766 | for _, v in self.fs.items(): |
2022 | 767 | if v['node_id']: | 767 | if v['node_id']: |
2023 | 768 | all_data.append( | 768 | all_data.append( |
2025 | 769 | (v['share_id'], v['node_id'], v['server_hash'])) | 769 | (v['share_id'], v['node_id'], v['server_hash'])) |
2026 | 770 | return all_data | 770 | return all_data |
2027 | 771 | 771 | ||
2028 | 772 | def get_for_server_rescan_by_path(self, base_path): | 772 | def get_for_server_rescan_by_path(self, base_path): |
2029 | @@ -842,7 +842,6 @@ | |||
2030 | 842 | from_context = self._enable_share_write(mdobj['share_id'], path_from) | 842 | from_context = self._enable_share_write(mdobj['share_id'], path_from) |
2031 | 843 | to_context = self._enable_share_write(new_share_id, path_to) | 843 | to_context = self._enable_share_write(new_share_id, path_to) |
2032 | 844 | 844 | ||
2033 | 845 | # pylint: disable-msg=W0704 | ||
2034 | 846 | if mdobj["is_dir"]: | 845 | if mdobj["is_dir"]: |
2035 | 847 | expected_event = "FS_DIR_MOVE" | 846 | expected_event = "FS_DIR_MOVE" |
2036 | 848 | else: | 847 | else: |
2037 | @@ -866,7 +865,7 @@ | |||
2038 | 866 | path_to = normpath(path_to) | 865 | path_to = normpath(path_to) |
2039 | 867 | mdid = self._idx_path.pop(path_from) | 866 | mdid = self._idx_path.pop(path_from) |
2040 | 868 | log_debug("move_file: mdid=%r path_from=%r path_to=%r", | 867 | log_debug("move_file: mdid=%r path_from=%r path_to=%r", |
2042 | 869 | mdid, path_from, path_to) | 868 | mdid, path_from, path_to) |
2043 | 870 | 869 | ||
2044 | 871 | # if the move overwrites other file, send it to trash | 870 | # if the move overwrites other file, send it to trash |
2045 | 872 | if path_to in self._idx_path: | 871 | if path_to in self._idx_path: |
2046 | @@ -887,7 +886,6 @@ | |||
2047 | 887 | mdobj["info"]["last_moved_from"] = path_from | 886 | mdobj["info"]["last_moved_from"] = path_from |
2048 | 888 | mdobj["info"]["last_moved_time"] = time.time() | 887 | mdobj["info"]["last_moved_time"] = time.time() |
2049 | 889 | # we try to stat, if we fail, so what? | 888 | # we try to stat, if we fail, so what? |
2050 | 890 | #pylint: disable-msg=W0704 | ||
2051 | 891 | try: | 889 | try: |
2052 | 892 | mdobj["stat"] = stat_path(path_to) # needed if not the same FS | 890 | mdobj["stat"] = stat_path(path_to) # needed if not the same FS |
2053 | 893 | except OSError: | 891 | except OSError: |
2054 | @@ -968,8 +966,8 @@ | |||
2055 | 968 | # not empty, need to check if we can delete it | 966 | # not empty, need to check if we can delete it |
2056 | 969 | subtree = self._delete_dir_tree(path=path) | 967 | subtree = self._delete_dir_tree(path=path) |
2057 | 970 | for p, is_dir in subtree: | 968 | for p, is_dir in subtree: |
2060 | 971 | filter_name = "FS_DIR_DELETE" if is_dir \ | 969 | filter_name = ( |
2061 | 972 | else "FS_FILE_DELETE" | 970 | "FS_DIR_DELETE" if is_dir else "FS_FILE_DELETE") |
2062 | 973 | self.eq.add_to_mute_filter(filter_name, path=p) | 971 | self.eq.add_to_mute_filter(filter_name, path=p) |
2063 | 974 | self.delete_metadata(p) | 972 | self.delete_metadata(p) |
2064 | 975 | 973 | ||
2065 | @@ -1031,7 +1029,7 @@ | |||
2066 | 1031 | raise | 1029 | raise |
2067 | 1032 | 1030 | ||
2068 | 1033 | for p, is_dir in self.get_paths_starting_with( | 1031 | for p, is_dir in self.get_paths_starting_with( |
2070 | 1034 | path, include_base=False): | 1032 | path, include_base=False): |
2071 | 1035 | if is_dir: | 1033 | if is_dir: |
2072 | 1036 | # remove inotify watch | 1034 | # remove inotify watch |
2073 | 1037 | try: | 1035 | try: |
2074 | @@ -1180,7 +1178,6 @@ | |||
2075 | 1180 | log_debug("remove_partial: path=%r mdid=%r share_id=%r node_id=%r", | 1178 | log_debug("remove_partial: path=%r mdid=%r share_id=%r node_id=%r", |
2076 | 1181 | path, mdid, share_id, node_id) | 1179 | path, mdid, share_id, node_id) |
2077 | 1182 | partial_path = self._get_partial_path(mdobj) | 1180 | partial_path = self._get_partial_path(mdobj) |
2078 | 1183 | #pylint: disable-msg=W0704 | ||
2079 | 1184 | try: | 1181 | try: |
2080 | 1185 | # don't alert EQ, partials are in other directory, not watched | 1182 | # don't alert EQ, partials are in other directory, not watched |
2081 | 1186 | remove_file(partial_path) | 1183 | remove_file(partial_path) |
2082 | @@ -1289,8 +1286,8 @@ | |||
2083 | 1289 | for p, m in self._idx_path.iteritems(): | 1286 | for p, m in self._idx_path.iteritems(): |
2084 | 1290 | if os.path.dirname(p) == path and p != path: | 1287 | if os.path.dirname(p) == path and p != path: |
2085 | 1291 | mdobj = self.fs[m] | 1288 | mdobj = self.fs[m] |
2088 | 1292 | yield (os.path.basename(p), mdobj["is_dir"], | 1289 | yield ( |
2089 | 1293 | mdobj["node_id"]) | 1290 | os.path.basename(p), mdobj["is_dir"], mdobj["node_id"]) |
2090 | 1294 | 1291 | ||
2091 | 1295 | return sorted(_get_all()) | 1292 | return sorted(_get_all()) |
2092 | 1296 | 1293 | ||
2093 | @@ -1309,7 +1306,6 @@ | |||
2094 | 1309 | if path == share.path: | 1306 | if path == share.path: |
2095 | 1310 | # the relaitve path is the fullpath | 1307 | # the relaitve path is the fullpath |
2096 | 1311 | return share.path | 1308 | return share.path |
2097 | 1312 | # pylint: disable-msg=W0612 | ||
2098 | 1313 | head, sep, tail = path.rpartition(share.path) | 1309 | head, sep, tail = path.rpartition(share.path) |
2099 | 1314 | if sep == '': | 1310 | if sep == '': |
2100 | 1315 | raise ValueError("'%s' isn't a child of '%s'" % (path, share.path)) | 1311 | raise ValueError("'%s' isn't a child of '%s'" % (path, share.path)) |
2101 | @@ -1375,10 +1371,9 @@ | |||
2102 | 1375 | mdobj = self.fs[m] | 1371 | mdobj = self.fs[m] |
2103 | 1376 | # ignore shares that are not root (root is id='') | 1372 | # ignore shares that are not root (root is id='') |
2104 | 1377 | # and ignore files not present on the server | 1373 | # and ignore files not present on the server |
2109 | 1378 | if ((ignore_shares and | 1374 | if ((ignore_shares and mdobj["share_id"] != '' and |
2110 | 1379 | mdobj["share_id"] != '' and | 1375 | mdobj["share_id"] in self.vm.shares) or |
2111 | 1380 | mdobj["share_id"] in self.vm.shares) | 1376 | not mdobj["server_hash"]): |
2108 | 1381 | or not mdobj["server_hash"]): | ||
2112 | 1382 | continue | 1377 | continue |
2113 | 1383 | if pattern.search(p): | 1378 | if pattern.search(p): |
2114 | 1384 | yield p | 1379 | yield p |
2115 | 1385 | 1380 | ||
2116 | === modified file 'ubuntuone/syncdaemon/filesystem_notifications.py' | |||
2117 | --- ubuntuone/syncdaemon/filesystem_notifications.py 2012-07-17 11:36:12 +0000 | |||
2118 | +++ ubuntuone/syncdaemon/filesystem_notifications.py 2015-09-19 23:19:46 +0000 | |||
2119 | @@ -43,9 +43,9 @@ | |||
2120 | 43 | """Processor that takes care of dealing with the events.""" | 43 | """Processor that takes care of dealing with the events.""" |
2121 | 44 | 44 | ||
2122 | 45 | def __init__(self, monitor, handle_dir_delete, name_translations, | 45 | def __init__(self, monitor, handle_dir_delete, name_translations, |
2126 | 46 | platform_is_ignored, ignore_mask, ignore_config=None): | 46 | platform_is_ignored, ignore_mask, ignore_config=None): |
2127 | 47 | self.log = logging.getLogger('ubuntuone.SyncDaemon.' | 47 | self.log = logging.getLogger( |
2128 | 48 | + 'filesystem_notifications.GeneralProcessor') | 48 | 'ubuntuone.SyncDaemon.filesystem_notifications.GeneralProcessor') |
2129 | 49 | self.log.setLevel(TRACE) | 49 | self.log.setLevel(TRACE) |
2130 | 50 | self.invnames_log = logging.getLogger( | 50 | self.invnames_log = logging.getLogger( |
2131 | 51 | 'ubuntuone.SyncDaemon.InvalidNames') | 51 | 'ubuntuone.SyncDaemon.InvalidNames') |
2132 | @@ -97,8 +97,8 @@ | |||
2133 | 97 | 97 | ||
2134 | 98 | def get_paths_starting_with(self, path, include_base=True): | 98 | def get_paths_starting_with(self, path, include_base=True): |
2135 | 99 | """Return all the paths that start with the given one.""" | 99 | """Return all the paths that start with the given one.""" |
2138 | 100 | return self.monitor.fs.get_paths_starting_with(path, | 100 | return self.monitor.fs.get_paths_starting_with( |
2139 | 101 | include_base=False) | 101 | path, include_base=False) |
2140 | 102 | 102 | ||
2141 | 103 | def rm_watch(self, path): | 103 | def rm_watch(self, path): |
2142 | 104 | """Remove the watch for the given path.""" | 104 | """Remove the watch for the given path.""" |
2143 | @@ -185,8 +185,8 @@ | |||
2144 | 185 | else: | 185 | else: |
2145 | 186 | - push the here received events, return False | 186 | - push the here received events, return False |
2146 | 187 | """ | 187 | """ |
2149 | 188 | self.log.trace("Freeze commit: %r (%d events)", | 188 | self.log.trace( |
2150 | 189 | self.frozen_path, len(events)) | 189 | "Freeze commit: %r (%d events)", self.frozen_path, len(events)) |
2151 | 190 | if self.frozen_evts: | 190 | if self.frozen_evts: |
2152 | 191 | # ouch! we're dirty! | 191 | # ouch! we're dirty! |
2153 | 192 | self.log.debug("Dirty by %s", self.frozen_evts) | 192 | self.log.debug("Dirty by %s", self.frozen_evts) |
2154 | 193 | 193 | ||
2155 | === modified file 'ubuntuone/syncdaemon/fsm/fsm.py' | |||
2156 | --- ubuntuone/syncdaemon/fsm/fsm.py 2012-04-09 20:07:05 +0000 | |||
2157 | +++ ubuntuone/syncdaemon/fsm/fsm.py 2015-09-19 23:19:46 +0000 | |||
2158 | @@ -83,7 +83,6 @@ | |||
2159 | 83 | """ | 83 | """ |
2160 | 84 | items = varlist.items() | 84 | items = varlist.items() |
2161 | 85 | keys = [x[0] for x in items] | 85 | keys = [x[0] for x in items] |
2162 | 86 | # pylint: disable-msg=W0631 | ||
2163 | 87 | values = [x[1] for x in items] | 86 | values = [x[1] for x in items] |
2164 | 88 | 87 | ||
2165 | 89 | possible_states = [dict(zip(keys, state)) | 88 | possible_states = [dict(zip(keys, state)) |
2166 | @@ -150,7 +149,6 @@ | |||
2167 | 150 | elif af == "pass": | 149 | elif af == "pass": |
2168 | 151 | self.log.debug("passing") | 150 | self.log.debug("passing") |
2169 | 152 | else: | 151 | else: |
2170 | 153 | # pylint: disable-msg=W0703 | ||
2171 | 154 | self.log.info("Calling %s (got %s:%s)", | 152 | self.log.info("Calling %s (got %s:%s)", |
2172 | 155 | action_func_name, event_name, parameters) | 153 | action_func_name, event_name, parameters) |
2173 | 156 | try: | 154 | try: |
2174 | @@ -165,19 +163,18 @@ | |||
2175 | 165 | try: | 163 | try: |
2176 | 166 | out_state = self.get_state() | 164 | out_state = self.get_state() |
2177 | 167 | except KeyError: | 165 | except KeyError: |
2182 | 168 | self.log.error("from state %s on %s:%s, " | 166 | self.log.error( |
2183 | 169 | "cant find current out state: %s" % ( | 167 | "from state %s on %s:%s, cant find current out state: %s", |
2184 | 170 | enter_state.values, event_name, parameters, | 168 | enter_state.values, event_name, parameters, |
2185 | 171 | self.get_state_values())) | 169 | self.get_state_values()) |
2186 | 172 | self.on_error(event_name, parameters) | 170 | self.on_error(event_name, parameters) |
2187 | 173 | raise KeyError("unknown out state") | 171 | raise KeyError("unknown out state") |
2188 | 174 | 172 | ||
2189 | 175 | if out_state.values != transition.target: | 173 | if out_state.values != transition.target: |
2190 | 176 | self.log.error( | 174 | self.log.error( |
2195 | 177 | "in state %s with event %s:%s, out state is:" | 175 | "in state %s with event %s:%s, out state is: %s and should " |
2196 | 178 | "%s and should be %s" % ( | 176 | "be %s", enter_state.values, event_name, parameters, |
2197 | 179 | enter_state.values, event_name, parameters, | 177 | out_state.values, transition.target) |
2194 | 180 | out_state.values, transition.target)) | ||
2198 | 181 | raise ValueError("Incorrect out state") | 178 | raise ValueError("Incorrect out state") |
2199 | 182 | self.log.debug("Called %s", action_func_name) | 179 | self.log.debug("Called %s", action_func_name) |
2200 | 183 | return action_func_name | 180 | return action_func_name |
2201 | @@ -218,8 +215,6 @@ | |||
2202 | 218 | spec = fsm_parser.parse(input_data) | 215 | spec = fsm_parser.parse(input_data) |
2203 | 219 | elif input_data.endswith(".py"): | 216 | elif input_data.endswith(".py"): |
2204 | 220 | result = {} | 217 | result = {} |
2205 | 221 | # pylint doesnt like exec | ||
2206 | 222 | # pylint: disable-msg=W0122 | ||
2207 | 223 | exec open(input_data) in result | 218 | exec open(input_data) in result |
2208 | 224 | spec = result["state_machine"] | 219 | spec = result["state_machine"] |
2209 | 225 | else: | 220 | else: |
2210 | @@ -250,9 +245,10 @@ | |||
2211 | 250 | try: | 245 | try: |
2212 | 251 | value = state[kind][name] | 246 | value = state[kind][name] |
2213 | 252 | except KeyError: | 247 | except KeyError: |
2217 | 253 | self.errors.append(ValidationError( | 248 | err = ValidationError( |
2218 | 254 | "variable name '%s' not found in section %s" % ( | 249 | "variable name '%s' not found in section %s" % |
2219 | 255 | name, kind))) | 250 | (name, kind)) |
2220 | 251 | self.errors.append(err) | ||
2221 | 256 | else: | 252 | else: |
2222 | 257 | if str(value).strip() == "=" and kind != "STATE_OUT": | 253 | if str(value).strip() == "=" and kind != "STATE_OUT": |
2223 | 258 | self.errors.append(ValidationError( | 254 | self.errors.append(ValidationError( |
2224 | @@ -298,7 +294,7 @@ | |||
2225 | 298 | 294 | ||
2226 | 299 | # build transitions | 295 | # build transitions |
2227 | 300 | for event_name, lines in self.spec["events"].items(): | 296 | for event_name, lines in self.spec["events"].items(): |
2229 | 301 | if self.event_filter and not event_name in self.event_filter: | 297 | if self.event_filter and event_name not in self.event_filter: |
2230 | 302 | continue | 298 | continue |
2231 | 303 | event = Event(event_name, lines, self) | 299 | event = Event(event_name, lines, self) |
2232 | 304 | self.events[event_name] = event | 300 | self.events[event_name] = event |
2233 | @@ -309,18 +305,17 @@ | |||
2234 | 309 | state = self.states[hash_dict(transition.source)] | 305 | state = self.states[hash_dict(transition.source)] |
2235 | 310 | except KeyError: | 306 | except KeyError: |
2236 | 311 | continue | 307 | continue |
2237 | 312 | # pylint: disable-msg=W0101 | ||
2238 | 313 | # we dont error, so * that cover invalid states still work | 308 | # we dont error, so * that cover invalid states still work |
2239 | 314 | # XXX: lucio.torre: | 309 | # XXX: lucio.torre: |
2240 | 315 | # we should check that if the transition | 310 | # we should check that if the transition |
2241 | 316 | # is not expanded or all the states it covers are | 311 | # is not expanded or all the states it covers are |
2242 | 317 | # invalid, because this is an error | 312 | # invalid, because this is an error |
2243 | 318 | self.errors.append( | 313 | self.errors.append( |
2249 | 319 | ValidationError("Transitiont on %s with %s from '%s'" | 314 | ValidationError( |
2250 | 320 | "cant find source state." % ( | 315 | "Transitiont on %s with %s from '%s'cant find " |
2251 | 321 | transition.event, | 316 | "source state." % (transition.event, |
2252 | 322 | transition.parameters, | 317 | transition.parameters, |
2253 | 323 | transition.source))) | 318 | transition.source))) |
2254 | 324 | continue | 319 | continue |
2255 | 325 | s = {} | 320 | s = {} |
2256 | 326 | s.update(transition.source) | 321 | s.update(transition.source) |
2257 | @@ -328,18 +323,18 @@ | |||
2258 | 328 | try: | 323 | try: |
2259 | 329 | tracker.remove(s) | 324 | tracker.remove(s) |
2260 | 330 | except ValueError: | 325 | except ValueError: |
2265 | 331 | self.errors.append(ValidationError( | 326 | self.errors.append( |
2266 | 332 | "For event %s, the following transition was " | 327 | ValidationError( |
2267 | 333 | "already covered: %s" % ( | 328 | "For event %s, the following transition was " |
2268 | 334 | event, transition))) | 329 | "already covered: %s" % (event, transition))) |
2269 | 335 | else: | 330 | else: |
2270 | 336 | state.add_transition(transition) | 331 | state.add_transition(transition) |
2271 | 337 | if tracker.empty(): | 332 | if tracker.empty(): |
2272 | 338 | for s in tracker.pending: | 333 | for s in tracker.pending: |
2277 | 339 | self.errors.append(ValidationError( | 334 | self.errors.append( |
2278 | 340 | "The following state x parameters where " | 335 | ValidationError( |
2279 | 341 | "not covered for '%s': %s" % ( | 336 | "The following state x parameters where not " |
2280 | 342 | event, s))) | 337 | "covered for '%s': %s" % (event, s))) |
2281 | 343 | 338 | ||
2282 | 344 | def get_state(self, vars_dict): | 339 | def get_state(self, vars_dict): |
2283 | 345 | """Get a state instance from a dict with {varname:value}""" | 340 | """Get a state instance from a dict with {varname:value}""" |
2284 | @@ -394,7 +389,7 @@ | |||
2285 | 394 | if k in invalid: | 389 | if k in invalid: |
2286 | 395 | invalid.remove(k) | 390 | invalid.remove(k) |
2287 | 396 | 391 | ||
2289 | 397 | #remove invalids from lines | 392 | # remove invalids from lines |
2290 | 398 | for line in lines: | 393 | for line in lines: |
2291 | 399 | for inv in invalid: | 394 | for inv in invalid: |
2292 | 400 | if inv in line["PARAMETERS"]: | 395 | if inv in line["PARAMETERS"]: |
2293 | @@ -418,7 +413,7 @@ | |||
2294 | 418 | if sxp[k] != v: | 413 | if sxp[k] != v: |
2295 | 419 | break | 414 | break |
2296 | 420 | else: | 415 | else: |
2298 | 421 | if not sxp in toremove: | 416 | if sxp not in toremove: |
2299 | 422 | toremove.append(sxp) | 417 | toremove.append(sxp) |
2300 | 423 | 418 | ||
2301 | 424 | map(self.state_x_params.remove, toremove) | 419 | map(self.state_x_params.remove, toremove) |
2302 | @@ -506,7 +501,7 @@ | |||
2303 | 506 | def __str__(self): | 501 | def __str__(self): |
2304 | 507 | """___str___""" | 502 | """___str___""" |
2305 | 508 | return "<Transition: %s: %s x %s>" % ( | 503 | return "<Transition: %s: %s x %s>" % ( |
2307 | 509 | self.event, self.source, self.parameters) | 504 | self.event, self.source, self.parameters) |
2308 | 510 | 505 | ||
2309 | 511 | 506 | ||
2310 | 512 | class State(object): | 507 | class State(object): |
2311 | 513 | 508 | ||
2312 | === modified file 'ubuntuone/syncdaemon/fsm/fsm_parser.py' | |||
2313 | --- ubuntuone/syncdaemon/fsm/fsm_parser.py 2013-02-20 22:47:25 +0000 | |||
2314 | +++ ubuntuone/syncdaemon/fsm/fsm_parser.py 2015-09-19 23:19:46 +0000 | |||
2315 | @@ -78,7 +78,6 @@ | |||
2316 | 78 | if "HAS_OOFFICE" in os.environ: | 78 | if "HAS_OOFFICE" in os.environ: |
2317 | 79 | # we have to do this because python-uno breaks mocker | 79 | # we have to do this because python-uno breaks mocker |
2318 | 80 | import uno | 80 | import uno |
2319 | 81 | # pylint: disable-msg=F0401 | ||
2320 | 82 | from com.sun.star.connection import NoConnectException | 81 | from com.sun.star.connection import NoConnectException |
2321 | 83 | from com.sun.star.lang import IndexOutOfBoundsException | 82 | from com.sun.star.lang import IndexOutOfBoundsException |
2322 | 84 | from com.sun.star.container import NoSuchElementException | 83 | from com.sun.star.container import NoSuchElementException |
2323 | @@ -100,7 +99,7 @@ | |||
2324 | 100 | """Create a reader""" | 99 | """Create a reader""" |
2325 | 101 | local = uno.getComponentContext() | 100 | local = uno.getComponentContext() |
2326 | 102 | resolver = local.ServiceManager.createInstanceWithContext( | 101 | resolver = local.ServiceManager.createInstanceWithContext( |
2328 | 103 | "com.sun.star.bridge.UnoUrlResolver", local) | 102 | "com.sun.star.bridge.UnoUrlResolver", local) |
2329 | 104 | 103 | ||
2330 | 105 | try: | 104 | try: |
2331 | 106 | context = resolver.resolve( | 105 | context = resolver.resolve( |
2332 | @@ -110,11 +109,11 @@ | |||
2333 | 110 | raise Exception(CONNECT_MSG) | 109 | raise Exception(CONNECT_MSG) |
2334 | 111 | 110 | ||
2335 | 112 | desktop = context.ServiceManager.createInstanceWithContext( | 111 | desktop = context.ServiceManager.createInstanceWithContext( |
2337 | 113 | "com.sun.star.frame.Desktop", context) | 112 | "com.sun.star.frame.Desktop", context) |
2338 | 114 | 113 | ||
2339 | 115 | cwd = systemPathToFileUrl(os.getcwd()) | 114 | cwd = systemPathToFileUrl(os.getcwd()) |
2342 | 116 | file_url = absolutize(cwd, systemPathToFileUrl( | 115 | file_url = absolutize( |
2343 | 117 | os.path.join(os.getcwd(), filename))) | 116 | cwd, systemPathToFileUrl(os.path.join(os.getcwd(), filename))) |
2344 | 118 | in_props = PropertyValue("Hidden", 0, True, 0), | 117 | in_props = PropertyValue("Hidden", 0, True, 0), |
2345 | 119 | document = desktop.loadComponentFromURL( | 118 | document = desktop.loadComponentFromURL( |
2346 | 120 | file_url, "_blank", 0, in_props) | 119 | file_url, "_blank", 0, in_props) |
2347 | @@ -184,7 +183,7 @@ | |||
2348 | 184 | while True: | 183 | while True: |
2349 | 185 | cells = [ | 184 | cells = [ |
2350 | 186 | self.invalid.getCellByPosition(x, iter_line).getFormula() | 185 | self.invalid.getCellByPosition(x, iter_line).getFormula() |
2352 | 187 | for x in xrange(line_length)] | 186 | for x in xrange(line_length)] |
2353 | 188 | if not any(cells): | 187 | if not any(cells): |
2354 | 189 | break | 188 | break |
2355 | 190 | 189 | ||
2356 | @@ -283,12 +282,12 @@ | |||
2357 | 283 | afunc = row[action_func_idx] | 282 | afunc = row[action_func_idx] |
2358 | 284 | p += 1 | 283 | p += 1 |
2359 | 285 | states.append(dict(STATE=st, STATE_OUT=st_out, PARAMETERS=vars, | 284 | states.append(dict(STATE=st, STATE_OUT=st_out, PARAMETERS=vars, |
2361 | 286 | ACTION=act, COMMENTS=comm, ACTION_FUNC=afunc)) | 285 | ACTION=act, COMMENTS=comm, ACTION_FUNC=afunc)) |
2362 | 287 | events[event_name] = states | 286 | events[event_name] = states |
2363 | 288 | 287 | ||
2364 | 289 | # build invalid state list | 288 | # build invalid state list |
2365 | 290 | invalid = ods.get_invalid() | 289 | invalid = ods.get_invalid() |
2367 | 291 | invalid = [dict(zip(invalid[0], row)) for row in invalid[1:]] | 290 | invalid = [dict(zip(invalid[0], r)) for r in invalid[1:]] |
2368 | 292 | 291 | ||
2369 | 293 | return dict(events=events, state_vars=state_vars, | 292 | return dict(events=events, state_vars=state_vars, |
2370 | 294 | parameters=parameters, invalid=invalid) | 293 | parameters=parameters, invalid=invalid) |
2371 | @@ -311,9 +310,7 @@ | |||
2372 | 311 | if options.output: | 310 | if options.output: |
2373 | 312 | f = open(options.output, "w") | 311 | f = open(options.output, "w") |
2374 | 313 | data = pprint.pformat(result) | 312 | data = pprint.pformat(result) |
2378 | 314 | f.write("\"\"\"This is a generated python file\"\"\"\n" | 313 | f.write("\"\"\"This is a generated python file.\"\"\"\n" |
2376 | 315 | "# make pylint accept this\n" | ||
2377 | 316 | "# pylint: disable-msg=C0301\n" | ||
2379 | 317 | "state_machine = %s""" % data) | 314 | "state_machine = %s""" % data) |
2380 | 318 | f.close() | 315 | f.close() |
2381 | 319 | else: | 316 | else: |
2382 | 320 | 317 | ||
2383 | === modified file 'ubuntuone/syncdaemon/hash_queue.py' | |||
2384 | --- ubuntuone/syncdaemon/hash_queue.py 2012-04-09 20:07:05 +0000 | |||
2385 | +++ ubuntuone/syncdaemon/hash_queue.py 2015-09-19 23:19:46 +0000 | |||
2386 | @@ -130,8 +130,9 @@ | |||
2387 | 130 | except (IOError, OSError), e: | 130 | except (IOError, OSError), e: |
2388 | 131 | m = "Hasher: hash error %s (path %r mdid %s)" | 131 | m = "Hasher: hash error %s (path %r mdid %s)" |
2389 | 132 | self.logger.debug(m, e, path, mdid) | 132 | self.logger.debug(m, e, path, mdid) |
2392 | 133 | reactor.callLater(.1, reactor.callFromThread, self.eq.push, | 133 | reactor.callLater( |
2393 | 134 | "HQ_HASH_ERROR", mdid=mdid) | 134 | .1, reactor.callFromThread, self.eq.push, |
2394 | 135 | "HQ_HASH_ERROR", mdid=mdid) | ||
2395 | 135 | except StopHashing, e: | 136 | except StopHashing, e: |
2396 | 136 | self.logger.debug(str(e)) | 137 | self.logger.debug(str(e)) |
2397 | 137 | else: | 138 | else: |
2398 | 138 | 139 | ||
2399 | === modified file 'ubuntuone/syncdaemon/interfaces.py' | |||
2400 | --- ubuntuone/syncdaemon/interfaces.py 2012-04-09 20:08:42 +0000 | |||
2401 | +++ ubuntuone/syncdaemon/interfaces.py 2015-09-19 23:19:46 +0000 | |||
2402 | @@ -30,8 +30,6 @@ | |||
2403 | 30 | 30 | ||
2404 | 31 | from zope.interface import Interface, Attribute | 31 | from zope.interface import Interface, Attribute |
2405 | 32 | 32 | ||
2406 | 33 | # pylint: disable-msg=W0232,E0213,E0211 | ||
2407 | 34 | |||
2408 | 35 | 33 | ||
2409 | 36 | class IContentQueue(Interface): | 34 | class IContentQueue(Interface): |
2410 | 37 | """ | 35 | """ |
2411 | 38 | 36 | ||
2412 | === modified file 'ubuntuone/syncdaemon/local_rescan.py' | |||
2413 | --- ubuntuone/syncdaemon/local_rescan.py 2012-08-31 17:15:53 +0000 | |||
2414 | +++ ubuntuone/syncdaemon/local_rescan.py 2015-09-19 23:19:46 +0000 | |||
2415 | @@ -112,8 +112,8 @@ | |||
2416 | 112 | for vol in to_scan: | 112 | for vol in to_scan: |
2417 | 113 | # check that the path exists in disk | 113 | # check that the path exists in disk |
2418 | 114 | if not path_exists(vol.path): | 114 | if not path_exists(vol.path): |
2421 | 115 | log_warning('Volume dissapeared: %r - %r', | 115 | log_warning( |
2422 | 116 | vol.volume_id, vol.path) | 116 | 'Volume dissapeared: %r - %r', vol.volume_id, vol.path) |
2423 | 117 | if isinstance(vol, volume_manager.Share): | 117 | if isinstance(vol, volume_manager.Share): |
2424 | 118 | log_debug('Removing %r metadata', vol.volume_id) | 118 | log_debug('Removing %r metadata', vol.volume_id) |
2425 | 119 | self.vm.share_deleted(vol.volume_id) | 119 | self.vm.share_deleted(vol.volume_id) |
2426 | @@ -149,7 +149,7 @@ | |||
2427 | 149 | """ | 149 | """ |
2428 | 150 | try: | 150 | try: |
2429 | 151 | partials = listdir(self.fsm.partials_dir) | 151 | partials = listdir(self.fsm.partials_dir) |
2431 | 152 | except OSError, e: | 152 | except OSError as e: |
2432 | 153 | if e.errno != errno.ENOENT: | 153 | if e.errno != errno.ENOENT: |
2433 | 154 | raise | 154 | raise |
2434 | 155 | # no partials dir at all | 155 | # no partials dir at all |
2435 | @@ -164,8 +164,8 @@ | |||
2436 | 164 | """Process the FSM limbos and send corresponding AQ orders.""" | 164 | """Process the FSM limbos and send corresponding AQ orders.""" |
2437 | 165 | log_info("processing trash") | 165 | log_info("processing trash") |
2438 | 166 | trash_log = "share_id=%r parent_id=%r node_id=%r path=%r" | 166 | trash_log = "share_id=%r parent_id=%r node_id=%r path=%r" |
2441 | 167 | for share_id, node_id, parent_id, path, is_dir in \ | 167 | for item in self.fsm.get_iter_trash(): |
2442 | 168 | self.fsm.get_iter_trash(): | 168 | share_id, node_id, parent_id, path, is_dir = item |
2443 | 169 | datalog = trash_log % (share_id, parent_id, node_id, path) | 169 | datalog = trash_log % (share_id, parent_id, node_id, path) |
2444 | 170 | if IMarker.providedBy(node_id) or IMarker.providedBy(parent_id): | 170 | if IMarker.providedBy(node_id) or IMarker.providedBy(parent_id): |
2445 | 171 | # situation where the node is not in the server | 171 | # situation where the node is not in the server |
2446 | @@ -181,7 +181,7 @@ | |||
2447 | 181 | for data in self.fsm.get_iter_move_limbo(): | 181 | for data in self.fsm.get_iter_move_limbo(): |
2448 | 182 | to_log = move_log % data | 182 | to_log = move_log % data |
2449 | 183 | (share_id, node_id, old_parent_id, new_parent_id, new_name, | 183 | (share_id, node_id, old_parent_id, new_parent_id, new_name, |
2451 | 184 | path_from, path_to) = data | 184 | path_from, path_to) = data |
2452 | 185 | maybe_markers = (share_id, node_id, old_parent_id, new_parent_id) | 185 | maybe_markers = (share_id, node_id, old_parent_id, new_parent_id) |
2453 | 186 | if any(IMarker.providedBy(x) for x in maybe_markers): | 186 | if any(IMarker.providedBy(x) for x in maybe_markers): |
2454 | 187 | # situation where the move was not ready | 187 | # situation where the move was not ready |
2455 | @@ -190,7 +190,7 @@ | |||
2456 | 190 | continue | 190 | continue |
2457 | 191 | log_info("generating Move from limbo: " + to_log) | 191 | log_info("generating Move from limbo: " + to_log) |
2458 | 192 | self.aq.move(share_id, node_id, old_parent_id, | 192 | self.aq.move(share_id, node_id, old_parent_id, |
2460 | 193 | new_parent_id, new_name, path_from, path_to) | 193 | new_parent_id, new_name, path_from, path_to) |
2461 | 194 | 194 | ||
2462 | 195 | def _process_ro_shares(self): | 195 | def _process_ro_shares(self): |
2463 | 196 | """Process ro shares and reschedule interrupted downloads.""" | 196 | """Process ro shares and reschedule interrupted downloads.""" |
2464 | @@ -205,8 +205,8 @@ | |||
2465 | 205 | if mdobj.is_dir: | 205 | if mdobj.is_dir: |
2466 | 206 | # old state, no sense now with generations | 206 | # old state, no sense now with generations |
2467 | 207 | # but required for the migration path. | 207 | # but required for the migration path. |
2470 | 208 | log_warning("Found a directory in SERVER: %r", | 208 | log_warning( |
2471 | 209 | fullname) | 209 | "Found a directory in SERVER: %r", fullname) |
2472 | 210 | mdobj = self.fsm.get_by_path(fullname) | 210 | mdobj = self.fsm.get_by_path(fullname) |
2473 | 211 | self.fsm.set_by_mdid(mdobj.mdid, | 211 | self.fsm.set_by_mdid(mdobj.mdid, |
2474 | 212 | server_hash=mdobj.local_hash) | 212 | server_hash=mdobj.local_hash) |
2475 | @@ -262,7 +262,6 @@ | |||
2476 | 262 | log_error(m) | 262 | log_error(m) |
2477 | 263 | raise ValueError(m) | 263 | raise ValueError(m) |
2478 | 264 | 264 | ||
2479 | 265 | # No, 'share' is surely defined; pylint: disable-msg=W0631 | ||
2480 | 266 | self._queue.appendleft((share, direct, mdid, udfmode)) | 265 | self._queue.appendleft((share, direct, mdid, udfmode)) |
2481 | 267 | return self._queue_scan() | 266 | return self._queue_scan() |
2482 | 268 | 267 | ||
2483 | @@ -307,8 +306,7 @@ | |||
2484 | 307 | return | 306 | return |
2485 | 308 | 307 | ||
2486 | 309 | self._scan_tree(*scan_info) | 308 | self._scan_tree(*scan_info) |
2489 | 310 | # pylint: disable-msg=W0703 | 309 | except Exception as e: |
2488 | 311 | except Exception, e: | ||
2490 | 312 | self._previous_deferred.errback(e) | 310 | self._previous_deferred.errback(e) |
2491 | 313 | 311 | ||
2492 | 314 | reactor.callLater(0, safe_scan) | 312 | reactor.callLater(0, safe_scan) |
2493 | @@ -337,7 +335,7 @@ | |||
2494 | 337 | if failure.check(ScanTransactionDirty): | 335 | if failure.check(ScanTransactionDirty): |
2495 | 338 | reason = failure.getErrorMessage() | 336 | reason = failure.getErrorMessage() |
2496 | 339 | log_debug("re queue, transaction dirty for %r, reason: %s", | 337 | log_debug("re queue, transaction dirty for %r, reason: %s", |
2498 | 340 | path, reason) | 338 | path, reason) |
2499 | 341 | self._queue.appendleft((share, path, mdid, udfmode)) | 339 | self._queue.appendleft((share, path, mdid, udfmode)) |
2500 | 342 | elif failure.check(OSError, IOError): | 340 | elif failure.check(OSError, IOError): |
2501 | 343 | reason = failure.getErrorMessage() | 341 | reason = failure.getErrorMessage() |
2502 | @@ -410,7 +408,6 @@ | |||
2503 | 410 | # if asked, remove metadata por children | 408 | # if asked, remove metadata por children |
2504 | 411 | if also_children: | 409 | if also_children: |
2505 | 412 | log_debug("Removing metadata for %r children", fullname) | 410 | log_debug("Removing metadata for %r children", fullname) |
2506 | 413 | # pylint: disable-msg=W0612 | ||
2507 | 414 | children = self.fsm.get_paths_starting_with(fullname, False) | 411 | children = self.fsm.get_paths_starting_with(fullname, False) |
2508 | 415 | for path, is_dir in children: | 412 | for path, is_dir in children: |
2509 | 416 | self.fsm.delete_metadata(path) | 413 | self.fsm.delete_metadata(path) |
2510 | @@ -426,7 +423,7 @@ | |||
2511 | 426 | try: | 423 | try: |
2512 | 427 | log_info("Also remove %r", also_remove) | 424 | log_info("Also remove %r", also_remove) |
2513 | 428 | remove_file(also_remove) | 425 | remove_file(also_remove) |
2515 | 429 | except OSError, e: | 426 | except OSError as e: |
2516 | 430 | if e.errno != errno.ENOENT: | 427 | if e.errno != errno.ENOENT: |
2517 | 431 | raise | 428 | raise |
2518 | 432 | 429 | ||
2519 | @@ -555,8 +552,8 @@ | |||
2520 | 555 | to_inform = [] | 552 | to_inform = [] |
2521 | 556 | 553 | ||
2522 | 557 | # get all the info inside that dir | 554 | # get all the info inside that dir |
2525 | 558 | objs = self.fsm.get_mdobjs_by_share_id(share.volume_id, | 555 | objs = self.fsm.get_mdobjs_by_share_id( |
2526 | 559 | fullname) | 556 | share.volume_id, fullname) |
2527 | 560 | for obj in objs: | 557 | for obj in objs: |
2528 | 561 | shrpath = obj.path | 558 | shrpath = obj.path |
2529 | 562 | qparts = len(shrpath.split(os.path.sep)) | 559 | qparts = len(shrpath.split(os.path.sep)) |
2530 | 563 | 560 | ||
2531 | === modified file 'ubuntuone/syncdaemon/logger.py' | |||
2532 | --- ubuntuone/syncdaemon/logger.py 2012-08-28 14:34:26 +0000 | |||
2533 | +++ ubuntuone/syncdaemon/logger.py 2015-09-19 23:19:46 +0000 | |||
2534 | @@ -52,7 +52,6 @@ | |||
2535 | 52 | TRACE = logger.TRACE | 52 | TRACE = logger.TRACE |
2536 | 53 | 53 | ||
2537 | 54 | 54 | ||
2538 | 55 | # pylint: disable=C0103 | ||
2539 | 56 | class mklog(object): | 55 | class mklog(object): |
2540 | 57 | """ | 56 | """ |
2541 | 58 | Create a logger that keeps track of the method where it's being | 57 | Create a logger that keeps track of the method where it's being |
2542 | @@ -67,7 +66,8 @@ | |||
2543 | 67 | all_args = [] | 66 | all_args = [] |
2544 | 68 | for arg in args: | 67 | for arg in args: |
2545 | 69 | all_args.append( | 68 | all_args.append( |
2547 | 70 | repr(arg).decode('ascii', 'replace').encode('ascii', 'replace')) | 69 | repr(arg).decode('ascii', 'replace').encode('ascii', 'replace') |
2548 | 70 | ) | ||
2549 | 71 | for k, v in kwargs.items(): | 71 | for k, v in kwargs.items(): |
2550 | 72 | v = repr(v).decode('ascii', 'replace').encode('ascii', 'replace') | 72 | v = repr(v).decode('ascii', 'replace').encode('ascii', 'replace') |
2551 | 73 | all_args.append("%s=%r" % (k, v)) | 73 | all_args.append("%s=%r" % (k, v)) |
2552 | @@ -137,13 +137,12 @@ | |||
2553 | 137 | return failure | 137 | return failure |
2554 | 138 | return callback, errback | 138 | return callback, errback |
2555 | 139 | 139 | ||
2556 | 140 | # pylint: enable=C0103 | ||
2557 | 141 | LOGFILENAME = os.path.join(ubuntuone_log_dir, 'syncdaemon.log') | 140 | LOGFILENAME = os.path.join(ubuntuone_log_dir, 'syncdaemon.log') |
2558 | 142 | EXLOGFILENAME = os.path.join(ubuntuone_log_dir, 'syncdaemon-exceptions.log') | 141 | EXLOGFILENAME = os.path.join(ubuntuone_log_dir, 'syncdaemon-exceptions.log') |
2563 | 143 | INVALIDLOGFILENAME = os.path.join(ubuntuone_log_dir, | 142 | INVALIDLOGFILENAME = os.path.join( |
2564 | 144 | 'syncdaemon-invalid-names.log') | 143 | ubuntuone_log_dir, 'syncdaemon-invalid-names.log') |
2565 | 145 | BROKENLOGFILENAME = os.path.join(ubuntuone_log_dir, | 144 | BROKENLOGFILENAME = os.path.join( |
2566 | 146 | 'syncdaemon-broken-nodes.log') | 145 | ubuntuone_log_dir, 'syncdaemon-broken-nodes.log') |
2567 | 147 | 146 | ||
2568 | 148 | 147 | ||
2569 | 149 | root_logger = logging.getLogger("ubuntuone.SyncDaemon") | 148 | root_logger = logging.getLogger("ubuntuone.SyncDaemon") |
2570 | @@ -305,7 +304,6 @@ | |||
2571 | 305 | def rotate_logs(): | 304 | def rotate_logs(): |
2572 | 306 | """do a rollover of the three handlers""" | 305 | """do a rollover of the three handlers""" |
2573 | 307 | # ignore the missing file error on a failed rollover | 306 | # ignore the missing file error on a failed rollover |
2574 | 308 | # pylint: disable-msg=W0704 | ||
2575 | 309 | try: | 307 | try: |
2576 | 310 | root_handler.doRollover() | 308 | root_handler.doRollover() |
2577 | 311 | except OSError: | 309 | except OSError: |
2578 | 312 | 310 | ||
2579 | === modified file 'ubuntuone/syncdaemon/offload_queue.py' | |||
2580 | --- ubuntuone/syncdaemon/offload_queue.py 2012-04-09 20:08:42 +0000 | |||
2581 | +++ ubuntuone/syncdaemon/offload_queue.py 2015-09-19 23:19:46 +0000 | |||
2582 | @@ -44,7 +44,7 @@ | |||
2583 | 44 | 44 | ||
2584 | 45 | # limits for file rotation... | 45 | # limits for file rotation... |
2585 | 46 | # after the soft limit, we'll rotate if queue is short enough | 46 | # after the soft limit, we'll rotate if queue is short enough |
2587 | 47 | _rotation_soft_limit = 2 * 1024 ** 3 | 47 | _rotation_soft_limit = 2 * 1024 ** 3 |
2588 | 48 | # if the queue is shorter than this, we'll rotate after the soft limit | 48 | # if the queue is shorter than this, we'll rotate after the soft limit |
2589 | 49 | _rotation_too_big_size = 50 * 1024 ** 2 | 49 | _rotation_too_big_size = 50 * 1024 ** 2 |
2590 | 50 | # rotate if file gets larger than this, no matter the queue size | 50 | # rotate if file gets larger than this, no matter the queue size |
2591 | @@ -69,7 +69,7 @@ | |||
2592 | 69 | # fallback to memory if something goes wrong when using disk | 69 | # fallback to memory if something goes wrong when using disk |
2593 | 70 | self._in_memory = False | 70 | self._in_memory = False |
2594 | 71 | 71 | ||
2596 | 72 | def __len__(self): | 72 | def __len__(self): |
2597 | 73 | return self._len | 73 | return self._len |
2598 | 74 | 74 | ||
2599 | 75 | def push(self, item): | 75 | def push(self, item): |
2600 | @@ -91,7 +91,7 @@ | |||
2601 | 91 | self._tempfile_size += len(data) + STRUCT_SIZE | 91 | self._tempfile_size += len(data) + STRUCT_SIZE |
2602 | 92 | self._rotate() | 92 | self._rotate() |
2603 | 93 | 93 | ||
2605 | 94 | def _handle_bad_write(self, data): | 94 | def _handle_bad_write(self, data): |
2606 | 95 | """Support a bad write, go to memory and continue.""" | 95 | """Support a bad write, go to memory and continue.""" |
2607 | 96 | self.log.exception("Crashed while writing") | 96 | self.log.exception("Crashed while writing") |
2608 | 97 | 97 | ||
2609 | @@ -135,7 +135,7 @@ | |||
2610 | 135 | # the file is big, let's check if we would need to copy too much data | 135 | # the file is big, let's check if we would need to copy too much data |
2611 | 136 | if queuesize > self._rotation_too_big_size: | 136 | if queuesize > self._rotation_too_big_size: |
2612 | 137 | # avoid rotation only if file size is still below the hard limit | 137 | # avoid rotation only if file size is still below the hard limit |
2614 | 138 | if filesize < self._rotation_hard_limit: | 138 | if filesize < self._rotation_hard_limit: |
2615 | 139 | return | 139 | return |
2616 | 140 | 140 | ||
2617 | 141 | # rotate to a new file | 141 | # rotate to a new file |
2618 | 142 | 142 | ||
2619 | === modified file 'ubuntuone/syncdaemon/states.py' | |||
2620 | --- ubuntuone/syncdaemon/states.py 2012-04-09 20:07:05 +0000 | |||
2621 | +++ ubuntuone/syncdaemon/states.py 2015-09-19 23:19:46 +0000 | |||
2622 | @@ -143,7 +143,7 @@ | |||
2623 | 143 | self.log.debug("Setting up the 'waiting' timer on %d secs", | 143 | self.log.debug("Setting up the 'waiting' timer on %d secs", |
2624 | 144 | self.waiting_timeout) | 144 | self.waiting_timeout) |
2625 | 145 | self._waiting_timer = reactor.callLater(self.waiting_timeout, | 145 | self._waiting_timer = reactor.callLater(self.waiting_timeout, |
2627 | 146 | self._waiting_timeout) | 146 | self._waiting_timeout) |
2628 | 147 | 147 | ||
2629 | 148 | elif new_node in self._handshake_nodes: | 148 | elif new_node in self._handshake_nodes: |
2630 | 149 | self.log.debug("Setting up the 'handshake' timer on %d secs", | 149 | self.log.debug("Setting up the 'handshake' timer on %d secs", |
2631 | @@ -215,8 +215,8 @@ | |||
2632 | 215 | 215 | ||
2633 | 216 | def __repr__(self): | 216 | def __repr__(self): |
2634 | 217 | return "<Node %s (%s) error=%s connected=%s online=%s" % ( | 217 | return "<Node %s (%s) error=%s connected=%s online=%s" % ( |
2637 | 218 | self.name, self.description, self.is_error, | 218 | self.name, self.description, self.is_error, self.is_connected, |
2638 | 219 | self.is_connected, self.is_online) | 219 | self.is_online) |
2639 | 220 | 220 | ||
2640 | 221 | 221 | ||
2641 | 222 | class StateInfo(Node): | 222 | class StateInfo(Node): |
2642 | @@ -227,9 +227,11 @@ | |||
2643 | 227 | self.connection_state = conn.state | 227 | self.connection_state = conn.state |
2644 | 228 | 228 | ||
2645 | 229 | def __repr__(self): | 229 | def __repr__(self): |
2649 | 230 | return "%s (error=%s connected=%s online=%s) Queue: %s "\ | 230 | return ( |
2650 | 231 | "Connection: %s" % (self.name, self.is_error, self.is_connected, | 231 | "%s (error=%s connected=%s online=%s) Queue: %s Connection: " |
2651 | 232 | self.is_online, self.queue_state, self.connection_state) | 232 | "%s" % (self.name, self.is_error, self.is_connected, |
2652 | 233 | self.is_online, self.queue_state, self.connection_state)) | ||
2653 | 234 | |||
2654 | 233 | __str__ = __repr__ | 235 | __str__ = __repr__ |
2655 | 234 | 236 | ||
2656 | 235 | 237 | ||
2657 | @@ -362,23 +364,19 @@ | |||
2658 | 362 | (self.READY, 'SYS_CONNECTION_MADE'): _from_ready, | 364 | (self.READY, 'SYS_CONNECTION_MADE'): _from_ready, |
2659 | 363 | (self.READY, 'SYS_CONNECTION_FAILED'): self.WAITING, | 365 | (self.READY, 'SYS_CONNECTION_FAILED'): self.WAITING, |
2660 | 364 | (self.WAITING, 'SYS_CONNECTION_RETRY'): self.READY, | 366 | (self.WAITING, 'SYS_CONNECTION_RETRY'): self.READY, |
2666 | 365 | 367 | (self.CHECK_VERSION, | |
2667 | 366 | (self.CHECK_VERSION, 'SYS_PROTOCOL_VERSION_OK'): | 368 | 'SYS_PROTOCOL_VERSION_OK'): self.SET_CAPABILITIES, |
2668 | 367 | self.SET_CAPABILITIES, | 369 | (self.CHECK_VERSION, |
2669 | 368 | (self.CHECK_VERSION, 'SYS_PROTOCOL_VERSION_ERROR'): | 370 | 'SYS_PROTOCOL_VERSION_ERROR'): self.BAD_VERSION, |
2665 | 369 | self.BAD_VERSION, | ||
2670 | 370 | (self.CHECK_VERSION, 'SYS_SERVER_ERROR'): self.STANDOFF, | 371 | (self.CHECK_VERSION, 'SYS_SERVER_ERROR'): self.STANDOFF, |
2676 | 371 | 372 | (self.SET_CAPABILITIES, | |
2677 | 372 | (self.SET_CAPABILITIES, 'SYS_SET_CAPABILITIES_OK'): | 373 | 'SYS_SET_CAPABILITIES_OK'): self.AUTHENTICATE, |
2678 | 373 | self.AUTHENTICATE, | 374 | (self.SET_CAPABILITIES, |
2679 | 374 | (self.SET_CAPABILITIES, 'SYS_SET_CAPABILITIES_ERROR'): | 375 | 'SYS_SET_CAPABILITIES_ERROR'): self.CAPABILITIES_MISMATCH, |
2675 | 375 | self.CAPABILITIES_MISMATCH, | ||
2680 | 376 | (self.SET_CAPABILITIES, 'SYS_SERVER_ERROR'): self.STANDOFF, | 376 | (self.SET_CAPABILITIES, 'SYS_SERVER_ERROR'): self.STANDOFF, |
2681 | 377 | |||
2682 | 378 | (self.AUTHENTICATE, 'SYS_AUTH_OK'): self.SERVER_RESCAN, | 377 | (self.AUTHENTICATE, 'SYS_AUTH_OK'): self.SERVER_RESCAN, |
2683 | 379 | (self.AUTHENTICATE, 'SYS_AUTH_ERROR'): self.AUTH_FAILED, | 378 | (self.AUTHENTICATE, 'SYS_AUTH_ERROR'): self.AUTH_FAILED, |
2684 | 380 | (self.AUTHENTICATE, 'SYS_SERVER_ERROR'): self.STANDOFF, | 379 | (self.AUTHENTICATE, 'SYS_SERVER_ERROR'): self.STANDOFF, |
2685 | 381 | |||
2686 | 382 | (self.SERVER_RESCAN, 'SYS_SERVER_RESCAN_DONE'): self.QUEUE_MANAGER, | 380 | (self.SERVER_RESCAN, 'SYS_SERVER_RESCAN_DONE'): self.QUEUE_MANAGER, |
2687 | 383 | (self.SERVER_RESCAN, 'SYS_SERVER_ERROR'): self.STANDOFF, | 381 | (self.SERVER_RESCAN, 'SYS_SERVER_ERROR'): self.STANDOFF, |
2688 | 384 | } | 382 | } |
2689 | @@ -497,8 +495,8 @@ | |||
2690 | 497 | self.eq.push('SYS_STATE_CHANGED', state=info) | 495 | self.eq.push('SYS_STATE_CHANGED', state=info) |
2691 | 498 | 496 | ||
2692 | 499 | def __str__(self): | 497 | def __str__(self): |
2695 | 500 | return "<State: %r (queues %s connection %r)>" % (self.state.name, | 498 | return "<State: %r (queues %s connection %r)>" % ( |
2696 | 501 | self.queues.state.name, self.connection.state) | 499 | self.state.name, self.queues.state.name, self.connection.state) |
2697 | 502 | 500 | ||
2698 | 503 | def shutdown(self): | 501 | def shutdown(self): |
2699 | 504 | """Finish all pending work.""" | 502 | """Finish all pending work.""" |
2700 | 505 | 503 | ||
2701 | === modified file 'ubuntuone/syncdaemon/status_listener.py' | |||
2702 | --- ubuntuone/syncdaemon/status_listener.py 2012-10-24 08:54:12 +0000 | |||
2703 | +++ ubuntuone/syncdaemon/status_listener.py 2015-09-19 23:19:46 +0000 | |||
2704 | @@ -58,7 +58,7 @@ | |||
2705 | 58 | return None | 58 | return None |
2706 | 59 | 59 | ||
2707 | 60 | 60 | ||
2709 | 61 | #TODO: hookup the shutdown of the listener to the cleanup in the aggregator | 61 | # TODO: hookup the shutdown of the listener to the cleanup in the aggregator |
2710 | 62 | class StatusListener(object): | 62 | class StatusListener(object): |
2711 | 63 | """SD listener for EQ events that turns them into status updates.""" | 63 | """SD listener for EQ events that turns them into status updates.""" |
2712 | 64 | 64 | ||
2713 | @@ -94,7 +94,6 @@ | |||
2714 | 94 | show_all_notifications = property(get_show_all_notifications, | 94 | show_all_notifications = property(get_show_all_notifications, |
2715 | 95 | set_show_all_notifications) | 95 | set_show_all_notifications) |
2716 | 96 | 96 | ||
2717 | 97 | # pylint: disable=W0613 | ||
2718 | 98 | def handle_AQ_CHANGE_PUBLIC_ACCESS_OK(self, share_id, node_id, is_public, | 97 | def handle_AQ_CHANGE_PUBLIC_ACCESS_OK(self, share_id, node_id, is_public, |
2719 | 99 | public_url): | 98 | public_url): |
2720 | 100 | """The status of a published resource changed.""" | 99 | """The status of a published resource changed.""" |
2721 | @@ -114,7 +113,6 @@ | |||
2722 | 114 | """Progress has been made on an upload.""" | 113 | """Progress has been made on an upload.""" |
2723 | 115 | self.status_frontend.progress_made( | 114 | self.status_frontend.progress_made( |
2724 | 116 | share_id, node_id, n_bytes_read, deflated_size) | 115 | share_id, node_id, n_bytes_read, deflated_size) |
2725 | 117 | # pylint: enable=W0613 | ||
2726 | 118 | 116 | ||
2727 | 119 | def handle_SYS_QUEUE_ADDED(self, command): | 117 | def handle_SYS_QUEUE_ADDED(self, command): |
2728 | 120 | """A command has been added to the queue.""" | 118 | """A command has been added to the queue.""" |
2729 | 121 | 119 | ||
2730 | === modified file 'ubuntuone/syncdaemon/sync.py' | |||
2731 | --- ubuntuone/syncdaemon/sync.py 2012-10-03 19:35:40 +0000 | |||
2732 | +++ ubuntuone/syncdaemon/sync.py 2015-09-19 23:19:46 +0000 | |||
2733 | @@ -68,15 +68,13 @@ | |||
2734 | 68 | if self.mdid is not None: | 68 | if self.mdid is not None: |
2735 | 69 | return self.mdid | 69 | return self.mdid |
2736 | 70 | if len(self.keys) == 1 and "path" in self.keys: | 70 | if len(self.keys) == 1 and "path" in self.keys: |
2737 | 71 | # pylint: disable-msg=W0212 | ||
2738 | 72 | mdid = self.fs._idx_path[self.keys["path"]] | 71 | mdid = self.fs._idx_path[self.keys["path"]] |
2739 | 73 | elif len(self.keys) == 1 and "mdid" in self.keys: | 72 | elif len(self.keys) == 1 and "mdid" in self.keys: |
2740 | 74 | mdid = self.keys["mdid"] | 73 | mdid = self.keys["mdid"] |
2746 | 75 | elif len(self.keys) == 2 and "node_id" in self.keys \ | 74 | elif (len(self.keys) == 2 and "node_id" in self.keys and |
2747 | 76 | and "share_id" in self.keys: | 75 | "share_id" in self.keys): |
2748 | 77 | # pylint: disable-msg=W0212 | 76 | k = (self.keys["share_id"], self.keys["node_id"]) |
2749 | 78 | mdid = self.fs._idx_node_id[self.keys["share_id"], | 77 | mdid = self.fs._idx_node_id[k] |
2745 | 79 | self.keys["node_id"]] | ||
2750 | 80 | else: | 78 | else: |
2751 | 81 | raise KeyError("Incorrect keys: %s" % self.keys) | 79 | raise KeyError("Incorrect keys: %s" % self.keys) |
2752 | 82 | if mdid is None: | 80 | if mdid is None: |
2753 | @@ -194,7 +192,6 @@ | |||
2754 | 194 | 192 | ||
2755 | 195 | def remove_partial(self): | 193 | def remove_partial(self): |
2756 | 196 | """Remove a partial file.""" | 194 | """Remove a partial file.""" |
2757 | 197 | # pylint: disable-msg=W0704 | ||
2758 | 198 | try: | 195 | try: |
2759 | 199 | self.fs.remove_partial(self["node_id"], self["share_id"]) | 196 | self.fs.remove_partial(self["node_id"], self["share_id"]) |
2760 | 200 | except ValueError: | 197 | except ValueError: |
2761 | @@ -208,7 +205,6 @@ | |||
2762 | 208 | def safe_get(self, key, default='^_^'): | 205 | def safe_get(self, key, default='^_^'): |
2763 | 209 | """Safe version of self.get, to be used in the FileLogger.""" | 206 | """Safe version of self.get, to be used in the FileLogger.""" |
2764 | 210 | # catch all errors as we are here to help logging | 207 | # catch all errors as we are here to help logging |
2765 | 211 | # pylint: disable-msg=W0703 | ||
2766 | 212 | try: | 208 | try: |
2767 | 213 | return self.get(key) | 209 | return self.get(key) |
2768 | 214 | except Exception: | 210 | except Exception: |
2769 | @@ -256,12 +252,10 @@ | |||
2770 | 256 | "[%(share_id)r::%(node_id)r] '%(path)r' | %(message)s" | 252 | "[%(share_id)r::%(node_id)r] '%(path)r' | %(message)s" |
2771 | 257 | exc_info = sys.exc_info | 253 | exc_info = sys.exc_info |
2772 | 258 | if self.key.has_metadata() == "T": | 254 | if self.key.has_metadata() == "T": |
2774 | 259 | # catch all errors as we are logging, pylint: disable-msg=W0703 | 255 | # catch all errors as we are logging |
2775 | 260 | try: | 256 | try: |
2776 | 261 | # pylint: disable-msg=W0212 | ||
2777 | 262 | base = os.path.split(self.key.fs._get_share( | 257 | base = os.path.split(self.key.fs._get_share( |
2778 | 263 | self.key['share_id']).path)[1] | 258 | self.key['share_id']).path)[1] |
2779 | 264 | # pylint: disable-msg=W0212 | ||
2780 | 265 | path = os.path.join(base, self.key.fs._share_relative_path( | 259 | path = os.path.join(base, self.key.fs._share_relative_path( |
2781 | 266 | self.key['share_id'], self.key['path'])) | 260 | self.key['share_id'], self.key['path'])) |
2782 | 267 | except Exception: | 261 | except Exception: |
2783 | @@ -312,15 +306,14 @@ | |||
2784 | 312 | 306 | ||
2785 | 313 | def on_event(self, *args, **kwargs): | 307 | def on_event(self, *args, **kwargs): |
2786 | 314 | """Override on_event to capture the debug log""" | 308 | """Override on_event to capture the debug log""" |
2791 | 315 | in_state = '%(hasmd)s:%(changed)s:%(isdir)s' % \ | 309 | kw = dict( |
2792 | 316 | dict(hasmd=self.key.has_metadata(), | 310 | hasmd=self.key.has_metadata(), isdir=self.key.is_directory(), |
2793 | 317 | isdir=self.key.is_directory(), | 311 | changed=self.key.changed()) |
2794 | 318 | changed=self.key.changed()) | 312 | in_state = '%(hasmd)s:%(changed)s:%(isdir)s' % kw |
2795 | 319 | is_debug = self.log.logger.isEnabledFor(logging.DEBUG) | 313 | is_debug = self.log.logger.isEnabledFor(logging.DEBUG) |
2796 | 320 | with DebugCapture(self.log.logger): | 314 | with DebugCapture(self.log.logger): |
2797 | 321 | func_name = super(SyncStateMachineRunner, self).on_event(*args, | 315 | func_name = super(SyncStateMachineRunner, self).on_event(*args, |
2798 | 322 | **kwargs) | 316 | **kwargs) |
2799 | 323 | |||
2800 | 324 | if not is_debug: | 317 | if not is_debug: |
2801 | 325 | self.log.info("Called %s (In: %s)" % (func_name, in_state)) | 318 | self.log.info("Called %s (In: %s)" % (func_name, in_state)) |
2802 | 326 | 319 | ||
2803 | @@ -394,7 +387,7 @@ | |||
2804 | 394 | 387 | ||
2805 | 395 | if volume.generation is None or new_generation is None: | 388 | if volume.generation is None or new_generation is None: |
2806 | 396 | self.log.debug("Client not ready for generations! vol gen: %r, " | 389 | self.log.debug("Client not ready for generations! vol gen: %r, " |
2808 | 397 | "new gen: %r", volume.generation, new_generation) | 390 | "new gen: %r", volume.generation, new_generation) |
2809 | 398 | return | 391 | return |
2810 | 399 | 392 | ||
2811 | 400 | if new_generation <= volume.generation: | 393 | if new_generation <= volume.generation: |
2812 | @@ -447,7 +440,7 @@ | |||
2813 | 447 | """This file is in conflict.""" | 440 | """This file is in conflict.""" |
2814 | 448 | self.key.move_to_conflict() | 441 | self.key.move_to_conflict() |
2815 | 449 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], | 442 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], |
2817 | 450 | node_id=self.key['node_id']) | 443 | node_id=self.key['node_id']) |
2818 | 451 | self.get_file(event, params, hash) | 444 | self.get_file(event, params, hash) |
2819 | 452 | 445 | ||
2820 | 453 | def new_file(self, event, params, share_id, node_id, parent_id, name): | 446 | def new_file(self, event, params, share_id, node_id, parent_id, name): |
2821 | @@ -482,7 +475,7 @@ | |||
2822 | 482 | self.key.set(server_hash=hash) | 475 | self.key.set(server_hash=hash) |
2823 | 483 | self.key.sync() | 476 | self.key.sync() |
2824 | 484 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 477 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2826 | 485 | node_id=self.key['node_id']) | 478 | node_id=self.key['node_id']) |
2827 | 486 | self.key.remove_partial() | 479 | self.key.remove_partial() |
2828 | 487 | self.get_file(event, params, hash) | 480 | self.get_file(event, params, hash) |
2829 | 488 | 481 | ||
2830 | @@ -519,7 +512,7 @@ | |||
2831 | 519 | self.key.set(server_hash=hash) | 512 | self.key.set(server_hash=hash) |
2832 | 520 | self.key.sync() | 513 | self.key.sync() |
2833 | 521 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 514 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2835 | 522 | node_id=self.key['node_id']) | 515 | node_id=self.key['node_id']) |
2836 | 523 | self.key.remove_partial() | 516 | self.key.remove_partial() |
2837 | 524 | 517 | ||
2838 | 525 | def commit_file(self, event, params, hash): | 518 | def commit_file(self, event, params, hash): |
2839 | @@ -618,7 +611,8 @@ | |||
2840 | 618 | node_id = self.key['node_id'] | 611 | node_id = self.key['node_id'] |
2841 | 619 | previous_hash = self.key['server_hash'] | 612 | previous_hash = self.key['server_hash'] |
2842 | 620 | upload_id = self.key.get('upload_id') | 613 | upload_id = self.key.get('upload_id') |
2844 | 621 | self.key.set(local_hash=current_hash, stat=stat, crc32=crc32, size=size) | 614 | self.key.set( |
2845 | 615 | local_hash=current_hash, stat=stat, crc32=crc32, size=size) | ||
2846 | 622 | self.key.sync() | 616 | self.key.sync() |
2847 | 623 | 617 | ||
2848 | 624 | self.m.action_q.upload(share_id, node_id, previous_hash, current_hash, | 618 | self.m.action_q.upload(share_id, node_id, previous_hash, current_hash, |
2849 | @@ -627,7 +621,7 @@ | |||
2850 | 627 | def converges_to_server(self, event, params, hash, crc32, size, stat): | 621 | def converges_to_server(self, event, params, hash, crc32, size, stat): |
2851 | 628 | """the local changes now match the server""" | 622 | """the local changes now match the server""" |
2852 | 629 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 623 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2854 | 630 | node_id=self.key['node_id']) | 624 | node_id=self.key['node_id']) |
2855 | 631 | self.key.remove_partial() | 625 | self.key.remove_partial() |
2856 | 632 | self.key.set(local_hash=hash, stat=stat) | 626 | self.key.set(local_hash=hash, stat=stat) |
2857 | 633 | self.key.sync() | 627 | self.key.sync() |
2858 | @@ -635,7 +629,7 @@ | |||
2859 | 635 | def reput_file_from_ok(self, event, param, hash): | 629 | def reput_file_from_ok(self, event, param, hash): |
2860 | 636 | """put the file again, mark upload as ok""" | 630 | """put the file again, mark upload as ok""" |
2861 | 637 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], | 631 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], |
2863 | 638 | node_id=self.key['node_id']) | 632 | node_id=self.key['node_id']) |
2864 | 639 | self.key.set(local_hash=hash) | 633 | self.key.set(local_hash=hash) |
2865 | 640 | self.key.set(server_hash=hash) | 634 | self.key.set(server_hash=hash) |
2866 | 641 | self.key.sync() | 635 | self.key.sync() |
2867 | @@ -644,14 +638,14 @@ | |||
2868 | 644 | def reput_file(self, event, param, current_hash, crc32, size, stat): | 638 | def reput_file(self, event, param, current_hash, crc32, size, stat): |
2869 | 645 | """Put the file again.""" | 639 | """Put the file again.""" |
2870 | 646 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], | 640 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], |
2872 | 647 | node_id=self.key['node_id']) | 641 | node_id=self.key['node_id']) |
2873 | 648 | previous_hash = self.key['server_hash'] | 642 | previous_hash = self.key['server_hash'] |
2874 | 649 | 643 | ||
2875 | 650 | share_id = self.key['share_id'] | 644 | share_id = self.key['share_id'] |
2876 | 651 | node_id = self.key['node_id'] | 645 | node_id = self.key['node_id'] |
2877 | 652 | upload_id = self.key.get('upload_id') | 646 | upload_id = self.key.get('upload_id') |
2878 | 653 | self.key.set(local_hash=current_hash, stat=stat, | 647 | self.key.set(local_hash=current_hash, stat=stat, |
2880 | 654 | crc32=crc32, size=size) | 648 | crc32=crc32, size=size) |
2881 | 655 | self.key.sync() | 649 | self.key.sync() |
2882 | 656 | mdid = self.key.get_mdid() | 650 | mdid = self.key.get_mdid() |
2883 | 657 | self.m.action_q.upload(share_id, node_id, previous_hash, current_hash, | 651 | self.m.action_q.upload(share_id, node_id, previous_hash, current_hash, |
2884 | @@ -660,7 +654,7 @@ | |||
2885 | 660 | def server_file_now_matches(self, event, params, hash): | 654 | def server_file_now_matches(self, event, params, hash): |
2886 | 661 | """We got a server hash that matches local hash""" | 655 | """We got a server hash that matches local hash""" |
2887 | 662 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], | 656 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], |
2889 | 663 | node_id=self.key['node_id']) | 657 | node_id=self.key['node_id']) |
2890 | 664 | self.key.set(server_hash=hash) | 658 | self.key.set(server_hash=hash) |
2891 | 665 | self.key.sync() | 659 | self.key.sync() |
2892 | 666 | 660 | ||
2893 | @@ -671,7 +665,7 @@ | |||
2894 | 671 | def cancel_and_commit(self, event, params, hash): | 665 | def cancel_and_commit(self, event, params, hash): |
2895 | 672 | """Finish an upload.""" | 666 | """Finish an upload.""" |
2896 | 673 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 667 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2898 | 674 | node_id=self.key['node_id']) | 668 | node_id=self.key['node_id']) |
2899 | 675 | self.key.remove_partial() | 669 | self.key.remove_partial() |
2900 | 676 | self.key.upload_finished(hash) | 670 | self.key.upload_finished(hash) |
2901 | 677 | 671 | ||
2902 | @@ -698,7 +692,7 @@ | |||
2903 | 698 | def file_gone_wile_downloading(self, event, params): | 692 | def file_gone_wile_downloading(self, event, params): |
2904 | 699 | """a file we were downloading is gone.""" | 693 | """a file we were downloading is gone.""" |
2905 | 700 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 694 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2907 | 701 | node_id=self.key['node_id']) | 695 | node_id=self.key['node_id']) |
2908 | 702 | self.key.remove_partial() | 696 | self.key.remove_partial() |
2909 | 703 | self.delete_file(event, params) | 697 | self.delete_file(event, params) |
2910 | 704 | 698 | ||
2911 | @@ -762,10 +756,10 @@ | |||
2912 | 762 | self.key.move_file(new_share_id, new_parent_id, new_name) | 756 | self.key.move_file(new_share_id, new_parent_id, new_name) |
2913 | 763 | 757 | ||
2914 | 764 | def server_moved_dirty(self, event, params, share_id, node_id, | 758 | def server_moved_dirty(self, event, params, share_id, node_id, |
2916 | 765 | new_share_id, new_parent_id, new_name): | 759 | new_share_id, new_parent_id, new_name): |
2917 | 766 | """file was moved on the server while downloading it""" | 760 | """file was moved on the server while downloading it""" |
2918 | 767 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 761 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2920 | 768 | node_id=self.key['node_id']) | 762 | node_id=self.key['node_id']) |
2921 | 769 | self.key.remove_partial() | 763 | self.key.remove_partial() |
2922 | 770 | self.key.move_file(new_share_id, new_parent_id, new_name) | 764 | self.key.move_file(new_share_id, new_parent_id, new_name) |
2923 | 771 | self.get_file(event, params, self.key['server_hash']) | 765 | self.get_file(event, params, self.key['server_hash']) |
2924 | @@ -773,7 +767,7 @@ | |||
2925 | 773 | def moved_dirty_local(self, event, params, path_from, path_to): | 767 | def moved_dirty_local(self, event, params, path_from, path_to): |
2926 | 774 | """file was moved while uploading it""" | 768 | """file was moved while uploading it""" |
2927 | 775 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], | 769 | self.m.action_q.cancel_upload(share_id=self.key['share_id'], |
2929 | 776 | node_id=self.key['node_id']) | 770 | node_id=self.key['node_id']) |
2930 | 777 | self.key.set(local_hash=self.key['server_hash']) | 771 | self.key.set(local_hash=self.key['server_hash']) |
2931 | 778 | self.key.sync() | 772 | self.key.sync() |
2932 | 779 | self.client_moved(event, params, path_from, path_to) | 773 | self.client_moved(event, params, path_from, path_to) |
2933 | @@ -783,16 +777,15 @@ | |||
2934 | 783 | self.client_moved(event, params, path_from, path_to) | 777 | self.client_moved(event, params, path_from, path_to) |
2935 | 784 | 778 | ||
2936 | 785 | self.m.action_q.cancel_download(share_id=self.key['share_id'], | 779 | self.m.action_q.cancel_download(share_id=self.key['share_id'], |
2938 | 786 | node_id=self.key['node_id']) | 780 | node_id=self.key['node_id']) |
2939 | 787 | self.key.remove_partial() | 781 | self.key.remove_partial() |
2940 | 788 | self.key.set(server_hash=self.key['local_hash']) | 782 | self.key.set(server_hash=self.key['local_hash']) |
2941 | 789 | self.key.sync() | 783 | self.key.sync() |
2942 | 790 | 784 | ||
2943 | 791 | # pylint: disable-msg=C0103 | ||
2944 | 792 | def DESPAIR(self, event, params, *args, **kwargs): | 785 | def DESPAIR(self, event, params, *args, **kwargs): |
2945 | 793 | """if we got here, we are in trouble""" | 786 | """if we got here, we are in trouble""" |
2946 | 794 | self.log.error("DESPAIR on event=%s params=%s args=%s kwargs=%s", | 787 | self.log.error("DESPAIR on event=%s params=%s args=%s kwargs=%s", |
2948 | 795 | event, params, args, kwargs) | 788 | event, params, args, kwargs) |
2949 | 796 | 789 | ||
2950 | 797 | def save_stat(self, event, params, hash, crc32, size, stat): | 790 | def save_stat(self, event, params, hash, crc32, size, stat): |
2951 | 798 | """Save the stat""" | 791 | """Save the stat""" |
2952 | @@ -820,7 +813,7 @@ | |||
2953 | 820 | # now that the DebugCapture is enabled | 813 | # now that the DebugCapture is enabled |
2954 | 821 | self.logger = logging.getLogger('ubuntuone.SyncDaemon.sync') | 814 | self.logger = logging.getLogger('ubuntuone.SyncDaemon.sync') |
2955 | 822 | self.broken_logger = logging.getLogger( | 815 | self.broken_logger = logging.getLogger( |
2957 | 823 | 'ubuntuone.SyncDaemon.BrokenNodes') | 816 | 'ubuntuone.SyncDaemon.BrokenNodes') |
2958 | 824 | if Sync.fsm is None: | 817 | if Sync.fsm is None: |
2959 | 825 | Sync.fsm = StateMachine(u1fsfsm.state_machine) | 818 | Sync.fsm = StateMachine(u1fsfsm.state_machine) |
2960 | 826 | self.m = main | 819 | self.m = main |
2961 | @@ -1094,7 +1087,7 @@ | |||
2962 | 1094 | ssmr.signal_event_with_error_and_hash("AQ_UPLOAD_ERROR", error, hash) | 1087 | ssmr.signal_event_with_error_and_hash("AQ_UPLOAD_ERROR", error, hash) |
2963 | 1095 | 1088 | ||
2964 | 1096 | def _handle_SV_MOVED(self, share_id, node_id, new_share_id, new_parent_id, | 1089 | def _handle_SV_MOVED(self, share_id, node_id, new_share_id, new_parent_id, |
2966 | 1097 | new_name): | 1090 | new_name): |
2967 | 1098 | """on SV_MOVED""" | 1091 | """on SV_MOVED""" |
2968 | 1099 | key = FSKey(self.m.fs, share_id=share_id, node_id=node_id) | 1092 | key = FSKey(self.m.fs, share_id=share_id, node_id=node_id) |
2969 | 1100 | log = FileLogger(self.logger, key) | 1093 | log = FileLogger(self.logger, key) |
2970 | @@ -1228,7 +1221,7 @@ | |||
2971 | 1228 | # if its a file, we only care about the hash | 1221 | # if its a file, we only care about the hash |
2972 | 1229 | if not is_dir: | 1222 | if not is_dir: |
2973 | 1230 | self._handle_SV_HASH_NEW(dt.share_id, dt.node_id, | 1223 | self._handle_SV_HASH_NEW(dt.share_id, dt.node_id, |
2975 | 1231 | dt.content_hash) | 1224 | dt.content_hash) |
2976 | 1232 | 1225 | ||
2977 | 1233 | # node updated, update generation | 1226 | # node updated, update generation |
2978 | 1234 | self.m.fs.set_by_mdid(node.mdid, generation=dt.generation) | 1227 | self.m.fs.set_by_mdid(node.mdid, generation=dt.generation) |
2979 | @@ -1285,7 +1278,7 @@ | |||
2980 | 1285 | if node_id is None: | 1278 | if node_id is None: |
2981 | 1286 | continue | 1279 | continue |
2982 | 1287 | 1280 | ||
2984 | 1288 | if not node_id in live_nodes: | 1281 | if node_id not in live_nodes: |
2985 | 1289 | self._handle_SV_FILE_DELETED(volume_id, node_id, node.is_dir) | 1282 | self._handle_SV_FILE_DELETED(volume_id, node_id, node.is_dir) |
2986 | 1290 | deletes += 1 | 1283 | deletes += 1 |
2987 | 1291 | 1284 | ||
2988 | 1292 | 1285 | ||
2989 | === modified file 'ubuntuone/syncdaemon/tritcask.py' | |||
2990 | --- ubuntuone/syncdaemon/tritcask.py 2013-02-12 23:21:50 +0000 | |||
2991 | +++ ubuntuone/syncdaemon/tritcask.py 2015-09-19 23:19:46 +0000 | |||
2992 | @@ -100,8 +100,9 @@ | |||
2993 | 100 | """A Exception for Bad header value.""" | 100 | """A Exception for Bad header value.""" |
2994 | 101 | 101 | ||
2995 | 102 | 102 | ||
2998 | 103 | TritcaskEntry = namedtuple('TritcaskEntry', ['crc32', 'tstamp', 'key_sz', | 103 | TritcaskEntry = namedtuple( |
2999 | 104 | 'value_sz', 'row_type', 'key', 'value', 'value_pos']) | 104 | 'TritcaskEntry', ['crc32', 'tstamp', 'key_sz', 'value_sz', 'row_type', |
3000 | 105 | 'key', 'value', 'value_pos']) | ||
3001 | 105 | 106 | ||
3002 | 106 | 107 | ||
3003 | 107 | _HintEntry = namedtuple('_HintEntry', ['tstamp', 'key_sz', 'row_type', | 108 | _HintEntry = namedtuple('_HintEntry', ['tstamp', 'key_sz', 'row_type', |
3004 | @@ -329,7 +330,7 @@ | |||
3005 | 329 | try: | 330 | try: |
3006 | 330 | crc32 = crc32_struct.unpack(crc32_bytes)[0] | 331 | crc32 = crc32_struct.unpack(crc32_bytes)[0] |
3007 | 331 | tstamp, key_sz, value_sz, row_type = header_struct.unpack(header) | 332 | tstamp, key_sz, value_sz, row_type = header_struct.unpack(header) |
3009 | 332 | except struct.error, e: | 333 | except struct.error as e: |
3010 | 333 | raise BadHeader(e) | 334 | raise BadHeader(e) |
3011 | 334 | key = fmmap[current_pos:current_pos + key_sz] | 335 | key = fmmap[current_pos:current_pos + key_sz] |
3012 | 335 | current_pos += key_sz | 336 | current_pos += key_sz |
3013 | @@ -430,8 +431,8 @@ | |||
3014 | 430 | """raise NotImplementedError.""" | 431 | """raise NotImplementedError.""" |
3015 | 431 | raise NotImplementedError | 432 | raise NotImplementedError |
3016 | 432 | 433 | ||
3019 | 433 | _open = close = read = write = make_immutable = make_zombie = \ | 434 | _open = close = read = write = make_immutable = _not_implemented |
3020 | 434 | __getitem__ = iter_entries = _not_implemented | 435 | make_zombie = __getitem__ = iter_entries = _not_implemented |
3021 | 435 | 436 | ||
3022 | 436 | 437 | ||
3023 | 437 | class TempDataFile(DataFile): | 438 | class TempDataFile(DataFile): |
3024 | @@ -449,8 +450,8 @@ | |||
3025 | 449 | new_name = self.filename.replace(self.temp_name, INACTIVE) | 450 | new_name = self.filename.replace(self.temp_name, INACTIVE) |
3026 | 450 | rename(self.filename, new_name) | 451 | rename(self.filename, new_name) |
3027 | 451 | if self.has_hint: | 452 | if self.has_hint: |
3030 | 452 | new_hint_name = self.hint_filename.replace(self.temp_name, | 453 | new_hint_name = self.hint_filename.replace( |
3031 | 453 | INACTIVE) | 454 | self.temp_name, INACTIVE) |
3032 | 454 | rename(self.hint_filename, new_hint_name) | 455 | rename(self.hint_filename, new_hint_name) |
3033 | 455 | return ImmutableDataFile(*os.path.split(new_name)) | 456 | return ImmutableDataFile(*os.path.split(new_name)) |
3034 | 456 | 457 | ||
3035 | @@ -487,8 +488,8 @@ | |||
3036 | 487 | current_pos += hint_header_size | 488 | current_pos += hint_header_size |
3037 | 488 | if header == '': | 489 | if header == '': |
3038 | 489 | raise StopIteration | 490 | raise StopIteration |
3041 | 490 | tstamp, key_sz, row_type, value_sz, value_pos = \ | 491 | result = hint_header_struct.unpack(header) |
3042 | 491 | hint_header_struct.unpack(header) | 492 | tstamp, key_sz, row_type, value_sz, value_pos = result |
3043 | 492 | key = fmap[current_pos:current_pos + key_sz] | 493 | key = fmap[current_pos:current_pos + key_sz] |
3044 | 493 | current_pos += key_sz | 494 | current_pos += key_sz |
3045 | 494 | yield HintEntry(tstamp, key_sz, row_type, | 495 | yield HintEntry(tstamp, key_sz, row_type, |
3046 | @@ -545,11 +546,11 @@ | |||
3047 | 545 | # update those stats too! | 546 | # update those stats too! |
3048 | 546 | old_stats = self._stats[old_entry.file_id] | 547 | old_stats = self._stats[old_entry.file_id] |
3049 | 547 | old_stats['live_entries'] -= 1 | 548 | old_stats['live_entries'] -= 1 |
3055 | 548 | old_stats['live_bytes'] -= len(key[1]) + old_entry.value_sz \ | 549 | old_stats['live_bytes'] -= ( |
3056 | 549 | + header_size + crc32_size | 550 | len(key[1]) + old_entry.value_sz + header_size + crc32_size |
3057 | 550 | 551 | ) | |
3058 | 551 | new_bytes = len(key[1]) + entry.value_sz \ | 552 | new_bytes = ( |
3059 | 552 | + header_size + crc32_size | 553 | len(key[1]) + entry.value_sz + header_size + crc32_size) |
3060 | 553 | # update the live entries in this file_id stats | 554 | # update the live entries in this file_id stats |
3061 | 554 | live_entries = stats.get('live_entries', 0) | 555 | live_entries = stats.get('live_entries', 0) |
3062 | 555 | stats['live_entries'] = live_entries + 1 | 556 | stats['live_entries'] = live_entries + 1 |
3063 | @@ -557,8 +558,8 @@ | |||
3064 | 557 | new_bytes = entry.value_sz - old_entry.value_sz | 558 | new_bytes = entry.value_sz - old_entry.value_sz |
3065 | 558 | except KeyError: | 559 | except KeyError: |
3066 | 559 | # a new entry | 560 | # a new entry |
3069 | 560 | new_bytes = len(key[1]) + entry.value_sz \ | 561 | new_bytes = ( |
3070 | 561 | + header_size + crc32_size | 562 | len(key[1]) + entry.value_sz + header_size + crc32_size) |
3071 | 562 | live_entries = stats.get('live_entries', 0) | 563 | live_entries = stats.get('live_entries', 0) |
3072 | 563 | stats['live_entries'] = live_entries + 1 | 564 | stats['live_entries'] = live_entries + 1 |
3073 | 564 | live_bytes = stats.get('live_bytes', 0) | 565 | live_bytes = stats.get('live_bytes', 0) |
3074 | @@ -571,14 +572,14 @@ | |||
3075 | 571 | # remove it from the keydir and update the stats | 572 | # remove it from the keydir and update the stats |
3076 | 572 | entry = self.pop(key, None) | 573 | entry = self.pop(key, None) |
3077 | 573 | # return if we don't have that key | 574 | # return if we don't have that key |
3079 | 574 | if entry == None: | 575 | if entry is None: |
3080 | 575 | return | 576 | return |
3081 | 576 | try: | 577 | try: |
3082 | 577 | stats = self._stats[entry.file_id] | 578 | stats = self._stats[entry.file_id] |
3085 | 578 | stats['live_bytes'] -= len(key[1]) + entry.value_sz \ | 579 | stats['live_bytes'] -= ( |
3086 | 579 | + header_size + crc32_size | 580 | len(key[1]) + entry.value_sz + header_size + crc32_size) |
3087 | 580 | stats['live_entries'] -= 1 | 581 | stats['live_entries'] -= 1 |
3089 | 581 | except KeyError, e: | 582 | except KeyError as e: |
3090 | 582 | logger.warning('Failed to update stats while removing %s with: %s', | 583 | logger.warning('Failed to update stats while removing %s with: %s', |
3091 | 583 | key, e) | 584 | key, e) |
3092 | 584 | 585 | ||
3093 | @@ -681,8 +682,8 @@ | |||
3094 | 681 | # no info for the live file | 682 | # no info for the live file |
3095 | 682 | return False | 683 | return False |
3096 | 683 | else: | 684 | else: |
3099 | 684 | return (live_file_stats['live_bytes'] / self.live_file.size) \ | 685 | return ((live_file_stats['live_bytes'] / self.live_file.size) < |
3100 | 685 | < self.dead_bytes_threshold | 686 | self.dead_bytes_threshold) |
3101 | 686 | 687 | ||
3102 | 687 | def should_merge(self, immutable_files): | 688 | def should_merge(self, immutable_files): |
3103 | 688 | """Check if the immutable_files should be merged.""" | 689 | """Check if the immutable_files should be merged.""" |
3104 | @@ -749,7 +750,7 @@ | |||
3105 | 749 | # it's an immutable file | 750 | # it's an immutable file |
3106 | 750 | data_file = ImmutableDataFile(self.base_path, filename) | 751 | data_file = ImmutableDataFile(self.base_path, filename) |
3107 | 751 | self._immutable[data_file.file_id] = data_file | 752 | self._immutable[data_file.file_id] = data_file |
3109 | 752 | except IOError, e: | 753 | except IOError as e: |
3110 | 753 | # oops, failed to open the file..discard it | 754 | # oops, failed to open the file..discard it |
3111 | 754 | broken_files += 1 | 755 | broken_files += 1 |
3112 | 755 | orig = os.path.join(self.base_path, filename) | 756 | orig = os.path.join(self.base_path, filename) |
3113 | @@ -835,8 +836,8 @@ | |||
3114 | 835 | self._keydir.remove((entry.row_type, entry.key)) | 836 | self._keydir.remove((entry.row_type, entry.key)) |
3115 | 836 | # add the tombstone entry to the hint | 837 | # add the tombstone entry to the hint |
3116 | 837 | if build_hint: | 838 | if build_hint: |
3119 | 838 | hint_entry = HintEntry.from_tritcask_entry(entry, | 839 | hint_entry = HintEntry.from_tritcask_entry( |
3120 | 839 | dead=True) | 840 | entry, dead=True) |
3121 | 840 | hint_idx[hint_entry.key] = hint_entry | 841 | hint_idx[hint_entry.key] = hint_entry |
3122 | 841 | else: | 842 | else: |
3123 | 842 | kd_entry = KeydirEntry.from_tritcask_entry(data_file.file_id, | 843 | kd_entry = KeydirEntry.from_tritcask_entry(data_file.file_id, |
3124 | @@ -866,8 +867,8 @@ | |||
3125 | 866 | raise ValueError('key must be a str instance.') | 867 | raise ValueError('key must be a str instance.') |
3126 | 867 | if not isinstance(value, str): | 868 | if not isinstance(value, str): |
3127 | 868 | raise ValueError('value must be a str instance.') | 869 | raise ValueError('value must be a str instance.') |
3130 | 869 | tstamp, value_pos, value_sz = self.live_file.write(row_type, | 870 | tstamp, value_pos, value_sz = self.live_file.write( |
3131 | 870 | key, value) | 871 | row_type, key, value) |
3132 | 871 | if value != TOMBSTONE: | 872 | if value != TOMBSTONE: |
3133 | 872 | kd_entry = KeydirEntry(self.live_file.file_id, tstamp, | 873 | kd_entry = KeydirEntry(self.live_file.file_id, tstamp, |
3134 | 873 | value_sz, value_pos) | 874 | value_sz, value_pos) |
3135 | @@ -977,7 +978,6 @@ | |||
3136 | 977 | def __len__(self): | 978 | def __len__(self): |
3137 | 978 | """The len of the shelf.""" | 979 | """The len of the shelf.""" |
3138 | 979 | counter = 0 | 980 | counter = 0 |
3139 | 980 | # pylint: disable-msg=W0612 | ||
3140 | 981 | for key in self.keys(): | 981 | for key in self.keys(): |
3141 | 982 | counter += 1 | 982 | counter += 1 |
3142 | 983 | return counter | 983 | return counter |
3143 | 984 | 984 | ||
3144 | === modified file 'ubuntuone/syncdaemon/u1fsfsm.py' | |||
3145 | --- ubuntuone/syncdaemon/u1fsfsm.py 2011-10-14 20:02:23 +0000 | |||
3146 | +++ ubuntuone/syncdaemon/u1fsfsm.py 2015-09-19 23:19:46 +0000 | |||
3147 | @@ -1,6 +1,6 @@ | |||
3148 | 1 | """This is a generated python file""" | 1 | """This is a generated python file""" |
3151 | 2 | # make pylint accept this | 2 | # make pylflakes accept this |
3152 | 3 | # pylint: disable-msg=C0301 | 3 | # noqa |
3153 | 4 | state_machine = {'events': {u'AQ_DIR_DELETE_ERROR': [{'ACTION': u'md.create(path=path, uuid=uuid, type=type) aq.query(uuid=uuid)', | 4 | state_machine = {'events': {u'AQ_DIR_DELETE_ERROR': [{'ACTION': u'md.create(path=path, uuid=uuid, type=type) aq.query(uuid=uuid)', |
3154 | 5 | 'ACTION_FUNC': u'', | 5 | 'ACTION_FUNC': u'', |
3155 | 6 | 'COMMENTS': u'the user deleted something we couldnt delete from the server. Re create.', | 6 | 'COMMENTS': u'the user deleted something we couldnt delete from the server. Re create.', |
3156 | 7 | 7 | ||
3157 | === modified file 'ubuntuone/syncdaemon/volume_manager.py' | |||
3158 | --- ubuntuone/syncdaemon/volume_manager.py 2015-09-17 02:20:40 +0000 | |||
3159 | +++ ubuntuone/syncdaemon/volume_manager.py 2015-09-19 23:19:46 +0000 | |||
3160 | @@ -314,7 +314,8 @@ | |||
3161 | 314 | def from_volume(cls, volume): | 314 | def from_volume(cls, volume): |
3162 | 315 | """Create a Root instance from a RootVolume.""" | 315 | """Create a Root instance from a RootVolume.""" |
3163 | 316 | # TODO: include the generation and the volume_id(?) | 316 | # TODO: include the generation and the volume_id(?) |
3165 | 317 | return cls(node_id=str(volume.node_id), | 317 | return cls( |
3166 | 318 | node_id=str(volume.node_id), | ||
3167 | 318 | free_bytes=volume.free_bytes, generation=volume.generation) | 319 | free_bytes=volume.free_bytes, generation=volume.generation) |
3168 | 319 | 320 | ||
3169 | 320 | def __repr__(self): | 321 | def __repr__(self): |
3170 | @@ -720,8 +721,9 @@ | |||
3171 | 720 | except KeyError: | 721 | except KeyError: |
3172 | 721 | # we don't have the file/md of this shared node_id yet | 722 | # we don't have the file/md of this shared node_id yet |
3173 | 722 | # for the moment ignore this share | 723 | # for the moment ignore this share |
3176 | 723 | self.log.warning("we got a share with 'from_me' direction," | 724 | self.log.warning( |
3177 | 724 | " but don't have the node_id in the metadata yet") | 725 | "we got a share with 'from_me' direction, " |
3178 | 726 | "but don't have the node_id in the metadata yet") | ||
3179 | 725 | path = None | 727 | path = None |
3180 | 726 | share = Shared.from_response(a_share, path) | 728 | share = Shared.from_response(a_share, path) |
3181 | 727 | shared.append(share.volume_id) | 729 | shared.append(share.volume_id) |
3182 | @@ -757,8 +759,9 @@ | |||
3183 | 757 | def _cleanup_shares(self, to_keep): | 759 | def _cleanup_shares(self, to_keep): |
3184 | 758 | """Cleanup not-yet accepted Shares from the shares shelf.""" | 760 | """Cleanup not-yet accepted Shares from the shares shelf.""" |
3185 | 759 | self.log.debug('deleting dead shares') | 761 | self.log.debug('deleting dead shares') |
3188 | 760 | for share in ifilter(lambda item: item and item not in to_keep and \ | 762 | shares = ( |
3189 | 761 | not self.shares[item].accepted, self.shares): | 763 | lambda i: i and i not in to_keep and not self.shares[i].accepted) |
3190 | 764 | for share in ifilter(shares, self.shares): | ||
3191 | 762 | self.log.debug('deleting shares: id=%s', share) | 765 | self.log.debug('deleting shares: id=%s', share) |
3192 | 763 | self.share_deleted(share) | 766 | self.share_deleted(share) |
3193 | 764 | 767 | ||
3194 | @@ -1022,7 +1025,6 @@ | |||
3195 | 1022 | # XXX: partially implemented, this should be moved into fsm?. | 1025 | # XXX: partially implemented, this should be moved into fsm?. |
3196 | 1023 | # should delete all the files in the share? | 1026 | # should delete all the files in the share? |
3197 | 1024 | # delete all the metadata but dont touch the files/folders | 1027 | # delete all the metadata but dont touch the files/folders |
3198 | 1025 | # pylint: disable-msg=W0612 | ||
3199 | 1026 | for a_path, _ in self.m.fs.get_paths_starting_with(path): | 1028 | for a_path, _ in self.m.fs.get_paths_starting_with(path): |
3200 | 1027 | self.m.fs.delete_metadata(a_path) | 1029 | self.m.fs.delete_metadata(a_path) |
3201 | 1028 | 1030 | ||
3202 | @@ -1061,9 +1063,9 @@ | |||
3203 | 1061 | node_id = mdobj.node_id | 1063 | node_id = mdobj.node_id |
3204 | 1062 | abspath = self.m.fs.get_abspath(mdobj.share_id, mdobj.path) | 1064 | abspath = self.m.fs.get_abspath(mdobj.share_id, mdobj.path) |
3205 | 1063 | share = Shared(path=abspath, volume_id=marker, | 1065 | share = Shared(path=abspath, volume_id=marker, |
3209 | 1064 | name=name, access_level=access_level, | 1066 | name=name, access_level=access_level, |
3210 | 1065 | other_username=username, other_visible_name=None, | 1067 | other_username=username, other_visible_name=None, |
3211 | 1066 | node_id=node_id) | 1068 | node_id=node_id) |
3212 | 1067 | self.marker_share_map[marker] = share | 1069 | self.marker_share_map[marker] = share |
3213 | 1068 | # XXX: unicode boundary! username, name should be unicode | 1070 | # XXX: unicode boundary! username, name should be unicode |
3214 | 1069 | self.m.action_q.create_share(node_id, username, name, | 1071 | self.m.action_q.create_share(node_id, username, name, |
3215 | @@ -1133,8 +1135,9 @@ | |||
3216 | 1133 | # don't scan the udf as we are not subscribed to it | 1135 | # don't scan the udf as we are not subscribed to it |
3217 | 1134 | d = defer.succeed(None) | 1136 | d = defer.succeed(None) |
3218 | 1135 | 1137 | ||
3221 | 1136 | d.addCallback(lambda _: self.m.event_q.push('VM_UDF_CREATED', | 1138 | d.addCallback( |
3222 | 1137 | udf=self.get_volume(udf.volume_id))) | 1139 | lambda _: self.m.event_q.push( |
3223 | 1140 | 'VM_UDF_CREATED', udf=self.get_volume(udf.volume_id))) | ||
3224 | 1138 | return d | 1141 | return d |
3225 | 1139 | 1142 | ||
3226 | 1140 | def udf_deleted(self, udf_id): | 1143 | def udf_deleted(self, udf_id): |
3227 | @@ -1187,8 +1190,8 @@ | |||
3228 | 1187 | 1190 | ||
3229 | 1188 | """ | 1191 | """ |
3230 | 1189 | new_path = path + os.path.sep | 1192 | new_path = path + os.path.sep |
3233 | 1190 | volumes = itertools.chain([self.shares[request.ROOT]], | 1193 | volumes = itertools.chain( |
3234 | 1191 | self.udfs.values()) | 1194 | [self.shares[request.ROOT]], self.udfs.values()) |
3235 | 1192 | for volume in volumes: | 1195 | for volume in volumes: |
3236 | 1193 | vol_path = volume.path + os.path.sep | 1196 | vol_path = volume.path + os.path.sep |
3237 | 1194 | if new_path.startswith(vol_path) or vol_path.startswith(new_path): | 1197 | if new_path.startswith(vol_path) or vol_path.startswith(new_path): |
3238 | @@ -1267,8 +1270,8 @@ | |||
3239 | 1267 | Also fire a local and server rescan. | 1270 | Also fire a local and server rescan. |
3240 | 1268 | 1271 | ||
3241 | 1269 | """ | 1272 | """ |
3244 | 1270 | push_error = functools.partial(self.m.event_q.push, | 1273 | push_error = functools.partial( |
3245 | 1271 | 'VM_SHARE_SUBSCRIBE_ERROR', share_id=share_id) | 1274 | self.m.event_q.push, 'VM_SHARE_SUBSCRIBE_ERROR', share_id=share_id) |
3246 | 1272 | push_success = lambda volume: \ | 1275 | push_success = lambda volume: \ |
3247 | 1273 | self.m.event_q.push('VM_SHARE_SUBSCRIBED', share=volume) | 1276 | self.m.event_q.push('VM_SHARE_SUBSCRIBED', share=volume) |
3248 | 1274 | self.log.info('subscribe_share: %r', share_id) | 1277 | self.log.info('subscribe_share: %r', share_id) |
3249 | @@ -1362,8 +1365,9 @@ | |||
3250 | 1362 | def unsubscribe_share(self, share_id): | 1365 | def unsubscribe_share(self, share_id): |
3251 | 1363 | """Mark the share with share_id as unsubscribed.""" | 1366 | """Mark the share with share_id as unsubscribed.""" |
3252 | 1364 | self.log.info('unsubscribe_share: %r', share_id) | 1367 | self.log.info('unsubscribe_share: %r', share_id) |
3255 | 1365 | push_error = functools.partial(self.m.event_q.push, | 1368 | push_error = functools.partial( |
3256 | 1366 | 'VM_SHARE_UNSUBSCRIBE_ERROR', share_id=share_id) | 1369 | self.m.event_q.push, 'VM_SHARE_UNSUBSCRIBE_ERROR', |
3257 | 1370 | share_id=share_id) | ||
3258 | 1367 | push_success = lambda volume: \ | 1371 | push_success = lambda volume: \ |
3259 | 1368 | self.m.event_q.push('VM_SHARE_UNSUBSCRIBED', share=volume) | 1372 | self.m.event_q.push('VM_SHARE_UNSUBSCRIBED', share=volume) |
3260 | 1369 | self._unsubscribe_volume(share_id, push_success, push_error) | 1373 | self._unsubscribe_volume(share_id, push_success, push_error) |
3261 | @@ -1371,8 +1375,8 @@ | |||
3262 | 1371 | def unsubscribe_udf(self, udf_id): | 1375 | def unsubscribe_udf(self, udf_id): |
3263 | 1372 | """Mark the UDF with udf_id as unsubscribed.""" | 1376 | """Mark the UDF with udf_id as unsubscribed.""" |
3264 | 1373 | self.log.info('unsubscribe_udf: %r', udf_id) | 1377 | self.log.info('unsubscribe_udf: %r', udf_id) |
3267 | 1374 | push_error = functools.partial(self.m.event_q.push, | 1378 | push_error = functools.partial( |
3268 | 1375 | 'VM_UDF_UNSUBSCRIBE_ERROR', udf_id=udf_id) | 1379 | self.m.event_q.push, 'VM_UDF_UNSUBSCRIBE_ERROR', udf_id=udf_id) |
3269 | 1376 | push_success = lambda volume: \ | 1380 | push_success = lambda volume: \ |
3270 | 1377 | self.m.event_q.push('VM_UDF_UNSUBSCRIBED', udf=volume) | 1381 | self.m.event_q.push('VM_UDF_UNSUBSCRIBED', udf=volume) |
3271 | 1378 | self._unsubscribe_volume(udf_id, push_success, push_error) | 1382 | self._unsubscribe_volume(udf_id, push_success, push_error) |
3272 | @@ -1484,8 +1488,8 @@ | |||
3273 | 1484 | """Upgrade the metadata (only if it's needed)""" | 1488 | """Upgrade the metadata (only if it's needed)""" |
3274 | 1485 | # upgrade the metadata | 1489 | # upgrade the metadata |
3275 | 1486 | if self.md_version != VolumeManager.METADATA_VERSION: | 1490 | if self.md_version != VolumeManager.METADATA_VERSION: |
3278 | 1487 | upgrade_method = getattr(self, "_upgrade_metadata_%s" % \ | 1491 | upgrade_method = getattr( |
3279 | 1488 | self.md_version) | 1492 | self, "_upgrade_metadata_%s" % self.md_version) |
3280 | 1489 | upgrade_method(self.md_version) | 1493 | upgrade_method(self.md_version) |
3281 | 1490 | 1494 | ||
3282 | 1491 | def _get_md_version(self): | 1495 | def _get_md_version(self): |
3283 | @@ -1527,12 +1531,12 @@ | |||
3284 | 1527 | and path_exists(self._shared_md_dir): | 1531 | and path_exists(self._shared_md_dir): |
3285 | 1528 | # we have shares and shared dirs | 1532 | # we have shares and shared dirs |
3286 | 1529 | # md_version >= 1 | 1533 | # md_version >= 1 |
3293 | 1530 | old_root_dir = os.path.abspath(os.path.join(self._root_dir, | 1534 | old_root_dir = os.path.abspath( |
3294 | 1531 | 'My Files')) | 1535 | os.path.join(self._root_dir, 'My Files')) |
3295 | 1532 | old_share_dir = os.path.abspath(os.path.join(self._root_dir, | 1536 | old_share_dir = os.path.abspath( |
3296 | 1533 | 'Shared With Me')) | 1537 | os.path.join(self._root_dir, 'Shared With Me')) |
3297 | 1534 | if path_exists(old_share_dir) and path_exists(old_root_dir) \ | 1538 | if (path_exists(old_share_dir) and path_exists(old_root_dir) and |
3298 | 1535 | and not is_link(old_share_dir): | 1539 | not is_link(old_share_dir)): |
3299 | 1536 | # md >= 1 and <= 3 | 1540 | # md >= 1 and <= 3 |
3300 | 1537 | # we have a My Files dir, 'Shared With Me' isn't a | 1541 | # we have a My Files dir, 'Shared With Me' isn't a |
3301 | 1538 | # symlink and ~/.local/share/ubuntuone/shares doesn't | 1542 | # symlink and ~/.local/share/ubuntuone/shares doesn't |
3302 | @@ -1547,9 +1551,8 @@ | |||
3303 | 1547 | target = read_link(self._shares_dir_link) | 1551 | target = read_link(self._shares_dir_link) |
3304 | 1548 | except OSError: | 1552 | except OSError: |
3305 | 1549 | target = None | 1553 | target = None |
3309 | 1550 | if is_link(self._shares_dir_link) \ | 1554 | if (normpath(target) == os.path.abspath(self._shares_dir_link) |
3310 | 1551 | and normpath(target) == os.path.abspath( | 1555 | and is_link(self._shares_dir_link)): |
3308 | 1552 | self._shares_dir_link): | ||
3311 | 1553 | # broken symlink, md_version = 4 | 1556 | # broken symlink, md_version = 4 |
3312 | 1554 | md_version = '4' | 1557 | md_version = '4' |
3313 | 1555 | else: | 1558 | else: |
3314 | @@ -1583,18 +1586,16 @@ | |||
3315 | 1583 | backup = os.path.join(self._data_dir, '0.bkp') | 1586 | backup = os.path.join(self._data_dir, '0.bkp') |
3316 | 1584 | if not path_exists(backup): | 1587 | if not path_exists(backup): |
3317 | 1585 | make_dir(backup, recursive=True) | 1588 | make_dir(backup, recursive=True) |
3318 | 1586 | # pylint: disable-msg=W0612 | ||
3319 | 1587 | # filter 'shares' and 'shared' dirs, in case we are in the case of | 1589 | # filter 'shares' and 'shared' dirs, in case we are in the case of |
3320 | 1588 | # missing version but existing .version file | 1590 | # missing version but existing .version file |
3321 | 1589 | filter_known_dirs = lambda d: d != os.path.basename( | 1591 | filter_known_dirs = lambda d: d != os.path.basename( |
3324 | 1590 | self._shares_md_dir) and \ | 1592 | self._shares_md_dir) and d != os.path.basename(self._shared_md_dir) |
3323 | 1591 | d != os.path.basename(self._shared_md_dir) | ||
3325 | 1592 | for dirname, dirs, files in walk(self._data_dir): | 1593 | for dirname, dirs, files in walk(self._data_dir): |
3326 | 1593 | if dirname == self._data_dir: | 1594 | if dirname == self._data_dir: |
3327 | 1594 | for dir in filter(filter_known_dirs, dirs): | 1595 | for dir in filter(filter_known_dirs, dirs): |
3328 | 1595 | if dir != os.path.basename(backup): | 1596 | if dir != os.path.basename(backup): |
3329 | 1596 | recursive_move(os.path.join(dirname, dir), | 1597 | recursive_move(os.path.join(dirname, dir), |
3331 | 1597 | os.path.join(backup, dir)) | 1598 | os.path.join(backup, dir)) |
3332 | 1598 | # regenerate the shelf using the new layout using the backup as src | 1599 | # regenerate the shelf using the new layout using the backup as src |
3333 | 1599 | old_shelf = LegacyShareFileShelf(backup) | 1600 | old_shelf = LegacyShareFileShelf(backup) |
3334 | 1600 | if not path_exists(self._shares_dir): | 1601 | if not path_exists(self._shares_dir): |
3335 | @@ -1871,8 +1872,9 @@ | |||
3336 | 1871 | """ | 1872 | """ |
3337 | 1872 | 1873 | ||
3338 | 1873 | TYPE = 'type' | 1874 | TYPE = 'type' |
3341 | 1874 | classes = dict((sub.__name__, sub) for sub in \ | 1875 | classes = dict( |
3342 | 1875 | Volume.__subclasses__() + Share.__subclasses__()) | 1876 | (sub.__name__, sub) |
3343 | 1877 | for sub in Volume.__subclasses__() + Share.__subclasses__()) | ||
3344 | 1876 | 1878 | ||
3345 | 1877 | def __init__(self, *args, **kwargs): | 1879 | def __init__(self, *args, **kwargs): |
3346 | 1878 | """Create the instance.""" | 1880 | """Create the instance.""" |
3347 | @@ -1955,8 +1957,9 @@ | |||
3348 | 1955 | """ | 1957 | """ |
3349 | 1956 | 1958 | ||
3350 | 1957 | TYPE = 'type' | 1959 | TYPE = 'type' |
3353 | 1958 | classes = dict((sub.__name__, sub) for sub in \ | 1960 | classes = dict( |
3354 | 1959 | Volume.__subclasses__() + Share.__subclasses__()) | 1961 | (sub.__name__, sub) |
3355 | 1962 | for sub in Volume.__subclasses__() + Share.__subclasses__()) | ||
3356 | 1960 | 1963 | ||
3357 | 1961 | def __init__(self, *args, **kwargs): | 1964 | def __init__(self, *args, **kwargs): |
3358 | 1962 | """Create the instance.""" | 1965 | """Create the instance.""" |
Ran 2773 tests in 189.908s
PASSED (skips=43, successes=2730)