Thought I share something from my projects. So this is just a simple program launch teamviewer from subprocess call. Since my free teamviewer account keeps getting error message "Commercial use suspected" just nuked the whole thing and started using this
#!/usr/bin/python
import wx
import wx.xrc
import subprocess
import platform
import os
class Py_Frame ( wx.Frame ):
# Initialize the Frame
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"TeamViewer ID Manager", pos = wx.DefaultPosition, size = wx.Size( 303,72 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer1 = wx.BoxSizer( wx.VERTICAL )
bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
# Read the Config file which contain connection informations.
ph_file = open("Py_Config.ini")
ph_content = ph_file.read().strip()
ph_file.close()
# Initialize the connection names into a list.
ph_nodes = ph_content.split("\n")
ph_array = [ x.split(" ") for x in ph_nodes ]
ph_name = [ x[0] for x in ph_array ]
self.ph_arr = ph_array
self.m_comboBox2 = wx.ComboBox( self, wx.ID_ANY, u"Desktop Names", wx.DefaultPosition, wx.DefaultSize, ph_name, 0 )
bSizer2.Add( self.m_comboBox2, 1, wx.ALL, 5 )
self.m_button1 = wx.Button( self, wx.ID_ANY, u"Launch", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer2.Add( self.m_button1, 0, wx.ALL, 5 )
bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
self.SetSizer( bSizer1 )
self.Layout()
self.Centre( wx.BOTH )
# Connect Events
self.m_button1.Bind( wx.EVT_BUTTON, self.Py_LaunchClick )
def __del__( self ):
pass
# Button click event handler.
def Py_LaunchClick( self, event ):
ph_selected = self.m_comboBox2.GetSelection()
if (ph_selected == -1):
dlg = wx.MessageDialog( None, "You Didn't select the PC.", "No Selection", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
else:
if platform.platform().startswith("Win"):
prog_32 = os.environ["ProgramW6432"].replace("\\","/")
prog_64 = os.environ["ProgramFiles(x86)"].replace("\\","/")
tv_path = "/TeamViewer/TeamViewer.exe"
if os.path.exists(prog_32 + tv_path):
subprocess.call(prog_32 + tv_path +" -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])
elif os.path.exists(prog_64 + tv_path):
subprocess.call(prog_64 + tv_path +" -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])
else:
dlg = wx.MessageDialog( None, "Couldn't detect TeamViewer'.", "Path Error", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
else:
subprocess.call("teamviewer -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])
if __name__ == "__main__":
app = wx.App()
frame = Py_Frame(None)
frame.Show()
app.MainLoop()
Py_Config.ini looks like this. Connection name, ID and Password
JoePC 111111111 password
BobPC 222222222 password
Hope this help some people out as well.