diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-25 16:43:49 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-25 16:43:49 -0400 |
| commit | 15f231a79320cbc97cd88d8a4751515a47ce223e (patch) | |
| tree | b86b202cadc816a5da7b96372b9de4362da88116 /run/proc_entry.py | |
| parent | 2ceaa6c607ef85bde4f14017634d9d1621efca29 (diff) | |
Bug fixes from testing.
Diffstat (limited to 'run/proc_entry.py')
| -rw-r--r-- | run/proc_entry.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/run/proc_entry.py b/run/proc_entry.py index 56f7c24..e222c3d 100644 --- a/run/proc_entry.py +++ b/run/proc_entry.py | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import traceback | ||
| 2 | 3 | ||
| 3 | class ProcEntry(object): | 4 | class ProcEntry(object): |
| 4 | def __init__(self, proc, data): | 5 | def __init__(self, proc, data): |
| 5 | self.proc = proc | 6 | self.proc = proc |
| 6 | self.data = data | 7 | self.data = str(data) |
| 7 | 8 | ||
| 8 | if not os.path.exists(self.proc): | 9 | if not os.path.exists(self.proc): |
| 9 | raise ValueError("Invalid proc entry %s" % self.proc) | 10 | raise ValueError("Invalid proc entry %s" % self.proc) |
| @@ -13,4 +14,10 @@ class ProcEntry(object): | |||
| 13 | with open(self.proc, 'w') as entry: | 14 | with open(self.proc, 'w') as entry: |
| 14 | entry.write(self.data) | 15 | entry.write(self.data) |
| 15 | except: | 16 | except: |
| 16 | print("Failed to write into %s value:\n%s" % (self.proc, self.data)) | 17 | traceback.print_exc() |
| 18 | |||
| 19 | val = str(self.data) | ||
| 20 | val = val if '\n' not in val else '\n'+val | ||
| 21 | |||
| 22 | raise IOError("Failed to write into %s value: %s" % | ||
| 23 | (self.proc, val)) | ||
