Commit 15404c8d authored by Hermann Krumrey's avatar Hermann Krumrey

Add wait time parameter

parent fa97ca6e
V 4.1.0:
- Avoid overlap if terminal window is too small during download
- Added wait_time parameter
V 4.0.0:
- Went over to completely rely on python's built-in logging
- Throttle value is now passed as parameter
......
......@@ -56,7 +56,8 @@ def main(args: argparse.Namespace, logger: logging.Logger):
packs,
timeout=args.timeout,
fallback_channel=args.fallback_channel,
throttle=args.throttle
throttle=args.throttle,
wait_time=args.wait_time
)
except ConnectionError:
......
......@@ -46,7 +46,8 @@ def main(args: argparse.Namespace, logger: logging.Logger):
packs,
timeout=args.timeout,
fallback_channel=args.fallback_channel,
throttle=args.throttle
throttle=args.throttle,
wait_time=args.wait_time
)
except DownloadIncomplete:
......
......@@ -57,7 +57,11 @@ def add_xdcc_argparse_arguments(parser: ArgumentParser):
help="Limits the download speed of xdcc-dl. "
"Append K,M or G for more convenient units")
parser.add_argument("--timeout", default=120, type=int,
help="Sets a timeout for starting the download")
help="If the download didn't start during the "
"specified timeout, the program will stop")
parser.add_argument("--fallback-channel",
help="Fallback channel in case a channel could not"
"be joined automatically using WHOIS commands")
parser.add_argument("--wait-time", default=0, type=int,
help="Waits for the specified amount of time before "
"sending the xdcc send request")
......@@ -51,7 +51,8 @@ class XDCCClient(SimpleIRCClient):
retry: bool = False,
timeout: int = 120,
fallback_channel: Optional[str] = None,
throttle: Union[int, str] = -1
throttle: Union[int, str] = -1,
wait_time: int = 0
):
"""
Initializes the XDCC IRC client
......@@ -63,6 +64,8 @@ class XDCCClient(SimpleIRCClient):
:param throttle: Throttles the download to n bytes per second.
If this value is <= 0, the download speed will be
unlimited
:param wait_time: Waits for the specified amount of time before sending
a message
"""
self.logger = ColorLogger(
logging.getLogger(self.__class__.__name__),
......@@ -92,6 +95,7 @@ class XDCCClient(SimpleIRCClient):
self.timeout = timeout
self.timed_out = False
self.fallback_channel = fallback_channel
self.wait_time = wait_time
self.connected = True
self.disconnected = False
......@@ -481,6 +485,10 @@ class XDCCClient(SimpleIRCClient):
:param conn: The connection to use
:return: None
"""
self.logger.info("Waiting for {}s before sending message"
.format(self.wait_time))
time.sleep(self.wait_time)
msg = self.pack.get_request_message()
self.logger.info("Send XDCC Message: " + msg)
self.message_sent = True
......
......@@ -26,7 +26,8 @@ def download_packs(
packs: List[XDCCPack],
timeout: int = 120,
fallback_channel: Optional[str] = None,
throttle: Union[int, str] = -1
throttle: Union[int, str] = -1,
wait_time: int = 0
):
"""
Downloads a list of XDCC Packs
......@@ -36,6 +37,8 @@ def download_packs(
:param throttle: Throttles the download to n bytes per second.
If this value is <= 0, the download speed will be
unlimited
:param wait_time: Waits for the specified amount of time before sending
a message
:return: None
"""
for pack in packs:
......@@ -43,6 +46,7 @@ def download_packs(
pack,
timeout=timeout,
fallback_channel=fallback_channel,
throttle=throttle
throttle=throttle,
wait_time=wait_time
)
client.download()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment