webutil.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import os, sys, string, time, getopt
4 import urllib
5 import roslib
6 
7 import config
8 
9 def grabTopics(hdf, topics):
10  topics = topics + ["/power_state", "/power_board_state", "/app_status"]
11  topicList = []
12  for topic in topics: topicList.append("topic=%s" % topic)
13  topics = string.join(topicList, "&")
14 
15  url = "http://localhost:%s/ros/receive?since=0&nowait=1&%s" % (config.gROSBridgePort, topics)
16  try:
17  fp = urllib.urlopen(url)
18  body = fp.read()
19  fp.close()
20 
21  hdf.setValue("CGI.cur.messages", body)
22  except:
23  pass
24 
25 def list_apps():
26  import subprocess
27  import glob
28 
29  apps = []
30  cmd = ["rospack", "depends-on", "webui"]
31  p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
32  while 1:
33  line = p.stdout.readline()
34  if not line: break
35  pkg = line.strip()
36 
37  path = roslib.packages.get_pkg_dir(pkg)
38  files = glob.glob(os.path.join(path, "*.app"))
39  for app in files:
40  apps.append(app)
41  return apps
42 
43 def set_tabs(hdf, tabs):
44  i = 0
45  for tab in tabs:
46  hdf.setValue("CGI.cur.tabs.%d" % i, tab)
47  i += 1
48 
49 def hdf_array(hdf, array, prefix):
50  i = 0
51  for element in array:
52  hdf.setValue("%s.%s" % (prefix, i), element)
53  i += 1
54 
def grabTopics(hdf, topics)
Definition: webutil.py:9
def hdf_array(hdf, array, prefix)
Definition: webutil.py:49
def set_tabs(hdf, tabs)
Definition: webutil.py:43
def list_apps()
Definition: webutil.py:25


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24