本文整理汇总了Python中winsound.PlaySound方法的典型用法代码示例。如果您正苦于以下问题:Python winsound.PlaySound方法的具体用法?Python winsound.PlaySound怎么用?Python winsound.PlaySound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类winsound
的用法示例。
在下文中一共展示了winsound.PlaySound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_scan
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def do_scan(crawling):
while 1:
try:
crawling = tocrawl.pop()
# print crawling
except KeyError:
sys.exit(1)
url = urlparse.urlparse(crawling)
try:
response = urllib2.urlopen(crawling)
except urllib2.HTTPError, e:
continue
except urllib2.URLError, e:
log_file = "sqli.txt"
FILE = open(log_file, "a")
FILE.write(crawling)
FILE.close()
print "\n================================================================================"
print "\t\tBlind MySQL Injection Detected"
print crawling
print "\n===============================================================================\n"
winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS)
time.sleep(10)
continue
示例2: writeRiskLog
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def writeRiskLog(self, content):
"""快速发出日志事件"""
# 发出报警提示音
if platform.uname() == 'Windows':
import winsound
winsound.PlaySound("SystemHand", winsound.SND_ASYNC)
# 发出日志事件
log = VtLogData()
log.logContent = content
log.gatewayName = self.name
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
# ----------------------------------------------------------------------
示例3: _pyaudio_play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def _pyaudio_play(name):
if not name:
return
if pyaudio is None:
# Raise an error because pyaudio isn't installed.
raise RuntimeError("pyaudio must be installed to use PlaySound "
"on this platform")
# Play the wave file.
pa = _get_pa_instance()
chunk = 1024
wf = wave.open(name, 'rb')
stream = pa.open(format=pa.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(), rate=wf.getframerate(),
output=True)
data = wf.readframes(chunk)
while data:
stream.write(data)
data = wf.readframes(chunk)
stream.stop_stream()
stream.close()
pa.terminate()
示例4: writeRiskLog
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def writeRiskLog(self, content):
"""快速发出日志事件"""
# 发出报警提示音
if platform.uname() == 'Windows':
import winsound
winsound.PlaySound("SystemHand", winsound.SND_ASYNC)
# 发出日志事件
log = VtLogData()
log.logContent = content
log.gatewayName = self.name
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
#----------------------------------------------------------------------
示例5: textPlay
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def textPlay():
f = open("output.txt", "r")
text = f.read()
# Language in which you want to convert
language = 'en'
# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed
myobj = gTTS(text=text, lang=language, slow=False)
myobj.save("welcome.wav")
'''
print('Playing')
winsound.PlaySound("This is real this is me",winsound.SND_FILENAME)
pygame.init()
t= pygame.mixer.Sound("welcome.wav")
t.play()'''
os.system("start welcome.wav")
示例6: test_stopasync
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def test_stopasync(self):
if _have_soundcard():
winsound.PlaySound(
'SystemQuestion',
winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
)
time.sleep(0.5)
try:
winsound.PlaySound(
'SystemQuestion',
winsound.SND_ALIAS | winsound.SND_NOSTOP
)
except RuntimeError:
pass
else: # the first sound might already be finished
pass
winsound.PlaySound(None, winsound.SND_PURGE)
else:
self.assertRaises(
RuntimeError,
winsound.PlaySound,
None, winsound.SND_PURGE
)
示例7: play_sound
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def play_sound(sound, async_=True):
if sound in sound_mappings: sound = sound_mappings[sound]
winsound.PlaySound(sound, winsound.SND_FILENAME | (winsound.SND_ASYNC if async_ else 0))
# --------------------------------------------------------------------------
# Sleep/wake grammar.
示例8: play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def play(self, **kwargs):
sound_path = os.path.join(self.dir, '{}.wav'.format(kwargs['command']))
if sublime.platform() == "osx":
if os.path.isfile(sound_path):
call(["afplay", "-v", str(1), sound_path])
if sublime.platform() == "windows":
if os.path.isfile(sound_path):
winsound.PlaySound(sound_path, winsound.SND_FILENAME | winsound.SND_ASYNC | winsound.SND_NODEFAULT)
if sublime.platform() == "linux":
if os.path.isfile(sound_path):
call(["aplay", sound_path])
示例9: worker
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def worker(self, keycode, modifiers):
# Hotkey must be registered by the thread that handles it
if not RegisterHotKey(None, 1, modifiers|MOD_NOREPEAT, keycode):
self.thread = None
return
fake = INPUT(INPUT_KEYBOARD, INPUT_union(ki = KEYBDINPUT(keycode, keycode, 0, 0, None)))
msg = MSG()
while GetMessage(ctypes.byref(msg), None, 0, 0) != 0:
if msg.message == WM_HOTKEY:
if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'):
self.root.event_generate('<<Invoke>>', when="tail")
else:
# Pass the key on
UnregisterHotKey(None, 1)
SendInput(1, fake, ctypes.sizeof(INPUT))
if not RegisterHotKey(None, 1, modifiers|MOD_NOREPEAT, keycode):
break
elif msg.message == WM_SND_GOOD:
winsound.PlaySound(self.snd_good, winsound.SND_MEMORY) # synchronous
elif msg.message == WM_SND_BAD:
winsound.PlaySound(self.snd_bad, winsound.SND_MEMORY) # synchronous
else:
TranslateMessage(ctypes.byref(msg))
DispatchMessage(ctypes.byref(msg))
UnregisterHotKey(None, 1)
self.thread = None
示例10: dns_lookup
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def dns_lookup(address):
subprocess.call("ipconfig /flushdns", stdout=False, stderr=False)
query = socket.getaddrinfo(address, 80)
query = ".".join([str(x) for x in query])
query = query.split("'")[3]
print address, "-", query
date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")
if os.path.isfile("history.txt"):
FILE = open ("history.txt","r" )
entries = FILE.readlines()
FILE.close()
lastentry = entries[-1].split("|")[1]
if debug:
print query.strip, lastentry
print address.strip().lower(), entries[-1].split("|")[0].strip().lower()
if (address.strip().lower() == entries[-1].split("|")[0].strip().lower()):
if query.strip() != lastentry.strip():
print "DNS Change Detected! (Old: %s - New: %s)\n" %(lastentry.strip(), query)
winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS)
line = address + "|" + query + "|" + date + "\n"
FILE = open("history.txt", "a")
FILE.writelines(line)
FILE.close()
else:
line = address + "|" + query + "|" + date + "\n"
FILE = open("history.txt", "w")
FILE.writelines(line)
FILE.close()
示例11: play_trade
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def play_trade(self, event):
"""播放交易声音"""
# 1.获取事件的Trade数据
trade = event.dict_['data']
winsound.PlaySound('warn.wav', winsound.SND_ASYNC)
########################################################################
示例12: updateWarning
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def updateWarning(self, event):
"""更新相关Warning """
log = event.dict_['data']
content = '\t'.join([log.logTime, log.logContent])
self.logMonitor.append(content)
winsound.PlaySound('err.wav', winsound.SND_ASYNC)
# ----------------------------------------------------------------------
示例13: updateError
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def updateError(self, event):
"""更新相关Error """
log = event.dict_['data']
content = '\t'.join([log.errorTime, log.errorID,log.errorMsg,log.additionalInfo])
self.logMonitor.append(content)
winsound.PlaySound('err.wav', winsound.SND_ASYNC)
# ----------------------------------------------------------------------
示例14: _execute
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def _execute(self, data=None):
if os.name == 'nt':
# Play the file or sound using the Windows API.
winsound.PlaySound(self._name, self._flags)
else:
# Play the file with pyaudio.
_pyaudio_play(self._name)
示例15: warn
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import PlaySound [as 别名]
def warn(self):
winsound.PlaySound(self.snd_warn, winsound.SND_ASYNC)