git://git.onelab.eu
/
nodemanager.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3107314
)
wrap open() with try/except
author
Barış Metin
<Talip-Baris.Metin@sophia.inria.fr>
Wed, 21 Oct 2009 15:42:34 +0000
(15:42 +0000)
committer
Barış Metin
<Talip-Baris.Metin@sophia.inria.fr>
Wed, 21 Oct 2009 15:42:34 +0000
(15:42 +0000)
tools.py
patch
|
blob
|
history
diff --git
a/tools.py
b/tools.py
index
941838b
..
122b321
100644
(file)
--- a/
tools.py
+++ b/
tools.py
@@
-18,18
+18,21
@@
def get_default_if():
return interface
def get_hwaddr_from_plnode():
return interface
def get_hwaddr_from_plnode():
- for line in open("/usr/boot/plnode.txt", 'r').readlines():
- if line.startswith("NET_DEVICE"):
- return line.split("=")[1].strip().strip('"')
+ try:
+ for line in open("/usr/boot/plnode.txt", 'r').readlines():
+ if line.startswith("NET_DEVICE"):
+ return line.split("=")[1].strip().strip('"')
+ except:
+ pass
return None
def get_if_from_hwaddr(hwaddr):
return None
def get_if_from_hwaddr(hwaddr):
- import sioc
- devs = sioc.gifconf()
- for dev in devs:
- dev_hwaddr = sioc.gifhwaddr(dev)
- if dev_hwaddr == hwaddr: return dev
- return None
+
import sioc
+
devs = sioc.gifconf()
+
for dev in devs:
+
dev_hwaddr = sioc.gifhwaddr(dev)
+
if dev_hwaddr == hwaddr: return dev
+
return None
def as_daemon_thread(run):
"""Call function <run> with no arguments in its own thread."""
def as_daemon_thread(run):
"""Call function <run> with no arguments in its own thread."""