install.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 """
00004 usage: %(progname)s robot robot_type web_user
00005 """
00006 
00007 import os, sys, string, time, getopt
00008 import pwd
00009 import subprocess
00010 
00011 def make_file(fn, default):
00012   if os.path.exists(fn): return
00013 
00014   open(fn, "w").write(default)
00015 
00016 def install(robot, robot_type, web_user):
00017   config_dir = "/etc/ros/"
00018   var_dir = "/var/ros/"
00019   log_dir = "/var/log/ros/"
00020 
00021   user = pwd.getpwnam(web_user)
00022   for path in (config_dir, var_dir, log_dir):
00023     if not os.path.exists(path):
00024       os.mkdir(path, 0755)
00025     os.chown(path, user.pw_uid, user.pw_gid)
00026 
00027   make_file(os.path.join(config_dir, "user"), web_user)
00028   make_file(os.path.join(config_dir, "master"), "http://localhost:11311/")
00029   make_file(os.path.join(config_dir, "robot"), robot)
00030   make_file(os.path.join(config_dir, "robot_type"), robot_type)
00031 
00032   subprocess.call(["install", "setup.bash", os.path.join(config_dir, "setup.bash")])
00033   subprocess.call(["install", "apache.cfg", os.path.join(config_dir, "ros_webui_apache.cfg")])
00034 
00035   subprocess.call(["install", "webui.init", "/usr/bin/webui"])
00036 
00037 def test():
00038   pass
00039 
00040 def usage(progname):
00041   print __doc__ % vars()
00042 
00043 def main(argv, stdout, environ):
00044   progname = argv[0]
00045   optlist, args = getopt.getopt(argv[1:], "", ["help", "test", "debug"])
00046 
00047   testflag = 0
00048 
00049   if len(args) == 0:
00050     usage(progname)
00051     return
00052 
00053   for (field, val) in optlist:
00054     if field == "--help":
00055       usage(progname)
00056       return
00057     elif field == "--debug":
00058       debugfull()
00059     elif field == "--test":
00060       testflag = 1
00061 
00062   if testflag:
00063     test()
00064     return
00065 
00066   robot = args[0]
00067   robot_type = args[1]
00068   web_user = args[2]
00069 
00070   install(robot, robot_type, web_user)
00071 
00072 
00073 if __name__ == "__main__":
00074   main(sys.argv, sys.stdout, os.environ)


webui
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Wed Apr 23 2014 10:36:00