Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchmedo.tricks_from broken after latest upgrade #879

Closed
ginwakeup opened this issue Mar 22, 2022 · 8 comments · Fixed by #880
Closed

Watchmedo.tricks_from broken after latest upgrade #879

ginwakeup opened this issue Mar 22, 2022 · 8 comments · Fixed by #880

Comments

@ginwakeup
Copy link

Hi,

we upgraded to latest version of the package and our tools are now crashing when invoking watchmedo.tricks_from method.

The exception:

  File "C:\Program Files\JetBrains\PyCharm 2021.3.2\plugins\python\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2021.3.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "...", line 119, in <module>
    watchmedo.tricks_from(args)
TypeError: 'NoneType' object is not callable

The code:

args = parseArgs()
    if args.files:
        LOGGER.info("Starting Tricks Watcher...")

        # Launch watchmedo using input tricks configuration files.
        watchmedo.tricks_from(args)
@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 23, 2022

Could you share the tricks file to ease reproduction on my side?

@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 23, 2022

It is OK, I can reproduce easily. Working on a fix.

@ginwakeup
Copy link
Author

It is OK, I can reproduce easily. Working on a fix.

Thank you very much!

@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 23, 2022

Do you mind trying the version from the BoboTiG:fix-879 branch to ensure my fix is working fine in your environment 🙏 ? You could even hot-patch watchdog for a quick test, here is the only change required:

diff --git a/src/watchdog/watchmedo.py b/src/watchdog/watchmedo.py
index 668984d..0841c9a 100755
--- a/src/watchdog/watchmedo.py
+++ b/src/watchdog/watchmedo.py
@@ -97,6 +97,7 @@ def command(args=[], parent=subparsers, cmd_aliases=[]):
         for arg in args:
             parser.add_argument(*arg[0], **arg[1])
             parser.set_defaults(func=func)
+        return func
     return decorator

@ginwakeup
Copy link
Author

Do you mind trying the version from the BoboTiG:fix-879 branch to ensure my fix is working fine in your environment 🙏 ? You could even hot-patch watchdog for a quick test, here is the only change required:

diff --git a/src/watchdog/watchmedo.py b/src/watchdog/watchmedo.py
index 668984d..0841c9a 100755
--- a/src/watchdog/watchmedo.py
+++ b/src/watchdog/watchmedo.py
@@ -97,6 +97,7 @@ def command(args=[], parent=subparsers, cmd_aliases=[]):
         for arg in args:
             parser.add_argument(*arg[0], **arg[1])
             parser.set_defaults(func=func)
+        return func
     return decorator

Yes this works, thanks @BoboTiG
I will fix it locally for the moment, any ETA for the patch release?

@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 25, 2022

Great! Thanks for the test 💪

ETA could be ASAP, I "just" need to fix tests. Working on it right now.

BoboTiG added a commit that referenced this issue Mar 25, 2022
Fixes #879

* Fix handling tests

Mokcing `time.sleep()` does not work if `eventlet.monkey_patch()` has been called before.
So I renamed watchmedo the test file to be run before the one using `eventlet`.

Also done some cleaning in tests.
@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 25, 2022

Watchdog 2.1.7 is out 🍾

@ginwakeup
Copy link
Author

Watchdog 2.1.7 is out 🍾

Thank you!

mergify bot pushed a commit to andrewbolster/bolster that referenced this issue Mar 25, 2022
Bumps [watchdog](https://github.com/gorakhargosh/watchdog) from 2.1.6 to 2.1.7.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/gorakhargosh/watchdog/releases">watchdog's releases</a>.</em></p>
<blockquote>
<h2>2.1.7</h2>
<ul>
<li>Eliminate timeout in waiting on event queue. (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/861">#861</a>)</li>
<li>[inotify] Fix <code>not</code> equality implementation for <code>InotifyEvent</code>. (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/848">#848</a>)</li>
<li>[watchmedo] Fix calling commands from within a Python script. (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/879">#879</a>)</li>
<li>[watchmedo] <code>PyYAML</code> is loaded only when strictly necessary. Simple usages of <code>watchmedo</code> are possible without the module being installed. (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/847">#847</a>)</li>
</ul>
<p>:heart_decoration: Thanks to our beloved contributors: <a href="https://github.com/sattlerc"><code>@​sattlerc</code></a>, <a href="https://github.com/JanzenLiu"><code>@​JanzenLiu</code></a>, <a href="https://github.com/BoboTiG"><code>@​BoboTiG</code></a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/gorakhargosh/watchdog/blob/master/changelog.rst">watchdog's changelog</a>.</em></p>
<blockquote>
<p>2.1.7</p>
<pre><code>
2022-03-25 • `full history &lt;https://github.com/gorakhargosh/watchdog/compare/v2.1.6...v2.1.7&gt;`__
<ul>
<li>Eliminate timeout in waiting on event queue. (<code>[#861](gorakhargosh/watchdog#861) &amp;lt;https://github.com/gorakhargosh/watchdog/pull/861&amp;gt;</code>_)</li>
<li>[inotify] Fix <code>not</code> equality implementation for <code>InotifyEvent</code>. (<code>[#848](gorakhargosh/watchdog#848) &amp;lt;https://github.com/gorakhargosh/watchdog/pull/848&amp;gt;</code>_)</li>
<li>[watchmedo] Fix calling commands from within a Python script. (<code>[#879](gorakhargosh/watchdog#879) &amp;lt;https://github.com/gorakhargosh/watchdog/pull/879&amp;gt;</code>_)</li>
<li>[watchmedo] <code>PyYAML</code> is loaded only when strictly necessary. Simple usages of <code>watchmedo</code> are possible without the module being installed. (<code>[#847](gorakhargosh/watchdog#847) &amp;lt;https://github.com/gorakhargosh/watchdog/pull/847&amp;gt;</code>_)</li>
<li>Thanks to our beloved contributors: <a href="https://github.com/sattlerc"><code>@​sattlerc</code></a>, <a href="https://github.com/JanzenLiu"><code>@​JanzenLiu</code></a>, <a href="https://github.com/BoboTiG"><code>@​BoboTiG</code></a>
</code></pre></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/4641ccdb281a00ae76a36a1ce1e5da9a71e70724"><code>4641ccd</code></a> Release 2.1.7</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/be50c422288e721dc864f453ca93ef21113c6977"><code>be50c42</code></a> [watchmedo] Fix calling commands from within a Python script (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/880">#880</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/77e1f4668bc42b4a8706b181d882fd68c05ab8b9"><code>77e1f46</code></a> Fix typo in README (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/866">#866</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/f945d826b102598e877b34e8feeabd5693801a08"><code>f945d82</code></a> Fix pypy CI version (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/864">#864</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/3d5c4f9a4b73701fb68ebbe7a5bdd87df6197fb0"><code>3d5c4f9</code></a> Run Github actions on master (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/863">#863</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/fa3b3b58925ac60612eed4554a99e721365a2580"><code>fa3b3b5</code></a> [watchmedo] Lazy loading of the PyYAML module (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/847">#847</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/5f895488b314295ecba9351d94ad0d2f4dcab6c3"><code>5f89548</code></a> [inotify] Fix <code>not</code> equality implementation for <code>InotifyEvent</code></li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/61d8f86975abc828acdf87f6fc4da74253811ccd"><code>61d8f86</code></a> Eliminate timeout in waiting on event queue (<a href="https://github-redirect.dependabot.com/gorakhargosh/watchdog/issues/861">#861</a>)</li>
<li><a href="https://github.com/gorakhargosh/watchdog/commit/57e80a504035892772858d018df542ffb3da0bf3"><code>57e80a5</code></a> Bump the version to 2.1.7</li>
<li>See full diff in <a href="https://github.com/gorakhargosh/watchdog/compare/v2.1.6...v2.1.7">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=watchdog&package-manager=pip&previous-version=2.1.6&new-version=2.1.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants