Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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 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)
def run(self):
# Monitor keypress and button press
LOG.info("Linux multimedia hotkey start")
ctx = self.disp.record_create_context(
0,
[record.AllClients],
[{
'core_requests': (0, 0),
'core_replies': (0, 0),
'ext_requests': (0, 0, 0, 0),
'ext_replies': (0, 0, 0, 0),
'delivered_events': (0, 0),
'device_events': (X.KeyReleaseMask, X.ButtonReleaseMask),
'errors': (0, 0),
'client_started': False,
'client_died': False,
}])
self.disp.record_enable_context(ctx, self.handler)
self.disp.record_free_context(ctx)
def check_release(cls):
url = 'https://api.github.com/repos/cosven/FeelUOwn/releases'
LOG.info('正在查找新版本...')
try:
loop = asyncio.get_event_loop()
future = loop.run_in_executor(
None, partial(requests.get, url, timeout=5))
res = yield from future
if not res.status_code == 200:
LOG.warning('connect to api.github.com timeout')
return
releases = res.json()
for release in releases:
if release['tag_name'] > cls.current_version:
title = u'发现新版本 %s hoho' % release['tag_name']
LOG.info(title)
content = release['name']
ControllerApi.notify_widget.show_message(title, content)
ViewOp.ui.STATUS_BAR.showMessage(title, 5000)
def Play(self):
LOG.info('dbus: call play')
ControllerApi.player.play()