diff options
Diffstat (limited to 'run/executable')
| -rw-r--r-- | run/executable/executable.py | 9 | ||||
| -rw-r--r-- | run/executable/ftcat.py | 21 |
2 files changed, 16 insertions, 14 deletions
diff --git a/run/executable/executable.py b/run/executable/executable.py index bc8edd7..0a408b7 100644 --- a/run/executable/executable.py +++ b/run/executable/executable.py | |||
| @@ -44,7 +44,6 @@ class Executable(object): | |||
| 44 | return full_command | 44 | return full_command |
| 45 | 45 | ||
| 46 | def __str__(self): | 46 | def __str__(self): |
| 47 | print("Full command: %s" % self.__get_full_command()) | ||
| 48 | return " ".join(self.__get_full_command()) | 47 | return " ".join(self.__get_full_command()) |
| 49 | 48 | ||
| 50 | def execute(self): | 49 | def execute(self): |
| @@ -63,7 +62,7 @@ class Executable(object): | |||
| 63 | '''Send the terminate signal to the binary.''' | 62 | '''Send the terminate signal to the binary.''' |
| 64 | self.sp.terminate() | 63 | self.sp.terminate() |
| 65 | 64 | ||
| 66 | def wait(self): | 65 | def wait(self, error=True): |
| 67 | '''Wait until the executable is finished, checking return code. | 66 | '''Wait until the executable is finished, checking return code. |
| 68 | 67 | ||
| 69 | If the exit status is non-zero, raise an exception. | 68 | If the exit status is non-zero, raise an exception. |
| @@ -71,8 +70,10 @@ class Executable(object): | |||
| 71 | ''' | 70 | ''' |
| 72 | 71 | ||
| 73 | self.sp.wait() | 72 | self.sp.wait() |
| 74 | if self.sp.returncode != 0: | 73 | if self.sp.returncode != 0 and error: |
| 75 | print >>sys.stderr, "Non-zero return: %s %s" % (self.exec_file, " ".join(self.extra_args)) | 74 | print >>sys.stderr, "Non-zero return %d: %s %s" % (self.sp.returncode, |
| 75 | self.exec_file, | ||
| 76 | " ".join(self.extra_args)) | ||
| 76 | return 0 | 77 | return 0 |
| 77 | else: | 78 | else: |
| 78 | return 1 | 79 | return 1 |
diff --git a/run/executable/ftcat.py b/run/executable/ftcat.py index 5da8fa7..1f0420b 100644 --- a/run/executable/ftcat.py +++ b/run/executable/ftcat.py | |||
| @@ -1,18 +1,15 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import stat | 2 | import stat |
| 3 | 3 | ||
| 4 | from executable import Executable | 4 | from .executable import Executable |
| 5 | 5 | ||
| 6 | class FTcat(Executable): | 6 | class FTcat(Executable): |
| 7 | '''Used to wrap the ftcat binary in the Experiment object.''' | 7 | '''Used to wrap the ftcat binary in the Experiment object.''' |
| 8 | 8 | ||
| 9 | def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None): | 9 | def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None): |
| 10 | '''Extends the Executable initializer method with ftcat attributes.''' | 10 | '''Extends the Executable initializer method with ftcat attributes.''' |
| 11 | super(FTcat, self).__init__('/usr/bin/taskset') | ||
| 11 | 12 | ||
| 12 | # hack to run FTCat at higher priority | ||
| 13 | chrt_bin = '/usr/bin/chrt' | ||
| 14 | |||
| 15 | super(FTcat, self).__init__(chrt_bin) | ||
| 16 | self.stdout_file = stdout_file | 13 | self.stdout_file = stdout_file |
| 17 | self.stderr_file = stderr_file | 14 | self.stderr_file = stderr_file |
| 18 | 15 | ||
| @@ -23,11 +20,15 @@ class FTcat(Executable): | |||
| 23 | if events is None: | 20 | if events is None: |
| 24 | raise Exception('No events!') | 21 | raise Exception('No events!') |
| 25 | 22 | ||
| 26 | # hack to run FTCat at higher priority | ||
| 27 | self.extra_args = ['-f', '40'] | ||
| 28 | if cpu is not None: | 23 | if cpu is not None: |
| 29 | # and bind it to a CPU | 24 | # Execute only on the given CPU |
| 30 | self.extra_args.extend(['/usr/bin/taskset', '-c', str(cpu)]) | 25 | self.extra_args = ['-c', str(cpu)] |
| 26 | else: | ||
| 27 | # Execute on any cpu | ||
| 28 | self.extra_args = ['0xFFFFFFFF'] | ||
| 29 | |||
| 31 | events_str_arr = map(str, events) | 30 | events_str_arr = map(str, events) |
| 32 | self.extra_args.extend([ft_cat_bin, dev] + events_str_arr) | 31 | ft_cat_cmd = [ft_cat_bin, dev] + list(events_str_arr) |
| 32 | |||
| 33 | self.extra_args.extend(ft_cat_cmd) | ||
| 33 | 34 | ||
