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

split watchmedo logic into _watchmedo.py (yaml and argh independent) #808

Closed

Conversation

replabrobin
Copy link
Contributor

To avoid using the yaml & argh dependencies for simple programmatic use I split out the logical parts of watchmedo.py into a separate module _watchedo.py; watchmedo can then import the functions it needs and the command stubs can use them .

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jun 29, 2021

I am not sure to understand the need and the patch 🤔
Could you elaborate please?

@replabrobin
Copy link
Contributor Author

replabrobin commented Jun 30, 2021

I have a cgi web application for which there is a need for a test harness that can be used in development. Mostly I can use a simple bash script to run a wsgi app and use inotify to check for underlying changes. My Boss uses a mac and inotify won't work. Conceptually watchmedo can do the restarts, but I wanted to make a simpler solution using just python. I can do all that I need with watchdog, but to use the auto_restart function itself I have to copy the code from watchmedo.py or incur the extra requirement of pyyaml and argh. By separating out the logic part of the code in watchmedo I can use the auto_restart logic without having to import argh & yaml (so they're no longer required at run time). It's really a minimalist desire.

An additional issue is that the watchmedo auto_restart becomes part of the parser and I would need to interface via an argv. I have simple python objects and that would mean conversion to argv form which is not required. Creating a post parse args object from python is easier.

I can live without this patch, but I dislike just copying the code across.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jul 28, 2021

Oh I get it now... Sorry for the late answer :)

You are importing stuff from _watchmedo in your own code, right? That seems good to me, those changes cannot hurt (:crossed_fingers:).

@ktdreyer
Copy link

ktdreyer commented Aug 2, 2021

See also #824 , argh is umaintained upstream and I think we should remove it.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Oct 1, 2021

Now that argh was removed (cf. #836), #847 could be useful for you, @replabrobin ? It avoids rewritting too much part of the module.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Dec 15, 2021

Superseded by #847.

@BoboTiG BoboTiG closed this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants