[Cvsshell-devel] CVS: cvsshell install.py,NONE,1.1
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-03-10 23:11:10
|
Update of /cvsroot/cvsshell/cvsshell In directory usw-pr-cvs1:/tmp/cvs-serv24870 Added Files: install.py Log Message: initial checkin --- NEW FILE: install.py --- #!/usr/bin/env python ############################################################################### # This file is part of CvsShell # # CvsShell is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # CvsShell is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CvsShell; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Copyright 2002 by Stefan Heimann # Website: http://cvsshell.sourceforge.net/ ############################################################################### import sys, os, time thisDir = os.path.join(os.getcwd(), sys.path[0]) sys.path.insert(1, os.path.join(thisDir, 'src')) from interactive_app import InteractiveApp from cvs_shell import NAME, VERSION, COPYRIGHT, BUG_ADDRESS unixStartScript = """#!/usr/bin/env sh # automatically generated on %s /usr/bin/env python %s "$@" """ % (time.ctime(time.time()), os.path.join(thisDir, 'src', 'cvs_shell.py')) class Installation(InteractiveApp): def __init__(self): InteractiveApp.__init__(self) self.setName(NAME + ' Installation Procedure') self.setVersion(VERSION) self.setCopyright(COPYRIGHT) self.setBugAddress(BUG_ADDRESS) self.targetDir = None self.initOptions('') self.onWindows = sys.platform[:3] == 'win' try: self.path = os.environ['PATH'].split(os.pathsep) except KeyError: self.path = [] def getPrompt(self): return 'Into which directory should I install the shellscript that starts CvsShell?\n' \ 'This directory should be included in your $PATH variable.\n$ ' def evalCommand(self, cmd): if os.path.isdir(cmd): if not self.inPath(cmd): self.printMsg('The directory is not included in your $PATH variable.') if raw_input('Are you sure (yes|no)? ') != 'yes': return self.targetDir = cmd return self.BREAK_REPL else: return 'Not a valid directory.' def start(self): InteractiveApp.start(self) if self.onWindows: self.exit("Windows is currently not supported. I am working on it.") def inPath(self, dir): return dir in self.path def stop(self): failureMsg = 'CvsShell was not successfully installed.' global unixStartScript if self.targetDir is None: self.printMsg(failureMsg) return startup = os.path.join(self.targetDir, 'cvsshell') try: open(startup, 'w').write(unixStartScript) os.chmod(startup, 0775) except (IOError, OSError), msg: self.exit(str(msg) + '\n' + failureMsg) self.printMsg('CvsShell was successfully installed.') if self.inPath(self.targetDir): launcher = os.path.basename(startup) else: launcer = startup self.printMsg("You can launch it by typing `%s' in a terminal window" % launcher) if __name__ == '__main__': i = Installation() i.main() |