Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
break
except Exception as e:
LOG.error(str(e))
def keyboard_tap_callback(proxy, type_, event, refcon):
from AppKit import NSKeyUp, NSEvent, NSBundle
NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] =\
dict(NSAllowsArbitraryLoads=True)
if type_ < 0 or type_ > 0x7fffffff:
LOG.error('Unkown mac event')
run_event_loop()
LOG.error('restart mac key board event loop')
return event
try:
key_event = NSEvent.eventWithCGEvent_(event)
except:
LOG.info("mac event cast error")
return event
if key_event.subtype() == 8:
key_code = (key_event.data1() & 0xFFFF0000) >> 16
key_state = (key_event.data1() & 0xFF00) >> 8
if key_code in (16, 19, 20):
# 16 for play-pause, 19 for next, 20 for previous
if key_state == NSKeyUp:
if key_code is 19:
ControllerApi.player.play_next()
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "正在尝试调用VLC视频播放器播放MV")
try:
subprocess.Popen(['vlc', url_middle, '--play-and-exit', '-f'])
except:
LOG.error('call vlc player failed')
elif platform.system().lower() == 'Darwin'.lower():
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "准备调用 QuickTime Player 播放mv")
try:
subprocess.Popen(
['open', '-a', 'QuickTime Player', url_middle])
except:
LOG.error('call quicktime player failed')
def keyboard_tap_callback(proxy, type_, event, refcon):
from AppKit import NSKeyUp, NSEvent, NSBundle
NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] =\
dict(NSAllowsArbitraryLoads=True)
if type_ < 0 or type_ > 0x7fffffff:
LOG.error('Unkown mac event')
run_event_loop()
LOG.error('restart mac key board event loop')
return event
try:
key_event = NSEvent.eventWithCGEvent_(event)
except:
LOG.info("mac event cast error")
return event
if key_event.subtype() == 8:
key_code = (key_event.data1() & 0xFFFF0000) >> 16
key_state = (key_event.data1() & 0xFF00) >> 8
if key_code in (16, 19, 20):
# 16 for play-pause, 19 for next, 20 for previous
if key_state == NSKeyUp:
if key_code is 19:
ControllerApi.player.play_next()
elif key_code is 20:
ControllerApi.player.play_last()
def write_json_into_file(data_json, filepath):
try:
with open(filepath, "w") as f:
data_str = json.dumps(data_json, indent=4)
f.write(data_str)
return True
except Exception as e:
LOG.error(str(e))
LOG.error("Write json into file failed")
return False
def write_json_into_file(data_json, filepath):
try:
with open(filepath, "w") as f:
data_str = json.dumps(data_json, indent=4)
f.write(data_str)
return True
except Exception as e:
LOG.error(str(e))
LOG.error("Write json into file failed")
return False
return
url_middle = mv_model['url_middle']
clipboard = QApplication.clipboard()
clipboard.setText(url_middle)
cls.view.ui.STATUS_BAR.showMessage(
u"程序已经将视频的播放地址复制到剪切板", 5000)
if platform.system() == "Linux":
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "正在尝试调用VLC视频播放器播放MV")
try:
subprocess.Popen(['vlc', url_middle, '--play-and-exit', '-f'])
except:
LOG.error('call vlc player failed')
elif platform.system().lower() == 'Darwin'.lower():
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "准备调用 QuickTime Player 播放mv")
try:
subprocess.Popen(
['open', '-a', 'QuickTime Player', url_middle])
except:
LOG.error('call quicktime player failed')
keyboard_tap_callback,
None
)
run_loop_source = Quartz.CFMachPortCreateRunLoopSource(
None, tap, 0)
Quartz.CFRunLoopAddSource(
Quartz.CFRunLoopGetCurrent(),
run_loop_source,
Quartz.kCFRunLoopDefaultMode
)
# Enable the tap
Quartz.CGEventTapEnable(tap, True)
# and run! This won't return until we exit or are terminated.
Quartz.CFRunLoopRun()
LOG.error('Mac hotkey event loop exit')
return []