aboutsummaryrefslogtreecommitdiff
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
parent59d49233ae2efd0c3a52e511d5ff8e1fe182b0c0 (diff)
h-client:improved the way pci devices are detected
-rw-r--r--h-client/hclient.py4
-rw-r--r--h-client/hlibrary.py31
2 files changed, 18 insertions, 17 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
index 9629319..8401c81 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -739,9 +739,9 @@ class hclient:
treesw = gtk.ScrolledWindow()
- treesw.set_size_request(110,401)
+ treesw.set_size_request(140,401)
treesw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- treesw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ treesw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
treesw.add(self.tree)
self.leftWindow.set_border_width(5)
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')