Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YangLeiSX committed Apr 12, 2020
1 parent 25e8c94 commit 8823ae0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 55 deletions.
5 changes: 1 addition & 4 deletions source/canvas_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from bs4 import BeautifulSoup
import json
import os
import sys
from time import sleep
from PyQt5.QtCore import qDebug
from PyQt5.QtCore import QThread
Expand All @@ -22,9 +21,7 @@ def __init__(self, parent, session=None):
self.parent = parent
self.status = False

self.log_dir = os.path.join(
os.path.split(os.path.abspath(__file__))[0],
"log")
self.log_dir = self.parent.log_dir
if not os.path.exists(self.log_dir):
os.mkdir(self.log_dir)

Expand Down
6 changes: 2 additions & 4 deletions source/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@


class Captcha(QtWidgets.QDialog, Ui_Captcha):
def __init__(self):
def __init__(self, parent):
super(Captcha, self).__init__()
self.setupUi(self)
log_dir = os.path.join(
os.path.split(os.path.abspath(__file__))[0],
"log")
log_dir = parent.log_dir
pixmap = QtGui.QPixmap(os.path.join(log_dir, "captcha.jpeg"))
self.captcha.setPixmap(pixmap)
self.show()
14 changes: 4 additions & 10 deletions source/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ def _get_login_page(session, url):


@retry(retry=retry_if_exception_type(RequestException), wait=wait_fixed(3))
def _bypass_captcha(session, url):
def _bypass_captcha(parent, session, url):
# return captcha code
captcha = session.get(url)
log_dir = os.path.join(
os.path.split(os.path.abspath(__file__))[0],
"log")
if not os.path.exists(log_dir):
os.mkdir(log_dir)
log_dir = parent.log_dir
with open(os.path.join(log_dir, 'captcha.jpeg'), 'wb') as f:
f.write(captcha.content)
qDebug("out captcha")
Expand Down Expand Up @@ -77,8 +73,6 @@ def _login(session, sid, returl, se, client, username, password, code, uuid):
def login(url, parent=None, username=None, password=None):
if (not password) or (not username):
return None
# username = input('Username: ')
# password = getpass('Password(no echo): ')
qDebug("in login")
while True:
session = _create_session()
Expand All @@ -94,8 +88,8 @@ def login(url, parent=None, username=None, password=None):
captcha_id += get_timestamp()
captcha_url = 'https://jaccount.sjtu.edu.cn/jaccount/captcha?' +\
captcha_id
_bypass_captcha(session, captcha_url)
check = Captcha()
code = _bypass_captcha(parent, session, captcha_url)
check = Captcha(parent)
if not check.exec_():
session.close()
return None
Expand Down
4 changes: 4 additions & 0 deletions source/download_queue.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
# @author: YangLeiSX
# @data: 2020-04-06

from PyQt5 import QtCore
import os
from time import sleep
Expand Down
34 changes: 0 additions & 34 deletions source/downoad_queue.py

This file was deleted.

7 changes: 4 additions & 3 deletions source/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
import os
import json
import time
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import qDebug, QFileInfo
from PyQt5.QtCore import pyqtSignal as Signal
Expand Down Expand Up @@ -59,6 +58,8 @@ def initRender(self):
self.progress.setValue(0)
self.isSave.setChecked(False)
self.Speed.setText("500")
if not os.path.exists(self.log_dir):
os.mkdir(self.log_dir)
if os.path.exists(os.path.join(self.log_dir, 'loginInfo.json')):
with open(os.path.join(self.log_dir, 'loginInfo.json'), 'r') as f:
loginInfo = json.loads(f.read())
Expand All @@ -83,7 +84,7 @@ def on_LoginBtn_clicked(self):
qDebug(jaccount)
qDebug(password)
self.session = login(url="https://oc.sjtu.edu.cn/login/openid_connect",
parent=self, username=jaccount, password=password,)
parent=self, username=jaccount, password=password)
if self.session:
self.LogInfo.emit("[MSG]Log in Successfully!\n")
loginInfo = {}
Expand All @@ -102,7 +103,7 @@ def on_UpdateBtn_clicked(self):
return
self.cu = CanvasUpdate(self, self.session)
self.cu.start()
self.parseRemote()
# self.parseRemote()

@Slot()
def on_GetPathBtn_clicked(self):
Expand Down

0 comments on commit 8823ae0

Please sign in to comment.