The following code will create a GUI popup box that checks the voice mail count at a specified interval. It assumes that there is a linux/unix tmp directory. If you are going to use it in Windows, change the tmp directory path
In Linux
save file as
/usr/local/bin/viaTalkVMail.py
and use
chmod a+rx /usr/local/bin/viaTalkVMail.py
to make it executable.
Then type in an XWindow terminal prompt:
viaTalkVMail.py
If you get a wxPython error, you may not have it loaded.
Try:
yum install wxPython
If you don't have curl
Try:
yum install curl


#!/usr/bin/python
#
#Viatalk Dashboard using Python
#Check the number of outstanding voice mails on the Via Talk web site
#This program uses Curl to get the index page as seen after login.
#It uses a cookie file that is saved in the /tmp directory. 
#If you are going to use this on a PC, then change the directory.
#If the INBOX can't be found on the returned page, it is assumed that we are no longer logged in.
#Re re-login, recreating the cookie file then retry.
#This simple wxPython code contains examples of how to use panels, frames, tab order (Based on the order in which they are created), page layout formatting, timers, shell commands, and event calls (Timer, Button Press, and Text Box On Change events).
#It also contain examples of how to use Curl to access https web-sites with login screens in order to treat them like SOAP services.
#
# = Lee Lofgren and Accounting Enhancements, Inc
# = Accounting Enhancements, Inc
# = 2007
#In the original BSD license, both occurrences of the phrase "COPYRIGHT HOLDERS AND CONTRIBUTORS" in the disclaimer read "REGENTS AND CONTRIBUTORS".
#Copyright (c) 2007, Lee Lofgren and Accounting Enhancements, Inc
#All rights reserved.
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution (It can be a text file in the progam directory).
#    * Neither the name of the  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
#CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
#EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from wxPython.wx import *
import os, string

defaultMailCheckDelay=300 #Seconds

class Panel(wxPanel):
    def __init__(self, frame):
	self.currentlyChecking = 0
	self.delayPrevious=defaultMailCheckDelay
	wxPanel.__init__(self, frame, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
	
	self.frame = frame
	
	self.timer = wxPyTimer(self.Notify)
	
	self.col1 = wxBoxSizer(wxVERTICAL)
	self.col2 = wxBoxSizer(wxVERTICAL)
	self.row = wxBoxSizer(wxHORIZONTAL)
	
	self.col1.Add(wxStaticText(self, label="Delay Time (Sec):", size=wxSize(-1, 25)),  0, wxALIGN_RIGHT)
	self.col1.Add(wxStaticText(self, label="Phone Number:", size=wxSize(-1, 25)),  0, wxALIGN_RIGHT)
	self.col1.Add(wxStaticText(self, label="Password:", size=wxSize(-1, 25)),  0, wxALIGN_RIGHT)
	
	self.delay = wxTextCtrl(self, size=wxSize(150, 25), style=wxTE_PROCESS_ENTER)
	self.delay.SetValue(str(defaultMailCheckDelay))
	self.delay.Bind(EVT_TEXT, self.delayChange)
	self.col2.Add(self.delay, 0)
	self.phoneNum = wxTextCtrl(self, size=wxSize(150, 25))
	self.col2.Add(self.phoneNum, 0)
	self.passwd = wxTextCtrl(self, size=wxSize(150, 25))
	self.col2.Add(self.passwd ,0)
	self.check = wxButton(self, id=-1, label='Check Now')
	self.Bind(EVT_BUTTON, self.checkClick)
	self.col2.Add(self.check, 0, wxALIGN_LEFT)
		
	self.row.Add(self.col1, 0)
	self.row.AddSpacer((5,0))
	self.row.Add(self.col2,0)
	self.SetSizer(self.row)
	self.row.Fit(self)
	self.SetMinSize(self.row.GetMinSize())
	self.Fit()

	try:
		settingsFile=open('/tmp/viaTalkVMail.settings')
		self.delay.SetValue(settingsFile.readline().strip('\n'))
		self.phoneNum.SetValue(settingsFile.readline().strip('\n'))
		self.passwd.SetValue(settingsFile.readline().strip('\n'))
		settingsFile.close()
		self.Notify()
	except IOError:
		print "failed to load previous settings"
	
	if self.delay.GetValue()>0:
		self.timer.Start(int(self.delay.GetValue())*1000)
	
	self.SetFocus()

    def delayChange(self, event):
	if self.delay.GetValue().isdigit() == 0 :
		if self.delay.GetValue() != "":
			print "invalid character"
			self.delay.SetValue(self.delayPrevious)
	else:
		if int(self.delay.GetValue())<1 or str(int(self.delay.GetValue())) != self.delay.GetValue():
			print "invalid number"
			self.delay.SetValue(self.delayPrevious)
		else:
			if self.delay.GetValue() != "" and int(self.delay.GetValue())>1:
				self.timer.Stop()
				self.timer.Start(int(self.delay.GetValue())*1000)
				self.delayPrevious=self.delay.GetValue()
				print "new time"
				settingsFile=open('/tmp/viaTalkVMail.settings','w')
				settingsFile.write(self.delay.GetValue() + '\n')
				settingsFile.write(self.phoneNum.GetValue() + '\n')
				settingsFile.write(self.passwd.GetValue() + '\n')
				settingsFile.close()
	
    def checkClick(self, event):
	self.Notify()
	settingsFile=open('/tmp/viaTalkVMail.settings','w')
	settingsFile.write(self.delay.GetValue() + '\n')
	settingsFile.write(self.phoneNum.GetValue() + '\n')
	settingsFile.write(self.passwd.GetValue() + '\n')
	settingsFile.close()
	
    def Notify(self):
	if self.currentlyChecking == 1:
		self.SetStatusText("Messages: Already Checking...")
	else:
		self.currentlyChecking = 1
	        self.SetStatusText("Messages: Checking...")
		count = self.CheckViaTalk()
	        self.frame.SetStatusText("Messages: %s" % count)
		self.frame.SetTitle("%s: ViaTalk VoiceMail Check" % count)
		self.currentlyChecking = 0
	
    def SetStatusText(self, statusText):
	#I Created this so that we can refresh the screen and let the user know what is happening
	#since the CheckViaTalk() method can take awhile. Without the EventLoop code, the
	#screen would not get refreshed so there would be no point in sending a message through the StatusText
	self.frame.SetStatusText(statusText)
	eventloop=wxEventLoop() #refresh display by processing waiting events before returning to this one
        thisEvent=wxEventLoop.GetActive()
        wxEventLoop.SetActive(eventloop)
        while eventloop.Pending():
                    eventloop.Dispatch()
        wxEventLoop.SetActive(thisEvent)
	
    def CheckViaTalk(self):
	command = "curl -b /tmp/%s.cookie -L https://support.viatalk.com/billing/index.php 2>/dev/null" % self.phoneNum.GetValue()
	output = os.popen(command).read()
	index = output.find("INBOX")

	if index == -1:
		command = 'curl -c /tmp/%s.cookie -d "op=login&submit=submit&username=%s&password=%s" -L https://support.viatalk.com/billing/index.php>/dev/null 2>&1' % (self.phoneNum.GetValue(), self.phoneNum.GetValue(), self.passwd.GetValue())
		os.system(command)
		command = "curl -b /tmp/%s.cookie -L https://support.viatalk.com/billing/index.php 2>/dev/null" % self.phoneNum.GetValue()
		output = os.popen(command).read()
		index=output.find("INBOX")

	if index == -1:
		output = "Login Error (Bad userName, Password, or web-page layout has changed): CheckViaTalk() Method"
	else:
		start = output.find("",index)
		end = output.find(" - ",index)
		if start == -1 or end == -1:
			output = "Decode Error. Page format changed. Fix Progam to support new page layout: CheckViaTalk() Method"
		else:
			start+=4
			output = output[start:end]
	
	return output
	


	
class Frame(wxFrame):
    def __init__(self, parent):
	wxFrame.__init__(self, parent, -1, 'ViaTalk VoiceMail Check', wxDefaultPosition, wxDefaultSize)
	
	menu = wxMenu()
	idExit = wxNewId()
	menu.Append(idExit,"E&xit\tAlt-X","Close Program")
	menuBar = wxMenuBar()
	menuBar.Append(menu, "&File")
	self.SetMenuBar(menuBar)
	EVT_MENU(self, idExit, self.OnFileExit)
	EVT_CLOSE(self, self.OnCloseWindow)
	
	self.CreateStatusBar()
	self.SetStatusText("Messages: ??")
	self.panel = Panel(self)
	self.SetMinSize(self.panel.GetMinSize())
	self.Fit()
	self.Center()

    def OnFileExit(self, event):
	self.Close()
	
    def OnCloseWindow(self, event):
	self.panel.timer.Stop()
	del self.panel.timer
	self.panel.Destroy()
	self.Destroy()

class App(wxApp):
    def OnInit(self):
	frame = Frame(NULL)
	frame.Show(true)
	self.SetTopWindow(frame)
	return true


app = App(0)
app.MainLoop()