#!/usr/bin/env python """This is the Student Robotics development tool wrapper script. It provides an interface to a number of different CLI tools used by the SR project. The idea is that this script searches for executable files in the subdirectories of /tools/ in subversion and allows one to run them like so: sr SCRIPT Where SCRIPT is the name of an executable file with the path /tools/*/SCRIPT in subversion. This script *must* be checked out along with the rest of /tools. See http://trac.srobo.org/wiki/DevScripts for more details.""" import sys, os print """sr tools have moved to git. Please remove your existing installation, and then check out from git. The new repository can be found here: https://www.studentrobotics.org/cgit/tools.git/""" sys.exit(1) import git_repos, subprocess, sr_commands TOOLS = os.path.join( sys.path[0], "../" ) cmds = sr_commands.get_dict(TOOLS) # Check the git stuff has been checked out if not os.path.exists( os.path.join( TOOLS, "git" ) ): print "git tools not yet downloaded -- rectifying:" os.mkdir( os.path.join( TOOLS, "git" ) ) git_repos.update_all( TOOLS ) else: git_repos.check_all( TOOLS ) #if no argument was passed or the command passed doesn't exist if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] not in cmds.keys()): if len(sys.argv) > 1: print "Invalid command '%s'" % sys.argv[1] else: print "sr: The Student Robotics devtool wrapper script" print "Usage: sr COMMAND" print "Available commands:" for cmd,path in cmds.iteritems(): if cmd[0] != "_": print "\t%s" % cmd sys.exit(1) else: cmd = sys.argv[1] args = [cmd] args += sys.argv[2:] os.execv( cmds[cmd], args )