def notify_snarl(self, buff_str, title, wnd): # Title not supported yet # Icon path: icon_path = os.path.join(os.getcwd(), "icon.ico") title = 'Notification' if PySnarl.snGetVersion() != False: id = PySnarl.snShowMessage("Notification", buff_str, timeout=NOTIFY_TIMEOUT, iconPath=icon_path, replyWindow=wnd, replyMsg=win32con.WM_LBUTTONDOWN) # This isn't working; try TTM_RELAYEVENT
def __init__(self, username, password): self.username = username self.password = password self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) self.encode = urllib.urlencode if PySnarl.snGetVersion() != False: (major, minor) = PySnarl.snGetVersion() print ('Found Snarl version', str(major) + "." + str(minor), 'running.') else: print ("Sorry Snarl does not appear to be running")
def check(self): if waveNotifier.login(self.username, self.password): result = waveNotifier.readInbox() try: uri = 'file://' + os.path.abspath(os.path.curdir) + '/wave_logo.png' pynotify.Notification('Google Wave', 'You have %s unread blips' % (result[1]), uri).show() except NameError: pass try: PySnarl.snShowMessage('Google Wave', 'You have %s unread blips' % (result[1]), 5, iconPath = os.getcwd() + '\wave_logo.png') except NameError: print 'Unread blips: %s' % result[1]
def send(message, message_type): try: import PySnarl except ImportError: return 1 import pywintypes try: PySnarl.snGetSnarlWindow() except pywintypes.error: return 2 import os PySnarl.snShowMessage( message, _titles.get(message_type), timeout=_timeouts.get(message_type, 10), iconPath=os.path.abspath(_icons.get(message_type, 10)), ) return 0
def test0009snRegisterAlert(self): time.sleep(2) p = path(".").abspath() PySnarl.snRegisterConfig(self.frame.Handle, "unittest App", 0) a = PySnarl.snRegisterAlert("unittest App", "testcase") self.assert_(a == 0L) b = PySnarl.snShowMessageEx("testcase", "test", "test") self.assert_(b == 634L) c = PySnarl.snShowMessageEx("testcase", "test", "test", hWndFrom=self.frame.Handle) self.assert_(c == 635L) d = PySnarl.snShowMessageEx("testcase", "test", "test", hWndFrom=0) self.assert_(d == PySnarl.M_BAD_HANDLE) e = PySnarl.snShowMessageEx("testcase", "test", "test", hWndFrom=1) self.assert_(e == PySnarl.M_NOT_FOUND)
def test0010snRevokeConfig(self): time.sleep(2) PySnarl.snRegisterConfig(self.frame.Handle, "unittest App", 0) a = PySnarl.snRevokeConfig(self.frame.Handle) self.assert_(a == 0L) b = PySnarl.snRevokeConfig(self.frame.Handle) self.assert_(b == PySnarl.M_NOT_FOUND) c = PySnarl.snShowMessageEx("testcase", "test", "test") self.assert_(c == PySnarl.M_BAD_HANDLE) d = PySnarl.snShowMessageEx("testcase", "test", "test", hWndFrom=self.frame.Handle) self.assert_(d == PySnarl.M_NOT_FOUND)
def test0009snRegisterAlert(self): time.sleep(2) p = path('.').abspath() PySnarl.snRegisterConfig(self.frame.Handle, "unittest App", 0) a = PySnarl.snRegisterAlert("unittest App", "testcase") self.assert_(a == 0L) b = PySnarl.snShowMessageEx('testcase', 'test', 'test') self.assert_(b == 634L) c = PySnarl.snShowMessageEx('testcase', 'test', 'test', hWndFrom=self.frame.Handle) self.assert_(c == 635L) d = PySnarl.snShowMessageEx('testcase', 'test', 'test', hWndFrom=0) self.assert_(d == PySnarl.M_BAD_HANDLE) e = PySnarl.snShowMessageEx('testcase', 'test', 'test', hWndFrom=1) self.assert_(e == PySnarl.M_NOT_FOUND)
def test0010snRevokeConfig(self): time.sleep(2) PySnarl.snRegisterConfig(self.frame.Handle, "unittest App", 0) a = PySnarl.snRevokeConfig(self.frame.Handle) self.assert_(a == 0L) b = PySnarl.snRevokeConfig(self.frame.Handle) self.assert_(b == PySnarl.M_NOT_FOUND) c = PySnarl.snShowMessageEx('testcase', 'test', 'test') self.assert_(c == PySnarl.M_BAD_HANDLE) d = PySnarl.snShowMessageEx('testcase', 'test', 'test', hWndFrom=self.frame.Handle) self.assert_(d == PySnarl.M_NOT_FOUND)
def test0003versionexstart(self): a = PySnarl.snGetVersionEx() self.assert_(type(a) == int or type(a) == long)
def test0004versionexstopped(self): self.stopSnarl() self.assert_(PySnarl.snGetVersionEx() == False)
def test0001versionstarted(self): (a, b) = PySnarl.snGetVersion() self.assert_(type(a) == int or type(a) == long) self.assert_(type(b) == int or type(b) == long)
def test0002versionstopped(self): self.stopSnarl() self.assert_(PySnarl.snGetVersion() == False)
def test0007snRegisterConfig(self): time.sleep(2) a = PySnarl.snRegisterConfig(self.frame.Handle, "unittest App", 0) self.assert_(a == 0L)
#! /usr/bin/python # -*- coding: utf-8 -*- import PySnarl import time #snGetVersion tells you if Snarl is alive if PySnarl.snGetVersion() != False: #Get Version gives you the major and minor version numbers of the running snarl (major, minor) = PySnarl.snGetVersion() print "Found Snarl version", str(major) + "." + str(minor), "running." #Show a message, otherwise snarl is useless id = PySnarl.snShowMessage("Test Message", "Hello World!") time.sleep(2) #wait and then update message for the fun of it PySnarl.snUpdateMessage(id, "Test 2", "Hello Snarl!") #If the message is still visible, set a timeout for it to go away if PySnarl.snIsMessageVisible(id): PySnarl.snSetTimeout(id, 2) #timeout can be set inline and unicode can be sent. id = PySnarl.snShowMessage('Test Unicode', u'привет мир', timeout=5) else: print "Sorry Snarl does not appear to be running"
def test0005snShowMessage(self): time.sleep(2) a = PySnarl.snShowMessage("test", "test") self.assert_(a == 633L) a = PySnarl.snShowMessage("test", "test") self.assert_(a == 634L)
def setUp(self): self.startSnarl() self.msg = PySnarl.SnarlMessage() self.app = wx.PySimpleApp() self.frame = wx.Frame(None, wx.ID_ANY, "Hello World")
def test0008snRegisterConfig2(self): time.sleep(2) p = path('.').abspath() a = PySnarl.snRegisterConfig2(self.frame.Handle, "unittest App", 0, p + "general.png") self.assert_(a == 0L)
def test0006snShowMessageStopped(self): self.stopSnarl() a = PySnarl.snShowMessage("test", "test") self.assert_(a == False)
def snarl(self, title, body, icon): PySnarl.snShowMessage(title, body, timeout = 5, iconPath = icon)
def test0008snRegisterConfig2(self): time.sleep(2) p = path(".").abspath() a = PySnarl.snRegisterConfig2(self.frame.Handle, "unittest App", 0, p + "general.png") self.assert_(a == 0L)
def player(path, start_from=1): debug.debug(start_from=start_from) #print "path =", os.path.abspath(path) IS_PLAYER = '' coverart = '' listdir = [] for root, dirs, files in os.walk(os.path.abspath(path)): if len(files) > 0: for i in files: if os.path.splitext(i)[1].strip() == '.mp3': listdir.append(os.path.join(root, i)) if os.path.splitext(i)[1].strip() == '.wav': listdir.append(os.path.join(root, i)) if os.path.splitext(i)[1].strip() == '.m4a': listdir.append(os.path.join(root, i)) if os.path.splitext(i)[1].strip() == '.mp4': listdir.append(os.path.join(root, i)) #if i.endswith(".mp3") or i.endswith(".m4a") or i.endswith(".wav"): #listdir.append(os.path.join(root, i)) debug.debug(listdir=listdir) for i in listdir[(start_from - 1):]: tags, coverart = get_tag(i, True) #debug.debug(tags) debug.debug(coverart=coverart) if not coverart: coverart = getCover(i) if tags: try: #if os.path.splitext(i)[1] == '.mp3': length, tag, mp3tag, id3tag = getTag(i) #duration = str(datetime.timedelta(seconds = float(length))) length = int(tags.duration) except: mp3tag = '' if not mp3tag: comment = '' else: comment = mp3tag.get('COMM::eng') duration = str(datetime.timedelta(seconds=float(tags.duration))) #if tags: #print "send Notify" msg = """ Album : {0} Artist : {1} Album Artist : {2} Disc : {3}/{4} Genre : {5} Duration : {6} Bitrate : {7} Year : {8} Comment : {9}""".format( unicode(tags.album).encode('UTF-8'), unicode(tags.artist).encode('UTF-8'), unicode(tags.albumartist).encode('UTF-8'), unicode(tags.disc).encode('UTF-8'), unicode(tags.disc_total).encode('UTF-8'), unicode(tags.genre).encode('UTF-8'), unicode(duration).encode('UTF-8'), unicode(tags.bitrate).encode('UTF-8'), unicode(tags.year).encode('UTF-8'), unicode(comment).encode('UTF-8')) #format(unicode(album).encode('UTF-8'), unicode(artist).encode('UTF-8'), unicode(albumartist).encode('UTF-8'), unicode(comment).encode('UTF-8')) try: title = "{0}/{1}/{2}/{3}. {4}".format( tags.track, tags.track_total, tags.disc, tags.disc_total, unicode(tags.title).encode('UTF-8')) except: if tag: try: title = "{0}. {1}".format( tag.get('tracknumber')[0], tag.get('title')[0]) except: title = "{0}. {1}".format(tag.get('tracknumber'), tag.get('title')[0]) else: msg = 'No IDTag' title = os.path.basename(i) debug.debug(coverart_final=coverart) if not os.path.isfile(coverart): coverart = r'F:\ICONS\Phuzion_Icon_Pack\PNG\Devices\Headphones2.png' sendnotify(msg, title, coverart, "Playing") #print "coverart =", coverart try: snarl.snShowMessage(title, msg, 20, coverart) except: pass if length > 0: pbar = ProgressBar(widgets=widgets, max_value=length) pbar.start() print "play %s ... [%s ~ %s]" % (os.path.basename(i), str(length), str(os.getpid())) if os.path.isfile(PLAYER0): a = subprocess.Popen([PLAYER0, i]) IS_PLAYER = os.path.basename(os.path.splitext(PLAYER0)[0]) else: if os.path.splitext(i)[1].strip() == '.mp3': if os.path.isfile(PLAYER1): a = subprocess.Popen([PLAYER1, i]) IS_PLAYER = os.path.basename(os.path.splitext(PLAYER1)[0]) else: a = playing2(i) if a == False: sys.exit(0) if os.path.splitext(i)[1].strip() == '.m4a' or os.path.splitext( i)[1].strip() == '.mp4': a = playing(i) if a == False: sys.exit(0) if os.path.splitext(i)[1].strip() == '.wav': a = playing2(i) if a == False: sys.exit(0) n = 1 if not IS_PLAYER.lower( ) == 'fmedia' or not 'fmedia' in IS_PLAYER.lower(): try: while 1: if a.poll() == 0: pbar.finish() break else: time.sleep(1) if length > 0: if n > length: pbar.finish() break else: pbar.update(n) n += 1 #m +=1 #if m == 20: # sendnotify(msg, title, coverart, 'Play Monitoring') # snarl.snShowMessage(title, msg, 20, coverart) # m = 1 except KeyboardInterrupt: pbar.finish() except: #print "error =", traceback.format_exc() sys.exit(0) else: try: while 1: if a.poll() == 0: break else: time.sleep(1) except KeyboardInterrupt: os.kill(a.pid, a.pid) except: sys.exit(0)
#! /usr/bin/python import PySnarl if PySnarl.snGetVersion() != False: (major, minor) = PySnarl.snGetVersion() print "Found Snarl version",str(major)+"."+str(minor),"running." PySnarl.snShowMessage("Test Message", "Hello World!") else: print "Sorry Snarl does not appear to be running"
#! /usr/bin/python import PySnarl if PySnarl.snGetVersion() != False: (major, minor) = PySnarl.snGetVersion() print("Found Snarl version",str(major)+"."+str(minor),"running.") PySnarl.snShowMessage("Test Message", "Hello World!") else: print("Sorry Snarl does not appear to be running")
def snarlShowMessage(self, title, msg, image=''): id = PySnarl.snShowMessage(title, msg, timeout=15, iconPath=image)