blob: e222c3d3f5985f9b4f51a35bd9d548d355814522 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import os
import traceback
class ProcEntry(object):
def __init__(self, proc, data):
self.proc = proc
self.data = str(data)
if not os.path.exists(self.proc):
raise ValueError("Invalid proc entry %s" % self.proc)
def write_proc(self):
try:
with open(self.proc, 'w') as entry:
entry.write(self.data)
except:
traceback.print_exc()
val = str(self.data)
val = val if '\n' not in val else '\n'+val
raise IOError("Failed to write into %s value: %s" %
(self.proc, val))
|