import subprocess
def execBashShellCommand(cmd):
print cmd
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,executable="/bin/bash")
while True:
buff = p.stdout.readline()
if buff == '' and p.poll() != None:
break
print buff
p.wait()
def main():
execBashShellCommand("rm -rf ~/workspace")
execBashShellCommand("rm -rf ~/.ros")
execBashShellCommand("rm -rf ~/.rviz")
execBashShellCommand("rm -rf ~/open_ptrack")
execBashShellCommand("sudo apt-get install git -y")
execBashShellCommand("cd ~ && git clone https://github.com/OpenPTrack/open_ptrack.git")
execBashShellCommand("sed -i '/source ~\/workspace\/ros\/rosbuild\/setup.bash/d' ~/.bashrc")
execBashShellCommand("sed -i '/export KINECT_DRIVER=openni/d' ~/.bashrc")
execBashShellCommand("sed -i '/export LC_ALL=C/d' ~/.bashrc")
execBashShellCommand("cd ~/open_ptrack/scripts && chmod +x *.sh && ./ros_install.sh")
execBashShellCommand("cd ~/open_ptrack/scripts && source /opt/ros/indigo/setup.bash ; ./ros_configure.sh")
execBashShellCommand("cd ~/open_ptrack/scripts && ./openptrack_install.sh")
execBashShellCommand("ln -s ~/workspace/ros/catkin/src/open_ptrack ~/open_ptrack")
execBashShellCommand("source ~/workspace/ros/rosbuild/setup.bash ; source ~/.profile ; export KINECT_DRIVER=openni && export LC_ALL=C && cd ~/workspace/ros/catkin && catkin_make --pkg calibration_msgs && catkin_make --pkg opt_msgs && catkin_make --force-cmake")
execBashShellCommand("sudo apt-get -y install nvidia-375-dev")
execBashShellCommand("sudo apt-get -y install ocl-icd-opencl-dev")
execBashShellCommand("source ~/workspace/ros/rosbuild/setup.bash ; source ~/.profile ; export KINECT_DRIVER=openni && export LC_ALL=C && cd ~/workspace/ros/catkin/src && roscd open_ptrack/../scripts && chmod +x kinect2_install.sh && ./kinect2_install.sh")
execBashShellCommand("cd ~/workspace/ros/catkin/devel/lib/kinect2_bridge && sudo ./kinect2_bridge")
if __name__ == "__main__":
main()