The following code will create a GUI popup box that Can Check, Set, and Clear the Forward Phone Number. 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/viaTalkForward.py
and use
chmod a+rx /usr/local/bin/viaTalkForward.py
to make it executable.
Then type in an XWindow terminal prompt:
viaTalkForward.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
#Update or clear the forward number 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 "callforward" 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, shell commands, and event calls (Button Press).
#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

class Panel(wxPanel):
    def __init__(self, frame):
	wxPanel.__init__(self, frame, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
	
	self.frame = frame
	
	self.col1 = wxBoxSizer(wxVERTICAL)
	self.col2 = wxBoxSizer(wxVERTICAL)
	self.row = wxBoxSizer(wxHORIZONTAL)
	self.buttons = wxBoxSizer(wxHORIZONTAL)
	
	self.col1.Add(wxStaticText(self, label="Phone Number:", size=wxSize(125, 25), style=wxALIGN_RIGHT))
	self.col1.Add(wxStaticText(self, label="Password:", size=wxSize(125, 25), style=wxALIGN_RIGHT))
	self.col1.Add(wxStaticText(self, label="Forward Number:", size=wxSize(125, 25), style=wxALIGN_RIGHT))
	
	self.phoneNum = wxTextCtrl(self, size=wxSize(165, 25))
	self.col2.Add(self.phoneNum, 0)
	
	self.passwd = wxTextCtrl(self, size=wxSize(165, 25))
	self.col2.Add(self.passwd ,0)
	
	self.forwardNum = wxTextCtrl(self, size=wxSize(165, 25))
	self.col2.Add(self.forwardNum, 0)
	
	#-----------------
	self.setButton = wxButton(self, id=-1, label=' Set ', size=wxSize(55,30))
	self.setButton.Bind(EVT_BUTTON, self.setButtonClick)
	self.buttons.Add(self.setButton, 0, wxALIGN_CENTER_HORIZONTAL)
	
	self.clearButton = wxButton(self, id=-1, label='Clear', size=wxSize(55,30))
	self.clearButton.Bind(EVT_BUTTON, self.clearButtonClick)
	self.buttons.Add(self.clearButton, 0, wxALIGN_CENTER_HORIZONTAL)
	
	self.checkButton = wxButton(self, id=-1, label='Check', size=wxSize(55,30))
	self.checkButton.Bind(EVT_BUTTON, self.checkButtonClick)
	self.buttons.Add(self.checkButton, 0, wxALIGN_CENTER_HORIZONTAL)
	#-----------------
	
	self.col2.Add(self.buttons,0)
	
	self.row.Add(self.col1, 0)
	self.row.AddSpacer((5,0))
	self.row.Add(self.col2,0)
	self.SetSizer(self.row)
	self.SetMinSize(self.row.GetMinSize())
	self.Fit()

	try:
		settingsFile=open('/tmp/viaTalkForward.settings')
		self.phoneNum.SetValue(settingsFile.readline().strip('\n'))
		self.passwd.SetValue(settingsFile.readline().strip('\n'))
		self.forwardNum.SetValue(settingsFile.readline().strip('\n'))
		settingsFile.close()
		if self.phoneNum.GetValue() != "":
			self.viaTalkForward("")
	except IOError:
		print "failed to load previous settings"
	
	
	self.SetFocus()

    def setButtonClick(self, event):
	self.viaTalkForward("set")
	settingsFile=open('/tmp/viaTalkForward.settings','w')
	settingsFile.write(self.phoneNum.GetValue() + '\n')
	settingsFile.write(self.passwd.GetValue() + '\n')
	settingsFile.write(self.forwardNum.GetValue() + '\n')
	settingsFile.close()
	
    def clearButtonClick(self, event):
	self.viaTalkForward("clear")
	settingsFile=open('/tmp/viaTalkForward.settings','w')
	settingsFile.write(self.phoneNum.GetValue() + '\n')
	settingsFile.write(self.passwd.GetValue() + '\n')
	settingsFile.write(self.forwardNum.GetValue() + '\n')
	settingsFile.close()

    def checkButtonClick(self, event):
	self.viaTalkForward("")
	settingsFile=open('/tmp/viaTalkForward.settings','w')
	settingsFile.write(self.phoneNum.GetValue() + '\n')
	settingsFile.write(self.passwd.GetValue() + '\n')
	settingsFile.write(self.forwardNum.GetValue() + '\n')
	settingsFile.close()
	
	
    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 viaTalkForward(self, action):
	#If action = clear, then clear the forward
	#If action = set then set the forward
	#Otherwise, just check the status
	
        self.SetStatusText("Changing settings...")
	
	if action == "set":
		command = 'curl -b /tmp/' + self.phoneNum.GetValue() + '.cookie -L "https://support.viatalk.com/billing/user.php?op=menu&tile=callforward&number=' + self.phoneNum.GetValue() + '&forward_number=' + self.forwardNum.GetValue() + '" 2>/dev/null'
	else:
		if action == "clear":
			command = 'curl -b /tmp/' + self.phoneNum.GetValue() + '.cookie -L "https://support.viatalk.com/billing/user.php?op=menu&tile=callforward&number=' + self.phoneNum.GetValue() + '&clear=Clear" 2>/dev/null'
		
		else:
			command = 'curl -b /tmp/%s.cookie -L "https://support.viatalk.com/billing/user.php?op=menu&tile=callforward" 2>/dev/null' % self.phoneNum.GetValue()

	output = unicode(str(os.popen(command).read()), errors='ignore')
	index=output.find("callforward")

	if index == -1:
		loginCommand = '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(loginCommand)
		#Now retry
		output = unicode(str(os.popen(command).read()), errors='ignore')
		index=output.find("callforward")

	if index == -1:
		output = "Login Error (Bad userName, Password, or web-page layout has changed): CheckForwardStatus() Method"
	else:
		start = output.find(self.phoneNum.GetValue(),index)
		end = -1
		if start > -1:
			end = output.find("",start)
			if end == -1:
				end = output.find("",index)
		if end > -1:
			output = output[start:end]
			start = output.find("")
			if start > -1:
				index = start + 10
				start = output.find(">",index)
				if start > -1:
					end = output.find("<",start)
		if start == -1 or end == -1:
			output = "Decode Error. Page format changed. Fix Program to support new page layout: CheckForwardStatus() Method"
		else:
			start+=1
			if end - start < 10:
				output = "Not Forwarded"
			else:
				output = output[start:end]
        
	self.frame.SetStatusText("viaTalkForward: %s" % output)
	self.frame.SetTitle("viaTalkForward: %s" % 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("viaTalkForward: NotChecked")
	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.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()