Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug#673931 - Python-ldtp has issues if the application calls an env o…

…r other program to run
  • Loading branch information...
commit beba4afac0d435313d053eae299c9b55a5631d72 1 parent c8ab919
Nagappan Alagappan authored April 11, 2012

Showing 1 changed file with 7 additions and 25 deletions. Show diff stats Hide diff stats

  1. 32  ldtpd/utils.py
32  ldtpd/utils.py
@@ -117,32 +117,11 @@ def get_cpu_memory_stat(self):
117 117
             # If len(i['process_name']) > 15, then the string is truncated by
118 118
             # statgrab module, so in re.search use i['process_name'] as search
119 119
             # criteria
120  
-            if not re.search(str(i['process_name']), self._appname,
121  
-                             re.U | re.L):
  120
+            if not re.search(str(i['proctitle']), self._appname,
  121
+                              re.U | re.L):
122 122
                 # If process name doesn't match, continue
123 123
                 continue
124  
-            # If process name matches
125  
-            # Get process title
126  
-            # ex output (string):
127  
-            # /usr/lib/gnome-panel/clock-applet --oaf-activate-iid= \
128  
-            #        OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=32
129  
-            title = str(i['proctitle'])
130  
-            # Split the title to get exact string
131  
-            # ex output (list of string):
132  
-            # ['/usr/lib/gnome-panel/clock-applet',
133  
-            # '--oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory \
134  
-            #        --oaf-ior-fd=32 ']
135  
-            # Just split the first separater
136  
-            proctitle = re.split(" ", title, 1) # Split by space
137  
-            # ex output (list of string)
138  
-            # ['', 'usr', 'lib', 'gnome-panel', 'clock-applet']
139  
-             # Split by / and use the last string, which is process name
140  
-            procname = re.split("/", proctitle[0])[-1]
141  
-            if not re.match(self._appname, procname):
142  
-                # If process name and application name doesn't match
143  
-                # continue, don't add it to the list
144  
-                continue
145  
-            proc_list.append([i, procname])
  124
+            proc_list.append([i, self._appname])
146 125
         return proc_list
147 126
 
148 127
     def run(self):
@@ -161,7 +140,10 @@ def run(self):
161 140
                            (procname, str(i['pid']),
162 141
                             str(round(i['cpu_percent'], 2))))
163 142
             # Wait for interval seconds before gathering stats again
164  
-            time.sleep(self._interval)
  143
+            try:
  144
+                time.sleep(self._interval)
  145
+            except KeyboardInterrupt:
  146
+                self._stop = True
165 147
 
166 148
     def stop(self):
167 149
         self._stop = True

0 notes on commit beba4af

Please sign in to comment.
Something went wrong with that request. Please try again.