Compare commits
2 commits
76f0a4cdd4
...
5c6783452d
Author | SHA1 | Date | |
---|---|---|---|
5c6783452d | |||
70d75c688c |
1 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
from asyncio import run_coroutine_threadsafe
|
from asyncio import run_coroutine_threadsafe
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Sequence
|
from typing import TYPE_CHECKING, Sequence
|
||||||
|
|
||||||
from red_commons.logging import RedTraceLogger, getLogger
|
from red_commons.logging import RedTraceLogger, getLogger
|
||||||
from redbot.core import Config, checks, commands
|
from redbot.core import Config, checks, commands
|
||||||
|
@ -8,7 +8,10 @@ from redbot.core.bot import Red
|
||||||
from redbot.core.core_commands import CoreLogic
|
from redbot.core.core_commands import CoreLogic
|
||||||
from redbot.core.utils.chat_formatting import bold, box, humanize_list
|
from redbot.core.utils.chat_formatting import bold, box, humanize_list
|
||||||
from watchdog.events import FileSystemEvent, FileSystemMovedEvent, RegexMatchingEventHandler
|
from watchdog.events import FileSystemEvent, FileSystemMovedEvent, RegexMatchingEventHandler
|
||||||
from watchdog.observers import Observer, ObserverType
|
from watchdog.observers import Observer
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from watchdog.observers import ObserverType
|
||||||
|
|
||||||
|
|
||||||
class HotReload(commands.Cog):
|
class HotReload(commands.Cog):
|
||||||
|
@ -16,7 +19,7 @@ class HotReload(commands.Cog):
|
||||||
|
|
||||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||||
__version__ = "1.3.0"
|
__version__ = "1.3.2"
|
||||||
__documentation__ = "https://seacogs.coastalcommits.com/hotreload/"
|
__documentation__ = "https://seacogs.coastalcommits.com/hotreload/"
|
||||||
|
|
||||||
def __init__(self, bot: Red) -> None:
|
def __init__(self, bot: Red) -> None:
|
||||||
|
@ -70,6 +73,10 @@ class HotReload(commands.Cog):
|
||||||
self.logger.debug("Stopped hanging observer.")
|
self.logger.debug("Stopped hanging observer.")
|
||||||
continue
|
continue
|
||||||
for path in paths:
|
for path in paths:
|
||||||
|
if not path.exists():
|
||||||
|
self.logger.warning("Path %s does not exist. Skipping.", path)
|
||||||
|
continue
|
||||||
|
self.logger.debug("Adding observer schedule for path %s.", path)
|
||||||
observer.schedule(event_handler=HotReloadHandler(cog=self, path=path), path=path, recursive=True)
|
observer.schedule(event_handler=HotReloadHandler(cog=self, path=path), path=path, recursive=True)
|
||||||
observer.start()
|
observer.start()
|
||||||
self.logger.info("Started observer. Watching for file changes.")
|
self.logger.info("Started observer. Watching for file changes.")
|
||||||
|
|
Loading…
Add table
Reference in a new issue