Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 import os
00011 import rocon_python_utils
00012 import rospkg
00013 import rocon_std_msgs.msg as rocon_std_msgs
00014
00015
00016
00017
00018
00019
00020 def setup_home_dirs():
00021 if not os.path.isdir(get_home()):
00022 os.makedirs(get_home())
00023 if not os.path.isdir(get_icon_cache_home()):
00024 os.makedirs(get_icon_cache_home())
00025 if not os.path.isdir(get_settings_cache_home()):
00026 os.makedirs(get_settings_cache_home())
00027
00028
00029 def get_home():
00030 '''
00031 Retrieve the location of the home directory for the rocon remocon's
00032 temporary storage needs
00033
00034 @return the rocon remocon home directory (path object).
00035 @type str
00036 '''
00037 return os.path.join(rospkg.get_ros_home(), 'rocon', 'remocon')
00038
00039
00040 def get_icon_cache_home():
00041 '''
00042 Retrieve the location of the directory used for storing icons.
00043
00044 @return the rocon remocon icons directory (path object).
00045 @type str
00046 '''
00047 return os.path.join(get_home(), 'icons')
00048
00049
00050 def get_settings_cache_home():
00051 '''
00052 Retrieve the location of the directory used for storing qt settings.
00053
00054 @return the rocon remocon qt settings directory (path object).
00055 @type str
00056 '''
00057 return os.path.join(get_home(), 'cache')
00058
00059
00060 def find_rocon_remocon_script(name):
00061 """
00062 Get the path to the internal script of the specified name. Note that this changes
00063 depending on whether you are working in a devel or an install space. Let the
00064 find resource handler discover where they are.
00065
00066 :returns: full absolute pathnmae to the script
00067 :rtype: path
00068 :raises: `rospgk.ResourceNotFound`
00069 """
00070 return rocon_python_utils.ros.find_resource('rocon_remocon', name)
00071
00072
00073 def get_web_browser():
00074 """
00075 Do a search through preferred browsers which most importantly can handle
00076 web apps and return the path to their executables.
00077
00078 :returns: pathname to the browser
00079 :rtype: str
00080 """
00081 if rocon_python_utils.system.which("google-chrome"):
00082 return 'google-chrome'
00083 elif rocon_python_utils.system.which("google-chrome-unstable"):
00084 return 'google-chrome-unstable'
00085 elif rocon_python_utils.system.which("chromium-browser"):
00086 return 'chromium-browser'
00087 elif rocon_python_utils.system.which("firefox"):
00088 return 'firefox'
00089 return None
00090
00091 def get_web_browser_codename():
00092 """
00093 returns available browsers codename
00094
00095 :returns: web browser code name
00096 :rtype: str
00097 """
00098
00099 return rocon_std_msgs.Strings.OS_CHROME