Skip to content

Commit

Permalink
fix bare except
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Jul 12, 2024
1 parent 66db557 commit 542ba1d
Show file tree
Hide file tree
Showing 29 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qbittorrentapi import Client as qbClient
from faulthandler import enable as faulthandler_enable
from socket import setdefaulttimeout
from logging import getLogger, FileHandler, StreamHandler, INFO, basicConfig, error, info, warning, Formatter, ERROR
from logging import getLogger, FileHandler, StreamHandler, INFO, basicConfig, error, warning, Formatter, ERROR
from uvloop import install

faulthandler_enable()
Expand Down
2 changes: 1 addition & 1 deletion bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def restart_notification():
chat_id, msg_id = map(int, f)
try:
await bot.edit_message_text(chat_id=chat_id, message_id=msg_id, text='Restarted Successfully!')
except:
except Exception:
pass
await aioremove(".restartmsg")

Expand Down
4 changes: 2 additions & 2 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_readable_message():
if hasattr(download, 'seeders_num'):
try:
msg += f"\nSeeders: {download.seeders_num()} | Leechers: {download.leechers_num()}"
except:
except Exception:
pass
elif download.status() == MirrorStatus.STATUS_SEEDING:
msg += f"<blockquote>Size: {download.size()}"
Expand Down Expand Up @@ -358,7 +358,7 @@ async def get_content_type(url):
async with aioClientSession(trust_env=True) as session:
async with session.get(url, verify_ssl=False) as response:
return response.headers.get('Content-Type')
except:
except Exception:
return None


Expand Down
12 changes: 6 additions & 6 deletions bot/helper/ext_utils/files_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def split_file(path, size, file_, dirpath, split_size, listener, start_tim
err = (await listener.suproc.stderr.read()).decode().strip()
try:
await aioremove(out_path)
except:
except Exception:
pass
if multi_streams:
LOGGER.warning(
Expand Down Expand Up @@ -396,12 +396,12 @@ async def clean_target(path):
if await aiopath.isdir(path):
try:
await aiormtree(path)
except:
except Exception:
pass
elif await aiopath.isfile(path):
try:
await aioremove(path)
except:
except Exception:
pass


Expand All @@ -410,15 +410,15 @@ async def clean_download(path):
LOGGER.info(f"Cleaning Download: {path}")
try:
await aiormtree(path)
except:
except Exception:
pass


async def start_cleanup():
xnox_client.torrents_delete(torrent_hashes="all")
try:
await aiormtree('/usr/src/app/downloads/')
except:
except Exception:
pass
await makedirs('/usr/src/app/downloads/', exist_ok = True)

Expand All @@ -428,7 +428,7 @@ def clean_all():
xnox_client.torrents_delete(torrent_hashes="all")
try:
rmtree('/usr/src/app/downloads/')
except:
except Exception:
pass


Expand Down
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def stop_duplicate_check(name, listener):
elif listener.extract:
try:
name = get_base_name(name)
except:
except Exception:
name = None
if name is not None:
telegraph_content, contents_no = await sync_to_async(GoogleDriveHelper().drive_list, name, stopDup=True)
Expand Down
8 changes: 4 additions & 4 deletions bot/helper/listeners/aria2_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def __onDownloadStarted(api, gid):
elif listener.extract:
try:
name = get_base_name(name)
except:
except Exception:
name = None
if name is not None:
telegraph_content, contents_no = await sync_to_async(GoogleDriveHelper().drive_list, name, True)
Expand Down Expand Up @@ -97,7 +97,7 @@ async def __onDownloadStarted(api, gid):
async def __onDownloadComplete(api, gid):
try:
download = await sync_to_async(api.get_download, gid)
except:
except Exception:
return
if download.options.follow_torrent == 'false':
return
Expand Down Expand Up @@ -145,7 +145,7 @@ async def __onBtDownloadComplete(api, gid):
if not file_o.selected and await aiopath.exists(f_path):
try:
await aioremove(f_path)
except:
except Exception:
pass
await clean_unwanted(download.dir)
if listener.seed:
Expand Down Expand Up @@ -199,7 +199,7 @@ async def __onDownloadError(api, gid):
return
error = download.error_message
LOGGER.info(f"Download Error: {error}")
except:
except Exception:
pass
if dl := await getDownloadByGid(gid):
listener = dl.listener()
Expand Down
10 changes: 5 additions & 5 deletions bot/helper/listeners/tasks_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def clean(self):
Interval.clear()
await sync_to_async(aria2.purge)
await delete_all_messages()
except:
except Exception:
pass

async def onDownloadStart(self):
Expand Down Expand Up @@ -171,7 +171,7 @@ async def onDownloadComplete(self):
del_path = ospath.join(dirpath, file_)
try:
await aioremove(del_path)
except:
except Exception:
return
else:
if self.seed:
Expand All @@ -191,7 +191,7 @@ async def onDownloadComplete(self):
if not self.seed:
try:
await aioremove(dl_path)
except:
except Exception:
return
else:
LOGGER.error(
Expand Down Expand Up @@ -268,12 +268,12 @@ async def onDownloadComplete(self):
continue
try:
await aioremove(f_path)
except:
except Exception:
return
elif not self.seed or self.newDir:
try:
await aioremove(f_path)
except:
except Exception:
return
else:
m_size.append(f_size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,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 @@ -783,7 +783,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 @@ -833,7 +833,7 @@ def __get_info(folderkey):
def __scraper(url):
try:
html = HTML(session.get(url).text)
except:
except Exception:
return
if final_link := html.xpath("//a[@id='downloadButton']/@href"):
return final_link[0]
Expand Down Expand Up @@ -967,7 +967,7 @@ def __getFile_link(file_id):
'https://send.cm/', data={'op': 'download2', 'id': file_id}, allow_redirects=False)
if 'Location' in _res.headers:
return _res.headers['Location']
except:
except Exception:
pass

def __getFiles(html):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def add_qb_torrent(link, path, listener, ratio, seed_time):
if tor_info.state not in ["metaDL", "checkingResumeData", "pausedDL"]:
await deleteMessage(meta)
break
except:
except Exception:
await deleteMessage(meta)
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def __onDownloadError(self, error):
async with global_lock:
try:
GLOBAL_GID.remove(self.__id)
except:
except Exception:
pass
await self.__listener.onDownloadError(error)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __onDownloadProgress(self, d):
self.__eta = d.get('eta', '-') or '-'
try:
self.__progress = (self.__downloaded_bytes / self.__size) * 100
except:
except Exception:
pass

async def __onDownloadStart(self, from_queue=False):
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 @@ -120,7 +120,7 @@ async def __event_handler(self):
pfunc, filters=regex('^rcq') & user(self.__user_id)), group=-1)
try:
await wait_for(self.event.wait(), timeout=self.__timeout)
except:
except Exception:
self.path = ''
self.remote = 'Timed Out. Task has been cancelled!'
self.is_cancelled = True
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/rclone_utils/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def __progress(self):
while not (self.__proc is None or self.__is_cancelled):
try:
data = (await self.__proc.stdout.readline()).decode()
except:
except Exception:
continue
if not data:
break
Expand Down Expand Up @@ -379,7 +379,7 @@ async def cancel_download(self):
if self.__proc is not None:
try:
self.__proc.kill()
except:
except Exception:
pass
if self.__is_download:
LOGGER.info(f"Cancelling Download: {self.name}")
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 @@ -13,7 +13,7 @@ def gid(self):
def progress_raw(self):
try:
return self.__obj.processed_bytes / self.__obj.total_size * 100
except:
except Exception:
return 0

def progress(self):
Expand All @@ -32,7 +32,7 @@ def eta(self):
try:
seconds = (self.__obj.total_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/extract_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def speed_raw(self):
def progress_raw(self):
try:
return self.processed_raw() / self.__size * 100
except:
except Exception:
return 0

def progress(self):
Expand All @@ -43,7 +43,7 @@ def eta(self):
try:
seconds = (self.__size - self.processed_raw()) / 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/gdrive_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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 @@ -47,7 +47,7 @@ def eta(self):
seconds = (self.__size - self.__obj.processed_bytes) / \
self.__obj.speed
return get_readable_time(seconds)
except:
except Exception:
return '-'

def download(self):
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/status_utils/mega_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def name(self):
def progress_raw(self):
try:
return round(self.__obj.downloaded_bytes / self.__size * 100, 2)
except:
except Exception:
return 0.0

def progress(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 @@ -28,7 +28,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 @@ -40,7 +40,7 @@ def eta(self):
seconds = (self.__size - self.__obj.processed_bytes) / \
self.__obj.speed
return get_readable_time(seconds)
except:
except Exception:
return '-'

def gid(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/status_utils/ytdlp_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def eta(self):
seconds = (self.__obj.size - self.processed_raw()) / \
self.__obj.download_speed
return get_readable_time(seconds)
except:
except Exception:
return '-'

def download(self):
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/status_utils/zip_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def speed_raw(self):
def progress_raw(self):
try:
return self.processed_raw() / self.__size * 100
except:
except Exception:
return 0

def progress(self):
Expand All @@ -43,7 +43,7 @@ def eta(self):
try:
seconds = (self.__size - self.processed_raw()) / self.speed_raw()
return get_readable_time(seconds)
except:
except Exception:
return '-'

def status(self):
Expand Down
6 changes: 3 additions & 3 deletions bot/helper/mirror_leech_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, name=None, path=None, listener=None):
def speed(self):
try:
return self.__processed_bytes / self.__total_time
except:
except Exception:
return 0

@property
Expand Down Expand Up @@ -123,7 +123,7 @@ def getFolderData(self, file_id):
meta = self.__service.files().get(fileId=file_id, supportsAllDrives=True).execute()
if meta.get('mimeType', '') == self.__G_DRIVE_DIR_MIME_TYPE:
return meta.get('name')
except:
except Exception:
return

@retry(wait=wait_exponential(multiplier=2, min=3, max=6), stop=stop_after_attempt(3),
Expand Down Expand Up @@ -325,7 +325,7 @@ def __upload_file(self, file_path, file_name, mime_type, dest_id, is_dir=True):
if not self.__listener.seed or self.__listener.newDir:
try:
osremove(file_path)
except:
except Exception:
pass
self.__file_processed_bytes = 0
if not is_dir:
Expand Down
Loading

0 comments on commit 542ba1d

Please sign in to comment.