本文整理汇总了Python中settings.Settings.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get_instance方法的具体用法?Python Settings.get_instance怎么用?Python Settings.get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.get_instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapped
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
profile = Profile.get_instance()
settings = Settings.get_instance()
if file_type == TOX_FILE_KIND['DATA']:
print 'file'
try:
file_name = unicode(file_name[:file_name_size].decode('utf-8'))
except:
file_name = u'toxygen_file'
invoke_in_main_thread(profile.incoming_file_transfer,
friend_number,
file_number,
size,
file_name)
if not window.isActiveWindow():
friend = profile.get_friend_by_number(friend_number)
if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
invoke_in_main_thread(tray_notification, 'File from ' + friend.name, file_name, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER'])
else: # AVATAR
print 'Avatar'
invoke_in_main_thread(profile.incoming_avatar,
friend_number,
file_number,
size)
示例2: wrapped
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
profile = Profile.get_instance()
settings = Settings.get_instance()
if file_type == TOX_FILE_KIND['DATA']:
print('File')
try:
file_name = str(file_name[:file_name_size], 'utf-8')
except:
file_name = 'toxygen_file'
invoke_in_main_thread(profile.incoming_file_transfer,
friend_number,
file_number,
size,
file_name)
if not window.isActiveWindow():
friend = profile.get_friend_by_number(friend_number)
if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY'] and not settings.locked:
file_from = QtGui.QApplication.translate("Callback", "File from", None, QtGui.QApplication.UnicodeUTF8)
invoke_in_main_thread(tray_notification, file_from + ' ' + friend.name, file_name, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER'])
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png'))
else: # AVATAR
print('Avatar')
invoke_in_main_thread(profile.incoming_avatar,
friend_number,
file_number,
size)
示例3: friend_request
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def friend_request(tox, public_key, message, message_size, user_data):
"""
Called when user get new friend request
"""
print('Friend request')
profile = Profile.get_instance()
key = ''.join(chr(x) for x in public_key[:TOX_PUBLIC_KEY_SIZE])
tox_id = bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
if tox_id not in Settings.get_instance()['blocked']:
invoke_in_main_thread(profile.process_friend_request, tox_id, str(message, 'utf-8'))
示例4: friend_status
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def friend_status(tox, friend_num, new_status, user_data):
"""
Check friend's status (none, busy, away)
"""
print "Friend's #{} status changed! New status: {}".format(friend_num, new_status)
profile = Profile.get_instance()
friend = profile.get_friend_by_number(friend_num)
if friend.status is None and Settings.get_instance()['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FRIEND_CONNECTION_STATUS'])
invoke_in_main_thread(friend.set_status, new_status)
invoke_in_main_thread(profile.update_filtration)
示例5: friend_connection_status
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def friend_connection_status(tox, friend_num, new_status, user_data):
"""
Check friend's connection status (offline, udp, tcp)
"""
print "Friend #{} connected! Friend's status: {}".format(friend_num, new_status)
profile = Profile.get_instance()
friend = profile.get_friend_by_number(friend_num)
if new_status == TOX_CONNECTION['NONE']:
invoke_in_main_thread(friend.set_status, None)
invoke_in_main_thread(profile.update_filtration)
if Settings.get_instance()['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FRIEND_CONNECTION_STATUS'])
elif friend.status is None:
invoke_in_main_thread(profile.send_avatar, friend_num)
示例6: sigint_handler
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def sigint_handler(*args):
"""Handler for the SIGINT signal."""
sys.stderr.write('\r')
from settings import Settings
s = Settings.get_instance()
try:
show_dialog = bool(s.get_setting("show_shutdown_dialog", True))
except ValueError:
s.set_setting("show_shutdown_dialog", True)
show_dialog = True
if show_dialog:
if QMessageBox.question(None, 'Stopping', "Are you sure you want to quit?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) == QMessageBox.Yes:
QApplication.quit()
else:
QApplication.quit()
示例7: get_beatmap_by_hash
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_instance [as 别名]
def get_beatmap_by_hash(map_hash):
settings = Settings.get_instance()
payload = {
'k': settings.get_setting("osu_api_key"),
'h': map_hash
}
r = requests.get('https://osu.ppy.sh/api/get_beatmaps', params=payload)
result = r.json()
log = logging.getLogger(__name__)
if result:
log.debug("Matched {} to {} - {} [{}] ({})".format(map_hash,
result[0]['artist'],
result[0]['title'],
result[0]['version'],
result[0]['creator']))
else:
log.debug("Could not match {}".format(map_hash))
return r.json()