[Sugar-devel] [PATCH Log 1/2] pep8-ized logcollect.py

2012-05-10 Thread Manuel Kaufmann
Passed pep8.py script to remove a lot of trailling whitespaces and
things related.

Signed-off-by: Manuel Kaufmann humi...@gmail.com
---
 logcollect.py |  278 ++---
 1 files changed, 146 insertions(+), 132 deletions(-)

diff --git a/logcollect.py b/logcollect.py
index 82c1bba..956cc24 100644
--- a/logcollect.py
+++ b/logcollect.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, Pascal Scheffers pas...@scheffers.net 
+# Copyright (C) 2007, Pascal Scheffers pas...@scheffers.net
 #
 # Permission is hereby granted, free of charge, to any person
 # obtaining a copy of this software and associated documentation
@@ -33,7 +33,7 @@
 #  ** ...
 #  * Installed packages list
 #  * All relevant log files (all of them, at first)
-# 
+#
 # The report is output as a tarfile
 #
 # This file has two modes:
@@ -78,32 +78,32 @@ class MachineProperties:
 return '#/etc/issue not found'
 
 # Needed, because we want to default to the first non blank line:
-first_line = '' 
+first_line = ''
 
 for line in self.__read_file('/etc/issue').splitlines():
 if line.lower().find('olpc build')  -1:
-return line
+return line
 if first_line == '':
-first_line=line
+first_line = line
 
 return first_line
 
 def uptime(self):
 for line in self.__read_file('/proc/uptime').splitlines():
 if line != '':
-return line
+return line
 return ''
 
 def loadavg(self):
 for line in self.__read_file('/proc/loadavg').splitlines():
 if line != '':
-return line
+return line
 return ''
 
 def kernel_version(self):
 for line in self.__read_file('/proc/version').splitlines():
 if line != '':
-return line
+return line
 return ''
 
 def memfree(self):
@@ -126,11 +126,11 @@ class MachineProperties:
 
 v = self.__read_file(mfg_path)
 # Remove trailing 0 character, if any:
-if v != '' and ord(v[len(v)-1]) == 0:
-v = v[:len(v)-1]
-
+if v != '' and ord(v[len(v) - 1]) == 0:
+v = v[:len(v) - 1]
+
 return v
-
+
 def laptop_serial_number(self):
 return self._mfg_data('SN')
 
@@ -141,9 +141,8 @@ class MachineProperties:
 s = self._mfg_data('SG')[0:1]
 if s == '':
 return ''
-
+
 return '%02X' % ord(self._mfg_data('SG')[0:1])
-
 
 def laptop_uuid(self):
 return self._mfg_data('U#')
@@ -165,18 +164,18 @@ class MachineProperties:
 
 def laptop_localization(self):
 return self._mfg_data('LO')
-
+
 def _battery_info(self, item):
  from  /sys/class/power-supply/olpc-battery/ 
 root = '/sys/class/power_supply/olpc-battery/'
-if not os.path.exists(root+item):
+if not os.path.exists(root + item):
 return ''
-
-return self.__read_file(root+item).strip()
+
+return self.__read_file(root + item).strip()
 
 def battery_serial_number(self):
 return self._battery_info('serial_number')
-
+
 def battery_capacity(self):
 return self._battery_info('capacity') + ' ' + \
 self._battery_info('capacity_level')
@@ -184,61 +183,60 @@ class MachineProperties:
 def battery_info(self):
 #Should be just:
 #return self._battery_info('uevent')
-
+
 #But because of a bug in the kernel, that has trash, lets filter:
-bi = ''
+bi = ''
 for line in self._battery_info('uevent').splitlines():
 if line.startswith('POWER_'):
 bi += line + '\n'
-
+
 return bi
-   
+
 def disksize(self, path):
 return os.statvfs(path).f_bsize * os.statvfs(path).f_blocks
-
+
 def diskfree(self, path):
 return os.statvfs(path).f_bsize * os.statvfs(path).f_bavail
-
+
 def _read_popen(self, cmd):
 p = os.popen(cmd)
 s = ''
 try:
 for line in p:
-s += line 
+s += line
 finally:
-p.close()
-
+p.close()
+
 return s
-
-def ifconfig(self):
+
+def ifconfig(self):
 return self._read_popen('/sbin/ifconfig')
-   
-def route_n(self):
+
+def route_n(self):
 return self._read_popen('/sbin/route -n')
-
+
 def df_a(self):
 return self._read_popen('/bin/df -a')
-  
+
 def ps_auxfwww(self):
 return self._read_popen('/bin/ps auxfwww')
-
+
 def usr_bin_free(self):
 return self._read_popen('/usr/bin/free')
 
 def top(self):
 return 

Re: [Sugar-devel] [PATCH Log 1/2] pep8-ized logcollect.py

2012-05-10 Thread James Cameron
On Thu, May 10, 2012 at 06:46:00PM -0300, Manuel Kaufmann wrote:
 Passed pep8.py script to remove a lot of trailling whitespaces and
 things related.

Reviewed-by: James Cameron qu...@laptop.org

On Thu, May 10, 2012 at 06:46:01PM -0300, Manuel Kaufmann wrote:
 When the user creates a zipfile with the log collector utility, all
 his installed activities are listed in info.txt (inside the zipfile)
 and all the sugar logs of the session are attached.

Reviewed-by: James Cameron qu...@laptop.org

 -for path in glob.glob('/home/olpc/Activities/*'):
 +home = os.path.expanduser('~')
 +for path in glob.glob(os.path.join(home, 'Activities', '*')):
  s += '~' + os.path.basename(path) + '\n'

This didn't look right, because of how it apparently corrupts the
name, changing /home/olpc/Activities/Terminal.activity
into ~Terminal.activity but it is how the code was before your patch.
It remains acceptable.

-- 
James Cameron
http://quozl.linux.org.au/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Log 1/2] pep8-ized logcollect.py

2012-05-10 Thread Manuel Kaufmann
On Thu, May 10, 2012 at 7:24 PM, James Cameron qu...@laptop.org wrote:
 This didn't look right, because of how it apparently corrupts the
 name, changing /home/olpc/Activities/Terminal.activity
 into ~Terminal.activity but it is how the code was before your patch.
 It remains acceptable.

Yes. I don't like the way it was implemented but I don't know if those
file are parsed with some script (for example), so I decided not to
change the original text.


-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel