Skip to content

Commit

Permalink
fix E722 and F405
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Dec 29, 2024
1 parent c96849d commit 0e4c6cb
Show file tree
Hide file tree
Showing 25 changed files with 53 additions and 52 deletions.
1 change: 1 addition & 0 deletions bot/core/handlers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F405
from pyrogram.filters import command, regex
from pyrogram.handlers import (
CallbackQueryHandler,
Expand Down
26 changes: 13 additions & 13 deletions bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async def before_start(self):
if self.user_transmission:
try:
chat = await TgClient.user.get_chat(self.up_dest)
except:
except Exception:
chat = None
if chat is None:
self.user_transmission = False
Expand All @@ -341,7 +341,7 @@ async def before_start(self):
if not self.user_transmission or self.mixed_leech:
try:
chat = await self.client.get_chat(self.up_dest)
except:
except Exception:
chat = None
if chat is None:
if self.user_transmission:
Expand All @@ -367,7 +367,7 @@ async def before_start(self):
self.up_dest,
ChatAction.TYPING,
)
except:
except Exception:
raise ValueError("Start the bot and try again!")
elif (
self.user_transmission or self.mixed_leech
Expand Down Expand Up @@ -536,7 +536,7 @@ async def init_bulk(self, input_list, bulk_start, bulk_end, obj):
self.multi_tag,
self.options,
).new_event()
except:
except Exception:
await send_message(
self.message,
"Reply to text file or to telegram message that have links seperated by new line!",
Expand Down Expand Up @@ -568,7 +568,7 @@ async def decompress_zst(self, dl_path, is_dir=False):
if code != 0:
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Unable to extract zst file!. Path: {f_path}",
Expand All @@ -590,7 +590,7 @@ async def decompress_zst(self, dl_path, is_dir=False):
if code != 0:
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Unable to extract zst file!. Path: {dl_path}",
Expand Down Expand Up @@ -655,7 +655,7 @@ async def proceed_extract(self, dl_path, gid):
if code != 0:
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Unable to extract archive splits!. Path: {f_path}",
Expand All @@ -670,7 +670,7 @@ async def proceed_extract(self, dl_path, gid):
del_path = ospath.join(dirpath, file_)
try:
await remove(del_path)
except:
except Exception:
self.is_cancelled = True
return up_path
dl_path = await self.decompress_zst(dl_path)
Expand Down Expand Up @@ -705,12 +705,12 @@ async def proceed_extract(self, dl_path, gid):
if not self.seed:
try:
await remove(dl_path)
except:
except Exception:
self.is_cancelled = True
return up_path
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Unable to extract archive! Uploading anyway. Path: {dl_path}",
Expand Down Expand Up @@ -793,7 +793,7 @@ async def proceed_compress(self, dl_path, gid, o_files, ft_delete):
self.new_dir = ""
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(f"{stderr}. Unable to zip this path: {dl_path}")
return dl_path
Expand Down Expand Up @@ -830,13 +830,13 @@ async def proceed_split(self, up_dir, m_size, o_files, gid):
else:
try:
await remove(f_path)
except:
except Exception:
return
continue
if not self.seed or self.new_dir:
try:
await remove(f_path)
except:
except Exception:
return
else:
m_size.append(f_size)
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/files_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def clean_all():
try:
LOGGER.info("Cleaning Download Directory")
rmtree(Config.DOWNLOAD_DIR, ignore_errors=True)
except:
except Exception:
pass
makedirs(Config.DOWNLOAD_DIR, exist_ok=True)

Expand Down
4 changes: 2 additions & 2 deletions bot/helper/ext_utils/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati
elif code != 0:
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Something went wrong while splitting file for sample video, mostly file is corrupted. Path: {video_file}"
Expand Down Expand Up @@ -731,7 +731,7 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati
elif code != 0:
try:
stderr = stderr.decode().strip()
except:
except Exception:
stderr = "Unable to decode the error!"
LOGGER.error(
f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def linkBox(url: str):
parsed_url = urlparse(url)
try:
shareToken = parsed_url.path.split("/")[-1]
except:
except Exception:
raise DirectDownloadLinkException("ERROR: invalid URL")

details = {"contents": [], "title": "", "total_size": 0}
Expand Down Expand Up @@ -939,7 +939,7 @@ def __fetch_links(session, _id=0, folderPath=""):
try:
if data["shareType"] == "singleItem":
return __singleItem(session, data["itemId"])
except:
except Exception:
pass
if not details["title"]:
details["title"] = data["dirName"]
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def mediafireFolder(url):
raw = url.split("/", 4)[-1]
folderkey = raw.split("/", 1)[0]
folderkey = folderkey.split(",")
except:
except Exception:
raise DirectDownloadLinkException("ERROR: Could not parse ")
if len(folderkey) == 1:
folderkey = folderkey[0]
Expand Down Expand Up @@ -1159,12 +1159,12 @@ def __repair_download(url):
html = HTML(session.get(url).text)
if new_link := html.xpath('//a[@id="continue-btn"]/@href'):
return __scraper(f"https://mediafire.com/{new_link[0]}")
except:
except Exception:
return None

try:
html = HTML(session.get(url).text)
except:
except Exception:
return None
if html.xpath("//div[@class='passwordPrompt']"):
if not _password:
Expand All @@ -1173,7 +1173,7 @@ def __repair_download(url):
)
try:
html = HTML(session.post(url, data={"downloadp": _password}).text)
except:
except Exception:
return None
if html.xpath("//div[@class='passwordPrompt']"):
return None
Expand Down Expand Up @@ -1344,7 +1344,7 @@ def __getFile_link(file_id):
)
if "Location" in _res.headers:
return _res.headers["Location"]
except:
except Exception:
pass

def __getFiles(html):
Expand Down Expand Up @@ -1735,7 +1735,7 @@ def mp4upload(url):
data["referer"] = url
direct_link = session.post(url, data=data).url
return direct_link, header
except:
except Exception:
raise DirectDownloadLinkException("ERROR: File Not Found!")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def add_qb_torrent(listener, path, ratio, seed_time):
]:
await delete_message(meta)
break
except:
except Exception:
await delete_message(meta)
return

Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/gdrive_utils/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self):
def speed(self):
try:
return self.proc_bytes / self.total_time
except:
except Exception:
return 0

@property
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/gdrive_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def _event_handler(self):
)
try:
await wait_for(self.event.wait(), timeout=self._timeout)
except:
except Exception:
self.id = "Timed Out. Task has been cancelled!"
self.listener.is_cancelled = True
self.event.set()
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/rclone_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def _event_handler(self):
)
try:
await wait_for(self.event.wait(), timeout=self._timeout)
except:
except Exception:
self.path = ""
self.remote = "Timed Out. Task has been cancelled!"
self.listener.is_cancelled = True
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/rclone_utils/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def rclone_serve_booter():
try:
RcloneServe[0].kill()
RcloneServe.clear()
except:
except Exception:
pass
return
config = RawConfigParser()
Expand All @@ -33,7 +33,7 @@ async def rclone_serve_booter():
try:
RcloneServe[0].kill()
RcloneServe.clear()
except:
except Exception:
pass
cmd = [
"rclone",
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/rclone_utils/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def _progress(self):
while not (self._proc is None or self._listener.is_cancelled):
try:
data = (await self._proc.stdout.readline()).decode()
except:
except Exception:
continue
if not data:
break
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/status_utils/direct_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def gid(self):
def progress_raw(self):
try:
return self._obj.processed_bytes / self.listener.size * 100
except:
except Exception:
return 0

def progress(self):
Expand All @@ -38,7 +38,7 @@ def eta(self):
self.listener.size - self._obj.processed_bytes
) / self._obj.speed
return get_readable_time(seconds)
except:
except Exception:
return "-"

def status(self):
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/status_utils/gdrive_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def gid(self) -> str:
def progress_raw(self):
try:
return self._obj.processed_bytes / self._size * 100
except:
except Exception:
return 0

def progress(self):
Expand All @@ -48,7 +48,7 @@ def eta(self):
try:
seconds = (self._size - self._obj.processed_bytes) / self._obj.speed
return get_readable_time(seconds)
except:
except Exception:
return "-"

def task(self):
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/status_utils/sevenz_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def progress_raw(self):
await self.processed_raw()
try:
return self._proccessed_bytes / self._size * 100
except:
except Exception:
return 0

async def progress(self):
Expand All @@ -47,7 +47,7 @@ def eta(self):
try:
seconds = (self._size - self._proccessed_bytes) / self.speed_raw()
return get_readable_time(seconds)
except:
except Exception:
return "-"

def status(self):
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/status_utils/telegram_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def name(self):
def progress(self):
try:
progress_raw = self._obj.processed_bytes / self._size * 100
except:
except Exception:
progress_raw = 0
return f"{round(progress_raw, 2)}%"

Expand All @@ -41,7 +41,7 @@ def eta(self):
try:
seconds = (self._size - self._obj.processed_bytes) / self._obj.speed
return get_readable_time(seconds)
except:
except Exception:
return "-"

def gid(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def eta(self):
self._obj.size - self._proccessed_bytes
) / self._obj.download_speed
return get_readable_time(seconds)
except:
except Exception:
return "-"

def task(self):
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/telegram_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ async def _upload_file(self, cap_mono, file, o_path, force_document=False):
def speed(self):
try:
return self._processed_bytes / (time() - self._start_time)
except:
except Exception:
return 0

@property
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def new_event(self):

try:
self.multi = int(args["-i"])
except:
except Exception:
self.multi = 0

self.up_dest = args["-up"]
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def do(func, message):
func_return = (
await sync_to_async(rfunc) if func == "exec" else await rfunc()
)
except:
except Exception:
value = stdout.getvalue()
return f"{value}{format_exc()}"
else:
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/file_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def select(_, message):
f"{e} Error in pause, this mostly happens after abuse aria2",
)
task.listener.select = True
except:
except Exception:
await send_message(message, "This is not a bittorrent task!")
return

Expand Down
Loading

0 comments on commit 0e4c6cb

Please sign in to comment.