gitso

gitso Commit Details


Date:2008-10-23 16:29:42 (16 years 1 month ago)
Author:gerberad
Branch:master
Commit:8e5e59d624ab10c723f26cd4d3580cc2aae023ac
Parents: dca37ca3c0134c60643553f63054f15cd29c5304
Message:Updated working threads on Linux. Timing issues arose and are fixed on my system, but should pay attention on other systems.

Changes:

File differences

gitso/trunk/ConnectionWindow.py
11
22
33
4
4
55
66
77
......
1818
1919
2020
21
2122
22
23
24
2325
2426
2527
2628
29
30
2731
2832
2933
34
35
3036
3137
3238
3339
34
3540
3641
3742
3843
3944
4045
41
42
43
44
45
46
47
4846
4947
5048
......
8381
8482
8583
86
8784
8885
8986
......
104101
105102
106103
107
108
109
104
105
106
110107
111108
112109
......
124121
125122
126123
124
127125
128126
127
129128
130129
131130
......
138137
139138
140139
141
142
143
140
144141
145142
146143
......
153150
154151
155152
156
157
158
153
154
159155
160
156
161157
162
163
164
165
166
167
158
159
160
161
168162
169163
170164
......
229223
230224
231225
232
233
234
235
226
227
228
229
230
236231
237232
238233
239234
240
235
236
237
238
241239
242240
243241
......
270268
271269
272270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#! /usr/bin/env python
import wx
import os, sys, signal, os.path
import os, sys, signal, os.path, time, thread
import AboutWindow, GitsoThread
class ConnectionWindow(wx.Frame):
@author: Derek Buranen
@author: Aaron Gerber
"""
self.ToggleValue = 0
self.paths = paths
self.thread = GitsoThread.GitsoThread(self, self.paths)
self.thread = None
self.threadLock = thread.allocate_lock()
if sys.platform.find('linux') != -1:
width = 165
height = 350
xval1 = 155
xval2 = 250
else:
height = 350
width = 175
xval1 = 180
xval2 = 265
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(height,width), style=wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
# I don't know if this works in OS X
icon = wx.Icon(os.path.join(self.paths['main'], 'icon.ico'), wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
if sys.platform == 'win32':
self.SetBackgroundColour(wx.Colour(236,233,216))
if sys.platform.find('linux') != -1:
xval1 = 155
xval2 = 250
else:
xval1 = 180
xval2 = 265
#Buttons
self.connectButton = wx.Button(self, 10, "Start", wx.Point(xval1, 70))
wx.EVT_BUTTON(self, 10, self.ConnectSupport)
fileMenu.Append(13, "&Clear History", "Clear History")
if sys.platform == 'darwin':
#OS X deals with the help and file menu in wonky way.
fileMenu.Append(wx.ID_ABOUT, "&About", "About Gitso")
wx.EVT_MENU(self, wx.ID_ABOUT, self.ShowAbout)
else:
self.SetMenuBar(menuBar)
self.statusBar = self.CreateStatusBar(2)
self.statusBar.SetStatusText("Status:", 0)
self.statusBar.SetStatusWidths([50, 300])
self.statusBar = self.CreateStatusBar(1)
self.statusBar.SetStatusWidths([350])
self.setMessage("Idle", False)
self.SetDefaultItem(self.hostField)
self.hostField.SetFocus()
@author: Aaron Gerber
"""
if self.rb1.GetValue():
self.ToggleValue = 0
self.hostField.Enable(True)
else:
self.ToggleValue = 1
self.hostField.Enable(False)
"""
if self.rb1.GetValue(): # Get Help
if self.validHost(self.hostField.GetValue().strip()) and self.hostField.GetValue() != "Enter/Select Support Address":
self.connectButton.Enable(False)
self.stopButton.Enable(True)
self.statusBar.SetStatusText("Started", 1)
self.setMessage("Connecting...", True)
host = self.hostField.GetValue().strip()
self.sampleList.append(host)
self.hostField.Destroy()
self.displayHostBox(self.sampleList, host)
self.thread.setHost(host)
self.thread.start()
self.createThread(host)
else:
self.statusBar.SetStatusText("Invalid Support Address", 1)
self.setMessage("Invalid Support Address", False)
else: # Give Suppport
self.connectButton.Enable(False)
self.stopButton.Enable(True)
self.statusBar.SetStatusText("Started", 1)
self.thread.start()
self.setMessage("Starting Server...", True)
self.createThread()
def ShowAbout(self,e):
"""
Display About Dialog
@author: Derek Buranen
@author: Aaron Gerber
"""
self.thread.kill()
self.connectButton.Enable(True)
self.stopButton.Enable(False)
self.statusBar.SetStatusText("Idle", 1)
if self.thread <> None:
self.thread.kill()
time.sleep(.5)
self.thread = None
self.setMessage("Idle.", False)
return
def OnCloseWindow(self, evt):
self.KillPID(self)
if self.thread <> None:
self.thread.kill()
time.sleep(.5)
self.thread = None
self.Destroy()
self.hostField = wx.ComboBox(self, 30, "", wx.Point(105, 12), wx.Size(230, -1), list, wx.CB_DROPDOWN)
self.hostField.SetValue(text)
def setMessage(self, message, status):
self.threadLock.acquire()
self.statusBar.SetStatusText(message, 0)
if status:
self.connectButton.Enable(False)
self.stopButton.Enable(True)
else:
self.connectButton.Enable(True)
self.stopButton.Enable(False)
if self.ToggleValue == 0:
self.rb1.SetValue(True)
else:
self.rb2.SetValue(True)
self.threadLock.release()
def createThread(self, host=""):
if self.thread <> None:
self.thread.kill()
self.thread = GitsoThread.GitsoThread(self, self.paths)
self.thread.setHost(host)
self.thread.start()
# If you don't wait 2 seconds, the interface won't reload and it'll freeze.
# Possibly on older systems you should wait longer, it works fine on mine...
time.sleep(2)
gitso/trunk/Gitso.py
5353
5454
5555
56
5756
5857
5958
elif len(sys.argv) > 2:
help_menu()
if sys.platform == "darwin":
paths['preferences'] = os.path.join(os.path.expanduser("~"), "Library", "Application Support", "Gitso")
if os.path.exists(paths['preferences']) != True:
gitso/trunk/GitsoThread.py
66
77
88
9
10
11
9
10
11
12
13
14
1215
1316
1417
18
1519
1620
17
18
21
22
23
24
25
26
27
1928
20
21
29
30
31
32
33
34
35
36
37
38
39
40
2241
42
43
44
45
46
47
2348
2449
2550
51
2652
2753
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
2874
75
76
77
78
79
class GitsoThread(threading.Thread):
def __init__(self, window, paths):
self.window = window
self.paths = paths
self.host = ""
self.window = window
self.paths = paths
self.host = ""
self.error = False
self.pid = 0
self.running = True
self.process = Processes.Processes(paths)
threading.Thread.__init__(self)
def run(self):
if self.host <> "":
print "In Thread -- Starting getSupport()"
self.process.getSupport(self.host)
self.pid = self.process.getSupport(self.host)
time.sleep(.5)
if self.checkStatus():
self.window.setMessage("Connected.", True)
else:
self.window.setMessage("Could not connect.", False)
self.error = True
else:
print "In Thread -- Starting giveSupport()"
self.process.giveSupport()
self.pid = self.process.giveSupport()
time.sleep(.5)
if self.checkStatus():
self.window.setMessage("Server running.", True)
else:
self.window.setMessage("Could not start server.", False)
self.error = True
print "GitsoThread.run(pid: " + str(self.pid) + ") running..."
while(self.running and self.checkStatus()):
time.sleep(.5)
if not self.error:
self.window.setMessage("Idle.", False)
self.kill()
def setHost(self, host=""):
self.host = host
def kill(self):
self.process.KillPID()
self.pid = 0
self.running = False
def checkStatus(self):
if self.pid == 0:
return False
if sys.platform == 'darwin' or sys.platform.find('linux') != -1:
connection = os.popen('netstat -an | grep 5500 | grep ESTABLISHED').readlines()
listen = os.popen('netstat -an | grep 5500 | grep LISTEN').readlines()
elif sys.platform == 'win32':
#XP PRO only -- Need to fix the case where there is no process, it'll still return 1 line.
#info = os.popen('WMIC PROCESS ' + str(self.pid) + ' get Processid').readlines()
# possibly
connection = os.popen('netstat -a | find "ESTABLISHED" | find "5500"').readlines()
listen = os.popen('netstat -a | find "LISTEN" | find "5500"').readlines()
else:
print 'Platform not detected'
connection = array()
listen = array()
if len(connection) == 0 and len(listen) == 0:
return False
else:
return True
gitso/trunk/Processes.py
2020
2121
2222
23
2324
2425
2526
......
3132
3233
3334
34
35
36
3735
3836
3937
40
4138
4239
4340
41
4442
4543
4644
......
5048
5149
5250
51
5352
5453
5554
self.returnPID = os.spawnl(os.P_NOWAIT, '%s\\WinVNC.exe' % os.environ['WINDIR'], '%s\\WinVNC.exe' % os.environ['WINDIR'], '-connect', '%s' % host)
else:
print 'Platform not detected'
return self.returnPID
def giveSupport(self):
if sys.platform == 'darwin':
else:
dlg = wx.MessageDialog(self, "We were unable to find X11.app in /Applications/Utilities", "To Give Support you need X11.app", wx.OK|wx.CENTRE|wx.ICON_ERROR)
dlg.ShowModal()
#self.statusBar.SetStatusText("X11.app not found.", 1)
#self.connectButton.Enable(True)
#self.stopButton.Enable(False)
elif sys.platform.find('linux') != -1:
self.returnPID = os.spawnlp(os.P_NOWAIT, 'vncviewer', 'vncviewer', '-listen')
elif sys.platform == 'win32':
print 'Launching %s\\vncviewer.exe' % os.environ['WINDIR']
self.returnPID = os.spawnl(os.P_NOWAIT, "%s\\vncviewer.exe" % os.environ['WINDIR'], '%s\\vncviewer.exe' % os.environ['WINDIR'], '-listen' )
else:
print 'Platform not detected'
return self.returnPID
def KillPID(self):
"""
@author: Aaron Gerber
"""
if self.returnPID != 0:
print "Processes.KillPID(" + str(self.returnPID) + ")"
if sys.platform == 'win32':
#import win32api
#handle = win32api.OpenProcess(1, 0, pid)

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.09800s using 13 queries.