Revision 5bbd3f7f lib/utils.py
b/lib/utils.py | ||
---|---|---|
136 | 136 |
directory for the command; the default will be / |
137 | 137 |
@rtype: L{RunResult} |
138 | 138 |
@return: RunResult instance |
139 |
@raise erors.ProgrammerError: if we call this when forks are disabled |
|
139 |
@raise errors.ProgrammerError: if we call this when forks are disabled
|
|
140 | 140 |
|
141 | 141 |
""" |
142 | 142 |
if no_fork: |
... | ... | |
701 | 701 |
@type ip: str |
702 | 702 |
@param ip: the address to be checked |
703 | 703 |
@rtype: a regular expression match object |
704 |
@return: a regular epression match object, or None if the |
|
704 |
@return: a regular expression match object, or None if the
|
|
705 | 705 |
address is not valid |
706 | 706 |
|
707 | 707 |
""" |
... | ... | |
734 | 734 |
|
735 | 735 |
This function will check all arguments in the args list so that they |
736 | 736 |
are valid shell parameters (i.e. they don't contain shell |
737 |
metacharaters). If everything is ok, it will return the result of |
|
737 |
metacharacters). If everything is ok, it will return the result of
|
|
738 | 738 |
template % args. |
739 | 739 |
|
740 | 740 |
@type template: str |
... | ... | |
1063 | 1063 |
@type args: list |
1064 | 1064 |
@param args: list of arguments to be quoted |
1065 | 1065 |
@rtype: str |
1066 |
@return: the quoted arguments concatenaned with spaces
|
|
1066 |
@return: the quoted arguments concatenated with spaces
|
|
1067 | 1067 |
|
1068 | 1068 |
""" |
1069 | 1069 |
return ' '.join([ShellQuote(i) for i in args]) |
... | ... | |
1080 | 1080 |
@type port: int |
1081 | 1081 |
@param port: the port to connect to |
1082 | 1082 |
@type timeout: int |
1083 |
@param timeout: the timeout on the connection attemp |
|
1083 |
@param timeout: the timeout on the connection attempt
|
|
1084 | 1084 |
@type live_port_needed: boolean |
1085 | 1085 |
@param live_port_needed: whether a closed port will cause the |
1086 | 1086 |
function to return failure, as if there was a timeout |
... | ... | |
1122 | 1122 |
address. |
1123 | 1123 |
|
1124 | 1124 |
@type address: string |
1125 |
@param address: the addres to check |
|
1125 |
@param address: the address to check
|
|
1126 | 1126 |
@rtype: bool |
1127 | 1127 |
@return: True if we own the address |
1128 | 1128 |
|
... | ... | |
1218 | 1218 |
@type size: None or int |
1219 | 1219 |
@param size: Read at most size bytes |
1220 | 1220 |
@rtype: str |
1221 |
@return: the (possibly partial) conent of the file |
|
1221 |
@return: the (possibly partial) content of the file
|
|
1222 | 1222 |
|
1223 | 1223 |
""" |
1224 | 1224 |
f = open(file_name, "r") |
... | ... | |
1378 | 1378 |
Element order is preserved. |
1379 | 1379 |
|
1380 | 1380 |
@type seq: sequence |
1381 |
@param seq: the sequence with the source elementes
|
|
1381 |
@param seq: the sequence with the source elements |
|
1382 | 1382 |
@rtype: list |
1383 | 1383 |
@return: list of unique elements from seq |
1384 | 1384 |
|
... | ... | |
1390 | 1390 |
def IsValidMac(mac): |
1391 | 1391 |
"""Predicate to check if a MAC address is valid. |
1392 | 1392 |
|
1393 |
Checks wether the supplied MAC address is formally correct, only |
|
1393 |
Checks whether the supplied MAC address is formally correct, only
|
|
1394 | 1394 |
accepts colon separated format. |
1395 | 1395 |
|
1396 | 1396 |
@type mac: str |
... | ... | |
1831 | 1831 |
|
1832 | 1832 |
""" |
1833 | 1833 |
if isinstance(text, unicode): |
1834 |
# onli if unicode; if str already, we handle it below
|
|
1834 |
# only if unicode; if str already, we handle it below
|
|
1835 | 1835 |
text = text.encode('ascii', 'backslashreplace') |
1836 | 1836 |
resu = "" |
1837 | 1837 |
for char in text: |
Also available in: Unified diff