Thread: [Cvsshell-devel] CVS: cvsshell install.py,1.1,1.2
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-03-11 10:09:52
|
Update of /cvsroot/cvsshell/cvsshell In directory usw-pr-cvs1:/tmp/cvs-serv2904 Modified Files: install.py Log Message: installation and cvsshell now works on windows! Index: install.py =================================================================== RCS file: /cvsroot/cvsshell/cvsshell/install.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** install.py 10 Mar 2002 23:11:07 -0000 1.1 --- install.py 11 Mar 2002 10:09:49 -0000 1.2 *************** *** 1,103 **** ! #!/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() --- 1,131 ---- ! #!/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 ! ! ! 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.cvsDir = None ! self.initOptions('') ! ! ! def getPrompt(self): ! if self.targetDir is None: ! return 'Into which directory should I install the shellscript that starts CvsShell?\n' \ ! 'This directory should be included in your $PATH variable.\n$ ' ! else: # This will be reached on windows only ! return 'Where can I find the cvs executable (cvs.exe)?\n$ ' ! ! ! def evalCommand(self, cmd): ! if os.path.isdir(cmd): ! if self.targetDir is None: ! 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 ! if not self.onWindows: return self.BREAK_REPL ! else: # only reachable on windows ! if os.path.exists(os.path.join(cmd, 'cvs.exe')): ! self.cvsDir = cmd ! return self.BREAK_REPL ! else: return 'cvs.exe does not exist in this directory.' ! else: return 'Not a valid directory.' ! ! ! def start(self): ! InteractiveApp.start(self) ! if self.onWindows: ! pass #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, content = self.createStartScript() ! try: ! open(startup, 'w').write(content) ! 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: ! launcher = startup ! self.printMsg("You can launch it by typing `%s' in a terminal window." % launcher) ! if self.onWindows: self.printMsg('You can also click the icon of this file in the explorer.') ! ! ! def createStartScript(self): ! if self.onWindows: return self.createWindowsStartScript() ! else: return self.createUnixStartScript() ! ! ! def createWindowsStartScript(self): ! return (os.path.join(self.targetDir, 'cvsshell.py'), """ ! import os, sys ! ! # Setting up PATH for cvs ! path = os.environ.get('PATH','') ! path = '%s;'+path ! os.environ['PATH'] = path ! ! sys.path.insert(0, '%s') ! import cvs_shell ! cvs_shell.main() ! raw_input() ! """ % (self.cvsDir, os.path.join(self.THIS_DIR, 'src'))) ! ! def createUnixStartScript(self): ! return (os.path.join(self.targetDir, 'cvsshell'), """#!/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'))) ! ! ! if __name__ == '__main__': ! i = Installation() ! i.main() ! if i.onWindows: raw_input() |