/usr/share/pyshared/tp/netlib/objects/Fail.py is in python-tp-netlib 0.2.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from xstruct import pack
from Header import Processed
class Fail(Processed):
"""\
The Fail packet consists of:
* A UInt32, error code
* A String, may contain useful information for debugging purposes
"""
no = 1
struct = "IS"
reasons = {
0 : "Protocol Error",
1 : "Frame Error",
2 : "Unavailable Permanently",
3 : "Unavailable Temporarily",
4 : "No such thing",
5 : "Permission Denied",
}
def __init__(self, sequence, errno, s=""):
if errno != 0 and sequence < 1:
raise ValueError("Fail is a reply packet so needs a valid sequence number (%i)" % sequence)
Processed.__init__(self, sequence)
# Length is:
# * 4 bytes (uint32 - error code
# * 4 bytes (uint32 - string length)
# * the string
# * null terminator
#
self.length = 4 + 4 + len(s)
self.errno = errno
self.s = s
def __str__(self):
output = Processed.__str__(self)
output += pack(self.struct, self.errno, self.s)
return output
def reason(self):
if self.reasons.has_key(self.errno):
return self.reasons[self.errno]
return "Unknown"
reason = property(reason, doc="A text string representation of the errno")
|