From c1553467a6597aa516e0351fade8a12dcf3d06e4 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Wed, 4 May 2011 15:34:12 +0000 Subject: h-client:improved the way pci devices are detected --- h-client/hclient.py | 4 ++-- h-client/hlibrary.py | 31 ++++++++++++++++--------------- 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') -- cgit v1.2.3