本文整理汇总了Python中cache.Cache.quit方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.quit方法的具体用法?Python Cache.quit怎么用?Python Cache.quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache.Cache
的用法示例。
在下文中一共展示了Cache.quit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import quit [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.config = Config()
self.datatype = 'main'
self.title = '网易云音乐'
self.datalist = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '每日推荐', '私人FM', '搜索', '帮助']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database["user"]["user_id"]
self.username = self.storage.database["user"]["nickname"]
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def update_alert(self, version):
latest = Menu().check_version()
if latest != version and latest != 0:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "MusicBox Update is available"sound name "/System/Library/Sounds/Ping.aiff"\'')
time.sleep(0.5)
os.system('/usr/bin/osascript -e \'display notification "NetEase-MusicBox installed version:' + version + '\nNetEase-MusicBox latest version:' + latest + '"\'')
else:
os.system('/usr/bin/notify-send "MusicBox Update is available"')
def signin_alert(self, type):
if type == 0:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "Mobile signin success"sound name "/System/Library/Sounds/Ping.aiff"\'')
else:
os.system('/usr/bin/notify-send "Mobile signin success"')
else:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "PC signin success"sound name "/System/Library/Sounds/Ping.aiff"\'')
else:
os.system('/usr/bin/notify-send "PC signin success"')
def check_version(self):
# 检查更新 && 签到
try:
mobilesignin = self.netease.daily_signin(0)
if mobilesignin != -1 and mobilesignin['code'] != -2:
self.signin_alert(0)
time.sleep(0.5)
pcsignin = self.netease.daily_signin(1)
if pcsignin != -1 and pcsignin['code'] != -2:
self.signin_alert(1)
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version())))
root = tree.getroot()
return root[0][4][0][0].text
except:
return 0
def start_fork(self, version):
pid = os.fork()
if pid == 0:
Menu().update_alert(version)
else:
Menu().start()
def play_pause(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.next()
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import quit [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.datatype = 'main'
self.title = '网易云音乐'
self.datalist = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '打碟', '收藏', '搜索', '帮助']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = None
self.username = None
self.resume_play = True
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def start(self):
self.START = time.time() // 1
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step, self.START)
self.ui.build_process_bar(self.player.process_location, self.player.process_length, self.player.playing_flag,
self.player.pause_flag, self.storage.database['player_info']['playing_mode'])
self.stack.append([self.datatype, self.title, self.datalist, self.offset, self.index])
while True:
datatype = self.datatype
title = self.title
datalist = self.datalist
offset = self.offset
idx = index = self.index
step = self.step
stack = self.stack
djstack = self.djstack
self.screen.timeout(500)
key = self.screen.getch()
self.ui.screen.refresh()
# term resize
if key == -1:
self.ui.update_size()
self.player.update_size()
# 退出
if key == ord('q'):
break
# 退出并清除用户信息
if key == ord('w'):
self.storage.database['user'] = {
"username": "",
"password": "",
}
break
# 上移
elif key == ord('k'):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord('j'):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord('0') <= key <= ord('9'):
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
idx = key - ord('0')
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import quit [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding("UTF-8")
self.config = Config()
self.datatype = "main"
self.title = "网易云音乐"
self.datalist = ["排行榜", "艺术家", "新碟上架", "精选歌单", "我的歌单", "DJ节目", "每日推荐", "私人FM", "搜索", "帮助"]
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database["collections"][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database["user"]["user_id"]
self.username = self.storage.database["user"]["nickname"]
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def alert(self, version):
latest = Menu().check_version()
if latest != version:
if platform.system() == "Darwin":
os.system(
'/usr/bin/osascript -e \'display notification "MusicBox Update is available"sound name "/System/Library/Sounds/Ping.aiff"\''
)
time.sleep(0.5)
os.system(
"/usr/bin/osascript -e 'display notification \"NetEase-MusicBox installed version:"
+ version
+ "\nNetEase-MusicBox latest version:"
+ latest
+ "\"'"
)
else:
os.system('/usr/bin/notify-send "MusicBox Update is available"')
def check_version(self):
# 检查更新
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version())))
root = tree.getroot()
return root[0][4][0][0].text
def start_fork(self, version):
# Hong, Fork a child process.
# Return 0 in the child and the child’s process id in the parent.
pid = os.fork()
if pid == 0:
Menu().alert(version)
else:
Menu().start()
def play_pause(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.next()
time.sleep(0.1)
def previous_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.prev()
time.sleep(0.1)
def start(self):
# Hong, Return the time in seconds since the epoch as a floating point number.
self.START = time.time() // 1
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step, self.START)
#.........这里部分代码省略.........
示例4: Menu
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import quit [as 别名]
class Menu(object):
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.config = Config()
self.datatype = 'main'
self.title = 'NetEase Music'
self.datalist = ['Charts', 'Artists', 'New Songs', 'Songs', 'My Songs', 'Radio Stations', 'Recommended',
'Personal Radio', 'Search', 'Help']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database['user']['user_id']
self.username = self.storage.database['user']['nickname']
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def update_alert(self, version):
latest = Menu().check_version()
if latest != version and latest != 0:
notify('MusicBox Update is available', 1)
time.sleep(0.5)
notify('NetEase-MusicBox installed version:' + version +
'\nNetEase-MusicBox latest version:' + latest, 0)
def check_version(self):
# 检查更新 && 签到
try:
mobilesignin = self.netease.daily_signin(0)
if mobilesignin != -1 and mobilesignin['code'] != -2:
notify('Mobile signin success', 1)
time.sleep(0.5)
pcsignin = self.netease.daily_signin(1)
if pcsignin != -1 and pcsignin['code'] != -2:
notify('PC signin success', 1)
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version(
))))
root = tree.getroot()
return root[0][4][0][0].text
except TypeError as e:
log.error(e)
return 0
def start_fork(self, version):
pid = os.fork()
if pid == 0:
Menu().update_alert(version)
else:
Menu().start()
def _is_playlist_empty(self):
return len(self.storage.database['player_info']['player_list']) == 0
def play_pause(self):
if self._is_playlist_empty():
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if self._is_playlist_empty():
return
self.player.next()
time.sleep(0.5)
def previous_song(self):
if self._is_playlist_empty():
return
self.player.prev()
time.sleep(0.5)
#.........这里部分代码省略.........