initifywait --exclude does not fire when there is at least one not excluded file
up vote
0
down vote
favorite
I am using this command to watch a directory:
inotifywait -r -e modify,create,delete --exclude ".*(.(git|idea)|(.*(___jb_tmp___|___jb_old___)))" my-dir
However, it does not work like I intend. What I want is that it does only NOT fire if every file that was changed is excluded. If there is at least one file that is NOT excluded and changes, then I want inotifywait to "fire".
My overall plan is to push code to a remove server whenever a python file or something else that is relevant is changed. I do not want to push code when only meta files from my IDE (PyCharm) or git files are changed.
Is there a way to do this?
Right now inotifywait does not fire when I change a python file in PyCharm since there are some files changed that end with _jb_tmp_. However, if I change a python file by hand, it works (e.g. in nano or vim).
ubuntu inotify
New contributor
|
show 3 more comments
up vote
0
down vote
favorite
I am using this command to watch a directory:
inotifywait -r -e modify,create,delete --exclude ".*(.(git|idea)|(.*(___jb_tmp___|___jb_old___)))" my-dir
However, it does not work like I intend. What I want is that it does only NOT fire if every file that was changed is excluded. If there is at least one file that is NOT excluded and changes, then I want inotifywait to "fire".
My overall plan is to push code to a remove server whenever a python file or something else that is relevant is changed. I do not want to push code when only meta files from my IDE (PyCharm) or git files are changed.
Is there a way to do this?
Right now inotifywait does not fire when I change a python file in PyCharm since there are some files changed that end with _jb_tmp_. However, if I change a python file by hand, it works (e.g. in nano or vim).
ubuntu inotify
New contributor
Have you tried experimenting with simpler--exclude
values?
– G-Man
Nov 28 at 23:45
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is really strange. When I use--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use--exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense
– Simon H
Nov 29 at 0:24
I tried the following command:inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock
– Simon H
Nov 29 at 0:50
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using this command to watch a directory:
inotifywait -r -e modify,create,delete --exclude ".*(.(git|idea)|(.*(___jb_tmp___|___jb_old___)))" my-dir
However, it does not work like I intend. What I want is that it does only NOT fire if every file that was changed is excluded. If there is at least one file that is NOT excluded and changes, then I want inotifywait to "fire".
My overall plan is to push code to a remove server whenever a python file or something else that is relevant is changed. I do not want to push code when only meta files from my IDE (PyCharm) or git files are changed.
Is there a way to do this?
Right now inotifywait does not fire when I change a python file in PyCharm since there are some files changed that end with _jb_tmp_. However, if I change a python file by hand, it works (e.g. in nano or vim).
ubuntu inotify
New contributor
I am using this command to watch a directory:
inotifywait -r -e modify,create,delete --exclude ".*(.(git|idea)|(.*(___jb_tmp___|___jb_old___)))" my-dir
However, it does not work like I intend. What I want is that it does only NOT fire if every file that was changed is excluded. If there is at least one file that is NOT excluded and changes, then I want inotifywait to "fire".
My overall plan is to push code to a remove server whenever a python file or something else that is relevant is changed. I do not want to push code when only meta files from my IDE (PyCharm) or git files are changed.
Is there a way to do this?
Right now inotifywait does not fire when I change a python file in PyCharm since there are some files changed that end with _jb_tmp_. However, if I change a python file by hand, it works (e.g. in nano or vim).
ubuntu inotify
ubuntu inotify
New contributor
New contributor
edited Nov 29 at 1:56
Rui F Ribeiro
38.3k1476127
38.3k1476127
New contributor
asked Nov 28 at 23:11
Simon H
1011
1011
New contributor
New contributor
Have you tried experimenting with simpler--exclude
values?
– G-Man
Nov 28 at 23:45
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is really strange. When I use--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use--exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense
– Simon H
Nov 29 at 0:24
I tried the following command:inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock
– Simon H
Nov 29 at 0:50
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52
|
show 3 more comments
Have you tried experimenting with simpler--exclude
values?
– G-Man
Nov 28 at 23:45
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is really strange. When I use--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use--exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense
– Simon H
Nov 29 at 0:24
I tried the following command:inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock
– Simon H
Nov 29 at 0:50
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52
Have you tried experimenting with simpler
--exclude
values?– G-Man
Nov 28 at 23:45
Have you tried experimenting with simpler
--exclude
values?– G-Man
Nov 28 at 23:45
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is really strange. When I use
--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use --exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense– Simon H
Nov 29 at 0:24
It is really strange. When I use
--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use --exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense– Simon H
Nov 29 at 0:24
I tried the following command:
inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock– Simon H
Nov 29 at 0:50
I tried the following command:
inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock– Simon H
Nov 29 at 0:50
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
As stated in the comments to my question, I found that the problem was not caused by inotifywait
but by PyCharm. It turned out that PyCharm has an option called "safe write" that tells the IDE to write changes to temporary files first and if this succeeds, it deletes the original file and renames the tempory file to the original file name.
This is why inotifywait
only sees events like these:
$ inotifywait -r -m -e modify,create,delete my-dir
my-dir/ CREATE main.py___jb_tmp___
my-dir/ MODIFY main.py___jb_tmp___
my-dir/ DELETE main.py___jb_old___
my-dir/.idea/ CREATE workspace.xml___jb_tmp___
my-dir/.idea/ MODIFY workspace.xml___jb_tmp___
my-dir/.idea/ DELETE workspace.xml___jb_old___
my-dir/.git/ CREATE index.lock
my-dir/.git/ DELETE index.lock
So I disabled safe write in PyCharm and now use this command:
inotifywait -r -e modify,create,delete --exclude ".*(.git|.idea)" my-dir
This is doing exactly what I want. The events I see from inotifywait
are like this:
my-dir/ MODIFY main.py
New contributor
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As stated in the comments to my question, I found that the problem was not caused by inotifywait
but by PyCharm. It turned out that PyCharm has an option called "safe write" that tells the IDE to write changes to temporary files first and if this succeeds, it deletes the original file and renames the tempory file to the original file name.
This is why inotifywait
only sees events like these:
$ inotifywait -r -m -e modify,create,delete my-dir
my-dir/ CREATE main.py___jb_tmp___
my-dir/ MODIFY main.py___jb_tmp___
my-dir/ DELETE main.py___jb_old___
my-dir/.idea/ CREATE workspace.xml___jb_tmp___
my-dir/.idea/ MODIFY workspace.xml___jb_tmp___
my-dir/.idea/ DELETE workspace.xml___jb_old___
my-dir/.git/ CREATE index.lock
my-dir/.git/ DELETE index.lock
So I disabled safe write in PyCharm and now use this command:
inotifywait -r -e modify,create,delete --exclude ".*(.git|.idea)" my-dir
This is doing exactly what I want. The events I see from inotifywait
are like this:
my-dir/ MODIFY main.py
New contributor
add a comment |
up vote
0
down vote
As stated in the comments to my question, I found that the problem was not caused by inotifywait
but by PyCharm. It turned out that PyCharm has an option called "safe write" that tells the IDE to write changes to temporary files first and if this succeeds, it deletes the original file and renames the tempory file to the original file name.
This is why inotifywait
only sees events like these:
$ inotifywait -r -m -e modify,create,delete my-dir
my-dir/ CREATE main.py___jb_tmp___
my-dir/ MODIFY main.py___jb_tmp___
my-dir/ DELETE main.py___jb_old___
my-dir/.idea/ CREATE workspace.xml___jb_tmp___
my-dir/.idea/ MODIFY workspace.xml___jb_tmp___
my-dir/.idea/ DELETE workspace.xml___jb_old___
my-dir/.git/ CREATE index.lock
my-dir/.git/ DELETE index.lock
So I disabled safe write in PyCharm and now use this command:
inotifywait -r -e modify,create,delete --exclude ".*(.git|.idea)" my-dir
This is doing exactly what I want. The events I see from inotifywait
are like this:
my-dir/ MODIFY main.py
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
As stated in the comments to my question, I found that the problem was not caused by inotifywait
but by PyCharm. It turned out that PyCharm has an option called "safe write" that tells the IDE to write changes to temporary files first and if this succeeds, it deletes the original file and renames the tempory file to the original file name.
This is why inotifywait
only sees events like these:
$ inotifywait -r -m -e modify,create,delete my-dir
my-dir/ CREATE main.py___jb_tmp___
my-dir/ MODIFY main.py___jb_tmp___
my-dir/ DELETE main.py___jb_old___
my-dir/.idea/ CREATE workspace.xml___jb_tmp___
my-dir/.idea/ MODIFY workspace.xml___jb_tmp___
my-dir/.idea/ DELETE workspace.xml___jb_old___
my-dir/.git/ CREATE index.lock
my-dir/.git/ DELETE index.lock
So I disabled safe write in PyCharm and now use this command:
inotifywait -r -e modify,create,delete --exclude ".*(.git|.idea)" my-dir
This is doing exactly what I want. The events I see from inotifywait
are like this:
my-dir/ MODIFY main.py
New contributor
As stated in the comments to my question, I found that the problem was not caused by inotifywait
but by PyCharm. It turned out that PyCharm has an option called "safe write" that tells the IDE to write changes to temporary files first and if this succeeds, it deletes the original file and renames the tempory file to the original file name.
This is why inotifywait
only sees events like these:
$ inotifywait -r -m -e modify,create,delete my-dir
my-dir/ CREATE main.py___jb_tmp___
my-dir/ MODIFY main.py___jb_tmp___
my-dir/ DELETE main.py___jb_old___
my-dir/.idea/ CREATE workspace.xml___jb_tmp___
my-dir/.idea/ MODIFY workspace.xml___jb_tmp___
my-dir/.idea/ DELETE workspace.xml___jb_old___
my-dir/.git/ CREATE index.lock
my-dir/.git/ DELETE index.lock
So I disabled safe write in PyCharm and now use this command:
inotifywait -r -e modify,create,delete --exclude ".*(.git|.idea)" my-dir
This is doing exactly what I want. The events I see from inotifywait
are like this:
my-dir/ MODIFY main.py
New contributor
New contributor
answered Nov 29 at 1:08
Simon H
1011
1011
New contributor
New contributor
add a comment |
add a comment |
Simon H is a new contributor. Be nice, and check out our Code of Conduct.
Simon H is a new contributor. Be nice, and check out our Code of Conduct.
Simon H is a new contributor. Be nice, and check out our Code of Conduct.
Simon H is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484792%2finitifywait-exclude-does-not-fire-when-there-is-at-least-one-not-excluded-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried experimenting with simpler
--exclude
values?– G-Man
Nov 28 at 23:45
It is very hard to find simpler values that take care of all the files that PyCharm writes... Do you have a simpler idea?
– Simon H
Nov 29 at 0:15
It is really strange. When I use
--exclude "(___jb_tmp___|___jb_old___)$"
it fires when I save a file in PyCharm (but the event is called '.git/ CREATE index.lock'). When I use--exclude "(index.lock|___jb_tmp___|___jb_old___)$"
and save a file, nothing happens. It looks like PyCharm is not really writing python files? But this makes no sense– Simon H
Nov 29 at 0:24
I tried the following command:
inotifywait -r -m -e modify,create,delete my-dir
(note the -m flag to monitor and see all events) and found that there is no event for the .py files when I save them in pycharm. The only events: my-dir/patch_experts/ CREATE densenet.py___jb_tmp___ my-dir/patch_experts/ MODIFY densenet.py___jb_tmp___ my-dir/patch_experts/ DELETE densenet.py___jb_old___ my-dir/.idea/ CREATE workspace.xml___jb_tmp___ my-dir/.idea/ MODIFY workspace.xml___jb_tmp___ my-dir/.idea/ DELETE workspace.xml___jb_old___ my-dir/.git/ CREATE index.lock my-dir/.git/ DELETE index.lock– Simon H
Nov 29 at 0:50
When I use sublime instead of PyCharm it works (I see 'MODIFY main.py'). So the reason for the problem is PyCharm, but I have no idea why this happens
– Simon H
Nov 29 at 0:52