Merge lp:~diegosarmentero/ubuntuone-client/darwin3-fsevents into lp:ubuntuone-client
| Status: | Merged |
|---|---|
| Approved by: | Alejandro J. Cura on 2012-07-03 |
| Approved revision: | 1278 |
| Merged at revision: | 1271 |
| Proposed branch: | lp:~diegosarmentero/ubuntuone-client/darwin3-fsevents |
| Merge into: | lp:ubuntuone-client |
| Prerequisite: | lp:~diegosarmentero/ubuntuone-client/darwin2-fsevents |
| Diff against target: |
1295 lines (+1052/-75) 9 files modified
tests/platform/filesystem_notifications/test_darwin.py (+781/-0) ubuntuone/platform/filesystem_notifications/__init__.py (+0/-1) ubuntuone/platform/filesystem_notifications/common.py (+59/-39) ubuntuone/platform/filesystem_notifications/darwin.py (+133/-0) ubuntuone/platform/filesystem_notifications/windows.py (+38/-34) ubuntuone/platform/os_helper/__init__.py (+6/-0) ubuntuone/platform/os_helper/darwin.py (+27/-0) ubuntuone/platform/os_helper/linux.py (+3/-0) ubuntuone/platform/os_helper/windows.py (+5/-1) |
| To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-client/darwin3-fsevents |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Alejandro J. Cura (community) | Approve on 2012-07-03 | ||
| Manuel de la Peña (community) | 2012-06-22 | Approve on 2012-06-27 | |
|
Review via email:
|
|||
Commit Message
- Adding Watch and WatchManager to darwin (LP: #1013323).
Description of the Change
Now you can execute:
./run-mac-tests tests/platform/
- 1269. By Diego Sarmentero on 2012-06-22
-
tests fixed for darwin
| Diego Sarmentero (diegosarmentero) wrote : | # |
> There seems to be a merge issue:
>
> 838 +<<<<<<< TREE
> 839 + For Windows:
> 840 + Also, they must not be literal paths, that is the \\?\ prefix should
> not be
> 841 + in the path.
> 842 +
> 843 +=======
> 844 +>>>>>>> MERGE-SOURCE
> 845 """
Yes, i realize in the next branch, i miss it here, and i didn't notice because it's inside a string :P
Fixed
| Manuel de la Peña (mandel) wrote : | # |
I noticed that in the tests we have asserts like:
self.assertEqua
self.assertEqua
self.assertEqua
...
Can we use constants that point to those value, there are two reasons for that:
1. if the constant value change we catch the error.
2. Is more readable for the possible maintainer.
I guess there was some inspiration from windows on test_darwin:
478 + # on windows a move to outside a watched dir translates to a remove
and
377 + # while on linux we will have to do some sort of magic like facundo
378 + # did, on windows we will get a deleted event which is much more
379 + # cleaner, first time ever windows is nicer!
Are we doing the exact same tests, can't we merge them?
Does watch take unicode of bytes, the following tests use diff values:
690 + def test_stream_
691 + """Test that the stream is created."""
692 + def fake_call(*args, **kwargs):
693 + """Fake call."""
694 +
695 + path = '/Users/
696 + watch = Watch(1, path, None, True, None)
697 + self.assertEqua
698 + self.assertEqua
699 + self.assertEqua
700 +
701 + def test_watching_
702 + """Test that the stopped property returns the stopped deferred."""
703 + path = u'/Users/
704 + watch = Watch(1, path, None, True, None)
705 + self.assertFals
We should agree on one, either always bytes or always unicode. I'm guessing it should be unicode due to:
1028 + if not isinstance(path, unicode):
1029 + e = NotImplementedE
which brings me to point out that we are doing:
873 + def __init__(self, watch_descriptor, path, mask, auto_add, processor,
874 + buf_size=8192):
875 + super(Watch, self)._
876 + processor, buf_size)
877 + # Create stream with folder to watch
878 + try:
879 + path = self._path.
880 + except (UnicodeDecodeE
881 + path = self._path
882 + self.stream = fsevents.
883 + path, file_events=True)
We certainly need to make it more clear what we want to avoid mixing bytes and unicode. I prefer to have sd fail because we passed the wrong type to be honest.
If I understand correctly we get from the fsevents api:
896 + action, cookie, file_name = (event.mask, event.cookie, event.name)
which probably means that cookie is unique, right? If so we do not need to do:
self._cookie = str(uuid4())
when creating the cookie for the fake IN_MOVED_FROM and IN_MOVED_TO events because we should be able to reuse the cookie passed by fsevents, is the assumption correct?
AFAIK we don't need the [] in:
897 + if any([file_
898 + for path in self._ignore_
899 + return
Looks like a copy paste from the windows one (me to blame) we should fix it in both, what is more, the method has a number of steps that are very similar do we really need to copy the entire func?
The following comment looks outdated and from the windows code:
932 + # add the event only if we ...
| Manuel de la Peña (mandel) wrote : | # |
One more issue due to the copy&paste:
902 + syncdaemon_path = os.path.
903 + full_dir_path = os.path.
Those two are the same on darwin and there is no reason to have both.
- 1270. By Diego Sarmentero on 2012-06-26
-
improving branch
- 1271. By Diego Sarmentero on 2012-06-26
-
merge
| Diego Sarmentero (diegosarmentero) wrote : | # |
> I noticed that in the tests we have asserts like:
>
> self.assertEqua
> self.assertEqua
> self.assertEqua
> ...
>
> Can we use constants that point to those value, there are two reasons for
> that:
>
> 1. if the constant value change we catch the error.
> 2. Is more readable for the possible maintainer.
>
> I guess there was some inspiration from windows on test_darwin:
>
> 478 + # on windows a move to outside a watched dir translates to a remove
>
> and
>
> 377 + # while on linux we will have to do some sort of magic like facundo
> 378 + # did, on windows we will get a deleted event which is much more
> 379 + # cleaner, first time ever windows is nicer!
>
> Are we doing the exact same tests, can't we merge them?
>
> Does watch take unicode of bytes, the following tests use diff values:
>
> 690 + def test_stream_
> 691 + """Test that the stream is created."""
> 692 + def fake_call(*args, **kwargs):
> 693 + """Fake call."""
> 694 +
> 695 + path = '/Users/
> 696 + watch = Watch(1, path, None, True, None)
> 697 + self.assertEqua
> 698 + self.assertEqua
> 699 + self.assertEqua
> 700 +
> 701 + def test_watching_
> 702 + """Test that the stopped property returns the stopped deferred."""
> 703 + path = u'/Users/
> 704 + watch = Watch(1, path, None, True, None)
> 705 + self.assertFals
>
> We should agree on one, either always bytes or always unicode. I'm guessing it
> should be unicode due to:
>
> 1028 + if not isinstance(path, unicode):
> 1029 + e = NotImplementedE
>
> which brings me to point out that we are doing:
>
> 873 + def __init__(self, watch_descriptor, path, mask, auto_add,
> processor,
> 874 + buf_size=8192):
> 875 + super(Watch, self)._
> 876 + processor, buf_size)
> 877 + # Create stream with folder to watch
> 878 + try:
> 879 + path = self._path.
> 880 + except (UnicodeDecodeE
> 881 + path = self._path
> 882 + self.stream = fsevents.
> 883 + path, file_events=True)
>
> We certainly need to make it more clear what we want to avoid mixing bytes and
> unicode. I prefer to have sd fail because we passed the wrong type to be
> honest.
>
> If I understand correctly we get from the fsevents api:
>
> 896 + action, cookie, file_name = (event.mask, event.cookie, event.name)
>
> which probably means that cookie is unique, right? If so we do not need to do:
>
> self._cookie = str(uuid4())
>
> when creating the cookie for the fake IN_MOVED_FROM and IN_MOVED_TO events
> because we should be able to reuse the cookie passed by fsevents, is the
> assumption correct?
>
> AFAIK we don't need the [] in:
>
> 897 + if any([file_
> 898 + for path in self._ignore_
- 1272. By Diego Sarmentero on 2012-06-26
-
merge
| Manuel de la Peña (mandel) wrote : | # |
Minor things:
Typo:
997 + """Add a new path tp be watch.
1103 + """Add a new path tp be watch.
Seems to happen a number of times, a :%s/tp/to in vim or a search and replace will do the trick :)
This are in the unix.py should they be in the darwin one:
1169 +# TODO: Implement this decorators to fix some encoding issues in darwin
1170 +
1171 +def is_valid_
1172 + def decorator(func):
1173 + def wrapped(*args, **kwargs):
1174 + return func(*args, **kwargs)
1175 + return wrapped
1176 + return decorator
1177 +
1178 +
1179 +def is_valid_
1180 + def decorator(func):
1181 + def wrapped(*args, **kwargs):
1182 + return func(*args, **kwargs)
1183 + return wrapped
1184 + return decorator
1185 +
1186 +
1187 +def os_path(
1188 + def decorator(func):
1189 + def wrapped(*args, **kwargs):
1190 + return func(*args, **kwargs)
1191 + return wrapped
1192 + return decorator
There is not yield, so there most me something wrong, or the decorator is not needed or the yield to super is missing:
1025 + @defer.
1026 + def del_watch(self, wd):
1027 + """Delete the watch with the given descriptor."""
1028 + watch = self.get_watch(wd)
1029 + self.observer.
1030 + super(WatchManager, self).del_watch(wd)
This have to be sorted in alphabetical order:
45 +from ubuntuone.
46 + EventsCodes,
47 + ProcessEvent,
48 + IN_CREATE,
49 + IN_DELETE,
50 +)
51 +from ubuntuone.
52 + darwin as filesystem_
53 +)
54 +from ubuntuone.
55 + Watch,
56 + WatchManager,
57 +)
- 1273. By Diego Sarmentero on 2012-06-27
-
Fixing merge proposal
- 1274. By Diego Sarmentero on 2012-06-27
-
resolving conflict
- 1275. By Diego Sarmentero on 2012-06-27
-
removing unnecessary functions from unix
- 1276. By Diego Sarmentero on 2012-06-27
-
changing decorator+yield for return
| Manuel de la Peña (mandel) wrote : | # |
When running the tests on windows I get the following error:
tests.syncdaemo
pair
=======
[FAIL]
Traceback (most recent call last):
File "C:\Users\
ts\syncdaemon\
self.
twisted.
tCase\\
onf' not in ['C:\\Users\
fsevents\
tests.syncdaemo
oding
Can you reproduce it?
| Alejandro J. Cura (alecu) wrote : | # |
I think that EVENT_CODES should be defined in darwin.py and windows.py and imported from __init__.py
----
"Add a new path to be watch" -> "Add a new path to be watched"
"oberserver" -> "observer"
"All paths passed to methods in this class should be __windows__ paths" in darwin.py
"to keep trak" -> "to keep track"
----
"_adding_watch" has no docstring, and the comment it has is wrong.
"_process_events", "append_event" have no docstring.
----
Please rework this comment:
# we transform the events to be the same as the one in pyinotify
# and then use the proc_fun
----
"#create a rever mapping to use it in the tests." ->
"# A reverse mapping for the tests"
----
Why is this in test_darwin.py???
msg = 'Got from ReadDirectoryCh
----
| Diego Sarmentero (diegosarmentero) wrote : | # |
> I think that EVENT_CODES should be defined in darwin.py and windows.py and
> imported from __init__.py
>
> ----
>
> "Add a new path to be watch" -> "Add a new path to be watched"
> "oberserver" -> "observer"
> "All paths passed to methods in this class should be __windows__ paths" in
> darwin.py
> "to keep trak" -> "to keep track"
>
> ----
>
> "_adding_watch" has no docstring, and the comment it has is wrong.
>
> "_process_events", "append_event" have no docstring.
>
> ----
>
> Please rework this comment:
>
> # we transform the events to be the same as the one in pyinotify
> # and then use the proc_fun
>
> ----
>
> "#create a rever mapping to use it in the tests." ->
> "# A reverse mapping for the tests"
>
> ----
>
> Why is this in test_darwin.py???
>
> msg = 'Got from ReadDirectoryCh
>
> ----
Everything has been fixed!
Except for the EVENT_CODES thing, the problem is that we are using the event codes at a module level in common.py
So the __init__ import-> darwin/windows which imports-> common, so when common is loaded we can't have access to EVENT_CODES in __init__ because if we define it after importing darwin/windows, it won't exist yet.
- 1277. By Diego Sarmentero on 2012-06-28
-
changing event codes
- 1278. By Diego Sarmentero on 2012-06-28
-
merge


There seems to be a merge issue:
838 +<<<<<<< TREE
839 + For Windows:
840 + Also, they must not be literal paths, that is the \\?\ prefix should not be
841 + in the path.
842 +
843 +=======
844 +>>>>>>> MERGE-SOURCE
845 """