scripts: Python3 support for scripts/nbd_client.py

Standard exceptions are build-in now, and 'exceptions' module
was removed from Python3.

Use bytes instead of string, since no implicitly conversion between
them in Python3.

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/imgedit.py

* Use floor division. As in Python3, the default division is float division.
* Encode string when bytes are required.
* Use Python3 style print function.

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/osv/modules/resolve.py

* Use Python3 style print function.
* Fix inconsistent use of tabs and spaces.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/osv/modules/filemap.py

* dict.iteritems() and itertools.ifilter() are removed form Python3, use
dict.items(), and build-in filter() function.
* Change loop variable name to avoid shadow build-in filter() function.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/module.py

* Use Python3 style print function.
* 'basestring' is removed from Python3, use 'str' instead.
* reduce() is removed from build-ins in Python3, import it from functools.

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: leave only one '[manifest]' in manifest files

Started in Python 3.2, configparser will not allow for any section
duplicates while reading from file by default. This change of default
behavior will cause upload_manifest.py failing. So make sure only one
[manifest] section tag left while generating manifest files.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/upload_manifest.py

* StringIO and ConfigParser are removed from Python3, use io.StringIO
and configparser instead.
* The backported io.StringIO requires unicode string not basestring in
Python2.
* Use Python3 style print function.
* Send bytes through socket to guest instead of string, and decode bytes
read from sys.stdout.

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/mkzfs.py

* StringIO and ConfigParser are removed from Python3, use io.StringIO
and configparser instead.
* The backported io.StringIO requires unicode string not basestring in
Python2.
* file() removed from Python3, use open().

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Python3 support for scripts/mkbootfs.py

* StringIO and ConfigParser are removed from Python3, use io.StringIO
and configparser instead.
* The backported io.StringIO requires unicode string not basestring in
Python2.
* file() removed from Python3, use open().
* Use bytes instead of string when packing with format 's'.

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>