Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def access_network_queue(self, res):
if ControllerApi.network_manager.network_queue.empty():
LOG.info('Nothing in network queue')
return
item = ControllerApi.network_manager.network_queue.get_nowait()
item(res)
}
if not self.is_autofill:
data = self.ne.login(username, password, phone_login)
else:
data = self.ne.auto_login(username, password, phone_login)
if data['code'] == 200:
self.hint_label.setText(u'登录成功')
self.signal_login_sucess.emit(data)
self.close()
self.save_login_info(login_data)
elif data['code'] == 415: # 需要验证码
self.is_need_captcha = True
self.hint_label.setText(data['message'])
LOG.info(u'本次登陆需要验证码')
self.captcha_id = data['captchaId']
self.captcha_label.show()
self.captcha_lineedit.show()
url = self.ne.get_captcha_url(data['captchaId'])
request = QNetworkRequest(QUrl(url))
self.nm.get(request)
self.parent().network_queue.put(self.show_captcha)
elif data['code'] == 408:
self.hint_label.setText(u'网络连接超时')
elif data['code'] == 501:
self.hint_label.setText(u'用户名错误')
elif data['code'] == 502:
self.hint_label.setText(u'密码错误')
elif data['code'] == 509:
self.hint_label.setText(u'你可能正在使用手机号登陆,密码错误几次之后,你可能需要等待几分钟再登录')
else:
def run_event_loop():
LOG.info("try to load mac hotkey event loop")
import Quartz
from AppKit import NSSystemDefined
# Set up a tap, with type of tap, location, options and event mask
tap = Quartz.CGEventTapCreate(
Quartz.kCGSessionEventTap, # Session level is enough for our needs
Quartz.kCGHeadInsertEventTap, # Insert wherever, we do not filter
Quartz.kCGEventTapOptionDefault,
# NSSystemDefined for media keys
Quartz.CGEventMaskBit(NSSystemDefined),
keyboard_tap_callback,
None
)
run_loop_source = Quartz.CFMachPortCreateRunLoopSource(
None, tap, 0)
def exit(cls):
ControllerApi.notify_widget.show_message("通知", "退出 FM 播放模式")
def init():
if not is_linux():
return 0
from .service import MprisServer
import dbus.mainloop.pyqt5
LOG.info("Load mpris plugin")
dbus.mainloop.pyqt5.DBusQtMainLoop(set_as_default=True)
MprisServer()
request = QNetworkRequest(QUrl(url))
self.nm.get(request)
self.parent().network_queue.put(self.show_captcha)
return
phone_login = False # 0: 网易通行证, 1: 手机号登陆
username = str(self.username_widget.text()) # 包含中文会出错
password = str(self.password_widget.text())
# 2: checked, 1: partial checked
is_remember = self.is_remember_chb.checkState()
# judget if logining by using phone number
if username.isdigit() and len(username) == 11:
username = int(username)
phone_login = True
LOG.info(u"正在使用手机号进行登录")
login_data = {
'username': username,
'password': password,
'is_remember': is_remember
}
if not self.is_autofill:
data = self.ne.login(username, password, phone_login)
else:
data = self.ne.auto_login(username, password, phone_login)
if data['code'] == 200:
self.hint_label.setText(u'登录成功')
self.signal_login_sucess.emit(data)
self.close()
def access_network_queue(self, res):
if ControllerApi.network_manager.network_queue.empty():
LOG.info('Nothing in network queue')
return
item = ControllerApi.network_manager.network_queue.get_nowait()
item(res)
self.username_label = QLabel()
self.password_label = QLabel()
self.hint_label = QLabel()
self.username_widget = QLineEdit()
self.password_widget = QLineEdit()
self.login_btn = QPushButton()
self.captcha_label = QLabel()
self.captcha_lineedit = QLineEdit()
self.layout = QVBoxLayout()
self.is_remember_chb = QCheckBox(u'记住账号')
self.nm = NetworkManager()
self.ne = ControllerApi.api
self.is_autofill = False
self.is_need_captcha = False
self.captcha_id = 0
self.user_data = 0
self.__set_signal_binding()
self.__set_widgets_prop()
self.__set_layouts_prop()
self.__set_me()
self.fill_content()
return 1 # run_cli
cli_cmds = ('show', 'play', 'search')
if args.cmd not in cli_cmds:
print_error('Fuo daemon not started.')
sys.exit(1)
return 2 # run_once
if not args.no_window:
try:
import PyQt5 # noqa
except ImportError:
logger.warning('PyQt5 is not installed, can only use daemon mode.')
else:
config.MODE |= App.GuiMode
if not args.no_server:
config.MODE |= App.DaemonMode
return 3
is_daemon_started = is_port_used(23333) or is_port_used(23334)
if is_daemon_started:
return 1 # run_cli
cli_cmds = ('show', 'play', 'search')
if args.cmd not in cli_cmds:
print_error('Fuo daemon not started.')
sys.exit(1)
return 2 # run_once
if not args.no_window:
try:
import PyQt5 # noqa
except ImportError:
logger.warning('PyQt5 is not installed, can only use daemon mode.')
else:
config.MODE |= App.GuiMode
if not args.no_server:
config.MODE |= App.DaemonMode
return 3