bmaptool: assign user-friendly names to file objects
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 6 May 2013 09:29:22 +0000 (12:29 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 6 May 2013 14:58:37 +0000 (17:58 +0300)
commit000309ce91f7b8eb967745fa426e07cf648f8b4b
treeee6d89cb746d3a9c568c7b23c34fa577c808035d
parent577e15ee08970f3c09413feef3421488e270c2bd
bmaptool: assign user-friendly names to file objects

Just like many things in python, BmapCopy assumes that file-like objects'
'name' attribute contains something user-frienly. And this is the case in most
of the cases, except one case. If the file object was created using
'os.fdopen()', the name will be '<fdopen>', instead of something user-friendly.
And bmaptool uses 'os.fdopen()' when opening block devices, because we need to
use special open flags. This results in poor error messages like this:

bmaptool: ERROR: wrote 187980 blocks from image
  'ivi-wayland-tizen-2.0a_20130501.1-sdb.raw.bz2' to '<fdopen>' ...

And the problem is that you cannot change the name - it is a read-only
attribute. This problem will probably be resolved in python 3, but not in 2.x,
see http://bugs.python.org/issue1625576

This patch works-around the problem by creating own simple dummy class which
overrides the name.

Change-Id: Ia6c8565c414c5e57d294d83c0fe5758e7b5aa518
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptool