aboutsummaryrefslogtreecommitdiff
path: root/h-client/hlibrary.py
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-05-04 15:34:12 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-05-04 15:34:12 +0000
commitc1553467a6597aa516e0351fade8a12dcf3d06e4 (patch)
tree527c35ccb00006f1aa3737c4eb466a53f29b7b80 /h-client/hlibrary.py
parent59d49233ae2efd0c3a52e511d5ff8e1fe182b0c0 (diff)
h-client:improved the way pci devices are detected
Diffstat (limited to 'h-client/hlibrary.py')
-rw-r--r--h-client/hlibrary.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index b78f452..389eff3 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -149,11 +149,12 @@ class Device(object):
#get the h-source distro code of the user
def userDistribution(self):
- if not os.system('cat /etc/*-release | grep CODENAME > tmp/temp'):
- f = open('tmp/temp','r')
- row = f.readline().replace("\n","").lower()
- return self.getDistroCode(row)
+ if not os.system('cat /etc/*-release | grep CODENAME > tmp/distro'):
+ f = open('tmp/distro','r')
+ row = f.readline().rstrip("\n").lower()
f.close();
+ os.system('rm -f tmp/distro')
+ return self.getDistroCode(row)
else:
self._status = False
self.errors.append('tmp folder not writable')
@@ -495,10 +496,11 @@ class Client:
#get the system kernel
def getKernel(self):
- if not os.system('uname -r > tmp/temp'):
- f = open('tmp/temp','r')
+ if not os.system('uname -r > tmp/kernel'):
+ f = open('tmp/kernel','r')
row = f.readline().replace("\n","")
f.close();
+ os.system('rm -f tmp/kernel')
return row
else:
self._status = False
@@ -591,15 +593,14 @@ class Client:
while 1:
row = f.readline()
-
+
if not row:
break
#get the slot
if row.find('Slot') != -1:
-
#get the class
- row = f.readline().replace("\n","")
+ row = f.readline().rstrip("\n")
if row:
cl = re.match('Class\:(.*)\[(.*)\]',row,re.I)
if cl:
@@ -609,18 +610,18 @@ class Client:
#set the type attribute of the device object
dev.setType(self.getType(cl.group(2)))
#get the vendorid
- row = f.readline().replace("\n","")
+ row = f.readline().rstrip("\n")
if row:
vn = re.match('Vendor\:(.*)\[(.*)\]',row,re.I)
if vn:
- dev.setVendorId(vn.group(2).replace("\t",""))
+ dev.setVendorId(vn.group(2).lstrip("\t"))
#get the productid
- row = f.readline().replace("\n","")
+ row = f.readline().rstrip("\n")
if row:
pr = re.match('Device\:(.*)\[(.*)\]',row,re.I)
if pr:
- dev.setProductId(pr.group(2).replace("\t",""))
- dev.setModel(pr.group(1).replace("\t",""))
+ dev.setProductId(pr.group(2).lstrip("\t"))
+ dev.setModel(pr.group(1).lstrip("\t"))
dev.setKernel(self.getKernel())
@@ -637,7 +638,7 @@ class Client:
else:
self.errors.append('tmp folder not writable')
-
+
#parse the output of the lspci command
if not os.system('lsusb -v > tmp/temp'):
f = open('tmp/temp','r')