download_testing_bag.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 2020 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import os
18 import sys
19 import rospy
20 import rospkg
21 import threading
22 import urllib
23 
24 
25 def show_progress(event):
26  while not event.is_set():
27  sys.stdout.write('.')
28  sys.stdout.flush()
29  event.wait(1)
30  print "\n"
31 
32 bag_file = os.path.join(rospkg.RosPack().get_path('sr_data_visualization'), 'biotacs_and_everything_else.bag')
33 
34 if not os.path.isfile(bag_file):
35  sys.stdout.write("Bag file for testing not found, downloading now. This may take a few minutes .")
36  sys.stdout.flush()
37  url = "https://www.dropbox.com/s/6vfxvmla4hcsbzd/biotacs_and_everything_else.bag?dl=1"
38  file_path = os.path.join(rospkg.RosPack().get_path('sr_data_visualization'))
39  trigger = threading.Event()
40  t = threading.Thread(target=show_progress, args=(trigger,))
41  t.start()
42  urllib.urlretrieve(url, bag_file)
43  trigger.set()
44  print "\n"
45  print "File downloaded: ", bag_file
46  sys.exit()
47 else:
48  print "Bag file already exists, doing nothing."
49  sys.exit()


sr_data_visualization
Author(s): Tom Queen
autogenerated on Wed Oct 14 2020 03:22:43