diff --git a/gitso/trunk/ArgsParser.py b/gitso/trunk/ArgsParser.py new file mode 100644 index 0000000..0800fd4 --- /dev/null +++ b/gitso/trunk/ArgsParser.py @@ -0,0 +1,91 @@ +#! /usr/bin/env python + +""" +Gisto - Gitso is to support others + +Gitso is a utility to facilitate the connection of VNC + +@author: Aaron Gerber ('gerberad') +@author: Derek Buranen ('burner') +@copyright: 2007-2008 +""" + +import os, sys, signal, os.path +class ArgsParser: + def __init__(self): + # Initialize Self.paths here. + self.paths = dict() + self.paths['resources'] = os.path.join(sys.path[0], "./") + self.paths['preferences'] = '' + self.paths['copyright'] = '' + self.paths['main'] = '' + self.paths['listen'] = False + self.paths['connect'] = '' + + if sys.platform.find('linux') != -1: + self.paths['main'] = os.path.join(sys.path[0], '..', 'share', 'gitso') + self.paths['copyright'] = os.path.join(sys.path[0], '..', 'share', 'doc', 'gitso', 'copyright') + else: + self.paths['main'] = os.path.join(sys.path[0]) + self.paths['copyright'] = os.path.join(sys.path[0], 'copyright') + + #for i in range(1, len(sys.argv)): + i = 1 + while i < len(sys.argv): + if sys.argv[i] == '--dev': # --dev + if sys.platform == "darwin": + self.paths['resources'] = 'arch/osx/' + elif sys.platform == "w32": + self.paths['resources'] = 'arch/win32/' + else: + self.paths['resources'] = 'arch/linux/' + self.paths['main'] = os.path.join(sys.path[0]) + self.paths['copyright'] = os.path.join(sys.path[0], 'copyright') + + elif sys.argv[i] == '--listen': # --listen + if self.paths['connect'] <> "": + print "Error: --connect and --listen can not be used at the same time." + self.HelpMenu() + self.paths['listen'] = True + + elif sys.argv[i] == '--connect': # --connect + i = i + 1 + if i >= len(sys.argv) or self.paths['listen']: + print "Error: --connect and --listen can not be used at the same time." + self.HelpMenu() + + if sys.argv[i][0] + sys.argv[i][1] <> "--": + self.paths['connect'] = sys.argv[i] + else: + print "Error: '" + sys.argv[i] + "' is host with '--connect'." + self.HelpMenu() + + else: + print "Error: '" + sys.argv[i] + "' is not a valid argument." + self.HelpMenu() + + i = i + 1 + + if sys.platform == "darwin": + self.paths['preferences'] = os.path.join(os.path.expanduser("~"), "Library", "Application Support", "Gitso") + if os.path.exists(self.paths['preferences']) != True: + os.makedirs(self.paths['preferences'], 0700) + self.paths['preferences'] = os.path.join(self.paths['preferences'], "hosts") + elif sys.platform == "win32": + self.paths['preferences'] = os.path.join(os.path.expanduser("~"), "Local Settings", "Application Data", ".gitso-hosts") + else: + self.paths['preferences'] = os.path.join(os.path.expanduser("~"), ".gitso-hosts") + + #Help Menu + def HelpMenu(self): + print "Usage: " + os.path.basename(sys.argv[0]) + " [OPTION]" + print " OPTIONS" + print " --dev\t\tSet self.paths for development." + print " --listen\t\tlisten for incoming connections." + print " --connect {IP|DN}\tConnects to host (support giver)." + print " --list {URL|LIST}\tAlternative Support list." + print " --help\t\tThis Menu." + exit(0) + + def GetPaths(self): + return self.paths diff --git a/gitso/trunk/ConnectionWindow.py b/gitso/trunk/ConnectionWindow.py index 9e8dd4d..ae22a9f 100644 --- a/gitso/trunk/ConnectionWindow.py +++ b/gitso/trunk/ConnectionWindow.py @@ -111,6 +111,16 @@ class ConnectionWindow(wx.Frame): self.SetThemeEnabled(True) self.Centre() self.Show(True) + + if self.paths['listen']: + self.rb2.Value = True + self.RadioToggle(None) + self.ConnectSupport(None) + elif self.paths['connect'] <> "": + self.rb1.Value = True + self.RadioToggle(None) + self.hostField.Value = self.paths['connect'] + self.ConnectSupport(None) def RadioToggle(self, event): @@ -295,5 +305,5 @@ class ConnectionWindow(wx.Frame): # 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) + time.sleep(1) diff --git a/gitso/trunk/Gitso.py b/gitso/trunk/Gitso.py index 9360c07..02156c0 100644 --- a/gitso/trunk/Gitso.py +++ b/gitso/trunk/Gitso.py @@ -11,60 +11,11 @@ Gitso is a utility to facilitate the connection of VNC """ import wx -import os, sys, signal, os.path -import ConnectionWindow, GitsoThread - -#Help Menu -def help_menu(): - print "Usage: " + os.path.basename(sys.argv[0]) + " [OPTION]" - print " OPTIONS" - print " --dev\t\tSet paths for development." - print " --host {IP|DN}\tConnects to host (support giver)." - print " --list {URL|LIST}\tAlternative Support list." - print " --help\t\tThis Menu." - exit(0) - -# Initialize Paths here. -paths = dict() -paths['resources'] = os.path.join(sys.path[0], "./") -paths['preferences'] = '' -paths['copyright'] = '' -paths['main'] = '' - -if sys.platform.find('linux') != -1: - paths['main'] = os.path.join(sys.path[0], '..', 'share', 'gitso') - paths['copyright'] = os.path.join(sys.path[0], '..', 'share', 'doc', 'gitso', 'copyright') -else: - paths['main'] = os.path.join(sys.path[0]) - paths['copyright'] = os.path.join(sys.path[0], 'copyright') - -if len(sys.argv) == 2: - if sys.argv[1] == '--dev': - if sys.platform == "darwin": - paths['resources'] = 'arch/osx/' - elif sys.platform == "w32": - paths['resources'] = 'arch/win32/' - else: - paths['resources'] = 'arch/linux/' - paths['main'] = os.path.join(sys.path[0]) - paths['copyright'] = os.path.join(sys.path[0], 'copyright') - else: - help_menu() -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: - os.makedirs(paths['preferences'], 0700) - paths['preferences'] = os.path.join(paths['preferences'], "hosts") -elif sys.platform == "win32": - paths['preferences'] = os.path.join(os.path.expanduser("~"), "Local Settings", "Application Data", ".gitso-hosts") -else: - paths['preferences'] = os.path.join(os.path.expanduser("~"), ".gitso-hosts") +import ConnectionWindow, ArgsParser if __name__ == "__main__": app = wx.PySimpleApp() - ConnectionWindow.ConnectionWindow(None, -1, "Gitso", paths) + args = ArgsParser.ArgsParser() + ConnectionWindow.ConnectionWindow(None, -1, "Gitso", args.GetPaths()) app.MainLoop() del app diff --git a/gitso/trunk/GitsoThread.py b/gitso/trunk/GitsoThread.py index 52a8d43..4b605ab 100755 --- a/gitso/trunk/GitsoThread.py +++ b/gitso/trunk/GitsoThread.py @@ -37,7 +37,7 @@ class GitsoThread(threading.Thread): print "GitsoThread.run(pid: " + str(self.pid) + ") running..." while(self.running and self.checkStatus()): - time.sleep(.5) + time.sleep(.2) if not self.error: self.window.setMessage("Idle.", False) @@ -58,19 +58,22 @@ class GitsoThread(threading.Thread): if self.pid == 0: return False + connection = [] + listen = [] 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() + if self.host <> "": + connection = os.popen('netstat -an | grep 5500 | grep ESTABLISHED').readlines() + else: + 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() + if self.host <> "": + connection = os.popen('netstat -a | find "ESTABLISHED" | find "5500"').readlines() + else: + 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 diff --git a/gitso/trunk/arch/linux/control b/gitso/trunk/arch/linux/control index 7eb9e84..b0c7ae3 100644 --- a/gitso/trunk/arch/linux/control +++ b/gitso/trunk/arch/linux/control @@ -1,5 +1,5 @@ Package: gitso -Version: 0.5 +Version: 0.6 Priority: optional Section: utils Architecture: all diff --git a/gitso/trunk/arch/linux/gitso b/gitso/trunk/arch/linux/gitso index b9b0503..561805e 100644 --- a/gitso/trunk/arch/linux/gitso +++ b/gitso/trunk/arch/linux/gitso @@ -3,9 +3,11 @@ import sys, os, wx sys.path.append(os.path.join(sys.path[0], '..', 'share', 'gitso')) -from Gitso import Connect +from Gitso import ConnectionWindow, ArgsParser if __name__ == "__main__": app = wx.PySimpleApp() - Connect(None, -1, "Gitso") + args = ArgsParser.ArgsParser() + ConnectionWindow.ConnectionWindow(None, -1, "Gitso", args.GetPaths()) app.MainLoop() + del app diff --git a/gitso/trunk/arch/linux/gitso.1 b/gitso/trunk/arch/linux/gitso.1 new file mode 100644 index 0000000..1ad1dfd --- /dev/null +++ b/gitso/trunk/arch/linux/gitso.1 @@ -0,0 +1,62 @@ +.TH GITSO 1 "October 2008" "gitso-0.6" "Gitso" +.SH NAME +gitso - Gitso is to support others +.SH SYNOPSIS +.B gitso +[ +.B --dev +| +.B --listen +| +.B --connect +.I host +| +.B --list +.I list +| +.B --help +] +.SH DESCRIPTION +Gitso is a frontend to reverse VNC connections. It is meant to be a simple two-step process that connects one person to another's screen in the context of giving technical support. +.SH OPTIONS +.TP +.B --dev +Configures paths for running Gitso in the source tree. +.TP +.B --listen +Start Gitso and listen for incoming connections +.TP +.B --connect +Starts gitso and automatically connects to +.I host +which is an IP or domain name (address of support giver). +.TP +.B --list +Alternative support list, where +.I list +is either a URL of a remote file list or a comma seperated list +.TP +.B --help +Display the help menu. + +.SH HOST FILES +.I $HOME/.gitso-hosts +.I /usr/share/gitso/hosts.txt + +.SH EXAMPLES +.TP +gitso --list support.mydomain.com/techs.txt +Gets the list of technician IP's or DN's from techs.txt +.TP +gitso --list sanda.mydomain.com,aicha.mydomain.com +Adds these three entries to the list of support techs. +.TP +gitso --connect hank.mydomain.com +Automatically connects to hank.mydomain.com + +.SH SEE ALSO +.I x11vnc +.I vncviewer + +.SH AUTHOR +Aaron Gerber and Derek Buranen diff --git a/gitso/trunk/makegitso.pl b/gitso/trunk/makegitso.pl deleted file mode 100755 index e9e3b15..0000000 --- a/gitso/trunk/makegitso.pl +++ /dev/null @@ -1,84 +0,0 @@ -#! /usr/bin/perl -w - -use warnings; -use strict; - - -if(`uname -a` =~ m/Darwin/) { - if(`which py2applet` ne "") { - print "Creating Gitso.app "; - `rm -f setup.py`; - `rm -rf dist`; - - print ".."; - `py2applet --make-setup Gitso.py`; - - print ".."; - `python setup.py py2app`; - - print ".."; - `cp arch/osx/Info.plist dist/Gitso.app/Contents/`; - `cp copyright dist/Gitso.app/Contents/Resources/`; - `cp PythonApplet.icns dist/Gitso.app/Contents/Resources/`; - - `tar xvfz arch/osx/OSXvnc.tar.gz`; - `mv OSXvnc dist/Gitso.app/Contents/Resources/`; - - `tar xvfz arch/osx/vncviewer.tar.gz`; - `mv vncviewer dist/Gitso.app/Contents/Resources/`; - print " [done]\n"; - - print "Creating Gitso.dmg "; - `rm -f Gitso.dmg`; - - `mkdir dist/Gitso`; - `cp arch/osx/dmg_DS_Store dist/Gitso/.DS_Store`; - `ln -s /Applications/ dist/Gitso/Applications`; - - `mv "dist/Gitso.app" "dist/Gitso/"`; - `cp -r arch/osx/Readme.rtfd dist/Gitso/Readme.rtfd`; - - print "..."; - `hdiutil create -srcfolder dist/Gitso/ Gitso.dmg`; - print "... [done]\n"; - } else { - print "Error, you need py2applet to be installed."; - } - -} elsif (`uname -a` =~ m/Linux/) { - my $deb = "gitso_0.5_all.deb"; - my $path = "gitso"; - print "Creating $path.deb"; - `rm -rf $path`; - `mkdir $path`; - `mkdir $path/DEBIAN`; - `cp arch/linux/control $path/DEBIAN`; - - print ".."; - `mkdir $path/usr`; - `mkdir $path/usr/bin`; - `mkdir $path/usr/share`; - `mkdir $path/usr/share/applications`; - `mkdir $path/usr/share/doc`; - `mkdir $path/usr/share/doc/$path`; - `mkdir $path/usr/share/$path`; - `cp arch/linux/gitso $path/usr/bin/`; - `chmod 755 $path/usr/bin/gitso`; - `cp Gitso.py $path/usr/share/$path/`; - `cp __init__.py $path/usr/share/$path/`; - `cp hosts.txt $path/usr/share/$path/`; - `cp icon.ico $path/usr/share/$path/`; - - print ".."; - `cp arch/linux/gitso.desktop $path/usr/share/applications/`; - `cp arch/linux/README.txt $path/usr/share/doc/$path/README`; - `cp copyright $path/usr/share/doc/$path/`; - `gzip -cf arch/linux/changelog > $path/usr/share/doc/$path/changelog.gz`; - - print ".."; - `dpkg -b $path/ $deb`; - - #`rm -rf $path`; - - print " [done]\n"; -} diff --git a/gitso/trunk/makegitso.sh b/gitso/trunk/makegitso.sh new file mode 100755 index 0000000..8182593 --- /dev/null +++ b/gitso/trunk/makegitso.sh @@ -0,0 +1,98 @@ +#! /bin/bash + +if [ "$1" = "" ]; then + CLEAN="yes" +elif test "$1" = "--no-clean"; then + CLEAN="no" +else + echo -e "Usage makegitso.sh: [ --no-clean | --help ]" + echo -e "\tOptions:" + echo -e "\t--no-clean\tDo not remove the build directory." + echo -e "\t--help \tThese options." + exit 0 +fi + +if test `uname -a | grep Darwin`; then + if test `which py2applet`; then + echo -e "Creating Gitso.app " + rm -f setup.py + rm -rf dist + + echo -e ".." + py2applet --make-setup Gitso.py + + echo -e ".." + python setup.py py2app + + echo -e ".." + cp arch/osx/Info.plist dist/Gitso.app/Contents/ + cp copyright dist/Gitso.app/Contents/Resources/ + cp PythonApplet.icns dist/Gitso.app/Contents/Resources/ + + tar xvfz arch/osx/OSXvnc.tar.gz + mv OSXvnc dist/Gitso.app/Contents/Resources/ + + tar xvfz arch/osx/vncviewer.tar.gz + mv vncviewer dist/Gitso.app/Contents/Resources/ + echo -e " [done]\n" + + echo -e "Creating Gitso.dmg " + rm -f Gitso.dmg + + mkdir dist/Gitso + cp arch/osx/dmg_DS_Store dist/Gitso/.DS_Store + ln -s /Applications/ dist/Gitso/Applications + + mv "dist/Gitso.app" "dist/Gitso/" + cp -r arch/osx/Readme.rtfd dist/Gitso/Readme.rtfd + + echo -e "..." + hdiutil create -srcfolder dist/Gitso/ Gitso.dmg + echo -e "... [done]\n" + else + echo -e "Error, you need py2applet to be installed." + fi + +elif test "`uname -a 2>&1 | grep Linux | grep -v which`"; then + DEB="gitso_0.6_all.deb" + BUILDPATH="gitso" + echo -n "Creating $DEB" + rm -rf $BUILDPATH + + mkdir -p $BUILDPATH/DEBIAN + mkdir -p $BUILDPATH/usr/bin + mkdir -p $BUILDPATH/usr/share/applications + mkdir -p $BUILDPATH/usr/share/doc/$BUILDPATH + mkdir -p $BUILDPATH/usr/share/$BUILDPATH + mkdir -p $BUILDPATH/usr/share/man/man1 + + echo -n ".." + cp arch/linux/control $BUILDPATH/DEBIAN + cp arch/linux/gitso $BUILDPATH/usr/bin/ + chmod 755 $BUILDPATH/usr/bin/gitso + cp Gitso.py $BUILDPATH/usr/share/$BUILDPATH/ + cp ConnectionWindow.py $BUILDPATH/usr/share/$BUILDPATH/ + cp AboutWindow.py $BUILDPATH/usr/share/$BUILDPATH/ + cp GitsoThread.py $BUILDPATH/usr/share/$BUILDPATH/ + cp Processes.py $BUILDPATH/usr/share/$BUILDPATH/ + cp ArgsParser.py $BUILDPATH/usr/share/$BUILDPATH/ + cp __init__.py $BUILDPATH/usr/share/$BUILDPATH/ + cp hosts.txt $BUILDPATH/usr/share/$BUILDPATH/ + cp icon.ico $BUILDPATH/usr/share/$BUILDPATH/ + + echo -n ".." + cp arch/linux/gitso.desktop $BUILDPATH/usr/share/applications/ + cp arch/linux/README.txt $BUILDPATH/usr/share/doc/$BUILDPATH/README + cp copyright $BUILDPATH/usr/share/doc/$BUILDPATH/ + gzip -cf arch/linux/changelog > $BUILDPATH/usr/share/doc/$BUILDPATH/changelog.gz + gzip -cf arch/linux/gitso.1 > $BUILDPATH/usr/share/man/man1/gitso.1.gz + + echo -n ".." + dpkg -b $BUILDPATH/ $DEB 2>&1 > /dev/null + + if [ "$CLEAN" = "yes" ]; then + rm -rf $BUILDPATH + fi + + echo -e " [done]\n" +fi