fix: check connection error.

This commit is contained in:
EstrellaXD
2023-09-18 20:03:23 +08:00
parent 9fcbb6cc7f
commit 48d77b795d
2 changed files with 20 additions and 18 deletions

View File

@@ -50,7 +50,8 @@ class Checker:
@staticmethod
def check_downloader() -> bool:
try:
response = requests.get(settings.downloader.host, timeout=2)
url = f"http://{settings.downloader.host}" if "://" not in settings.downloader.host else f"{settings.downloader.host}"
response = requests.get(url, timeout=2)
if settings.downloader.type in response.text.lower():
with DownloadClient() as client:
if client.authed:
@@ -59,16 +60,18 @@ class Checker:
return False
else:
return False
except requests.exceptions.Timeout:
except requests.exceptions.ReadTimeout:
logger.error("[Checker] Downloader connect timeout.")
return False
except requests.exceptions.ConnectionError:
logger.error("[Checker] Downloader connect failed.")
return False
except requests.exceptions.InvalidSchema:
logger.error("[Checker] No route to downloader.")
except Exception as e:
logger.error(f"[Checker] Downloader connect failed: {e}")
return False
if __name__ == "__main__":
print(Checker().check_downloader())
# print(Checker().check_downloader())
requests.get("http://162.200.20.1", timeout=2)

View File

@@ -68,28 +68,27 @@ function onSelect(site: string) {
v-on-click-outside="clearSearch"
abs top-84px left-192px z-8
>
<transition-group name="result" tag="div" space-y-12px>
<!-- TODO: Transition Effect to fix. -->
<ab-bangumi-card
v-for="bangumi in bangumiList"
:key="bangumi.id"
:bangumi="bangumi"
type="search"
@click="() => $emit('add-bangumi', bangumi)"
/>
<transition-group name="list" tag="ul" space-y-12px>
<li v-for="bangumi in bangumiList" :key="bangumi.id">
<ab-bangumi-card
:bangumi="bangumi"
type="search"
@click="() => $emit('add-bangumi', bangumi)"
/>
</li>
</transition-group>
</div>
</template>
<style lang="scss" scoped>
.result-enter-active,
.result-leave-active {
.list-enter-active,
.list-leave-active {
transition: all 0.5s ease;
}
.result-enter-from,
.result-leave-to {
.list-enter-from,
.list-leave-to {
opacity: 0;
}