Commit Graph

41 Commits

Author SHA1 Message Date
Cole Robinson
d2648d81cc virtconv: Don't implicitly depend on dict hash order 2017-10-20 16:13:04 -04:00
Radostin Stoyanov
37ea520773 Replace 'StandardError' with 'Exception'
Python 2 has an exception class called StandardError that has
been removed in Python 3. Use Exception instead. [1]

[1] http://python3porting.com/differences.html#standarderror
2017-10-20 13:18:31 -04:00
Radostin Stoyanov
63fce081ed pycodestyle: Use isinstance() for type checking
This is E721 in pycodestyle [1]:
   "do not compare types, use ‘isinstance()’"

The main differece between "type() is" and "isinstance()" is that
isinstance() supports inheritance. [1]

This can be seen in the example below:
    >>> type(True) is int
    False
    >>> isinstance(True, int)
    True

As we can see in python 'bool' a subclass of 'int'.

[1] https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
[2] https://docs.python.org/2/library/functions.html#isinstance
2017-10-20 11:49:13 -04:00
Radostin Stoyanov
b93cc3bbc9 pycodestyle: Do not use bare 'except:'
A bare 'except:' catches all exceptions [1], including SystemExit,
KeyboardInterrupt, and GeneratorExit (which is not an error and should
not normally be caught by user code). In situations where you need to
catch all “normal” errors, you can catch the base class for all normal
exceptions, Exception [2].

[1] https://docs.python.org/2/howto/doanddont.html#except
[2] https://docs.python.org/2/library/exceptions.html#Exception
2017-08-02 13:57:43 -04:00
Cole Robinson
55288c4551 Convert to python3 style print() syntax
Use __future__ imports to keep this working for python2
2017-05-05 14:52:37 -04:00
Cole Robinson
62feeb02a8 Switch to python3 style 'except X as Y' notation
Which also works with python2.7
2017-05-05 14:52:11 -04:00
Cole Robinson
f4dfb6de9d Fix recent pylint/pep8 output 2016-04-18 16:42:12 -04:00
Lin Ma
f11eb00b9a virt-convert: decompress the .gz files before converting
The OVF specification v1.1.0(page 15) indicates that "Each file
referenced by a File element may be compressed using gzip
(see RFC1952)."

In this case the .gz files should be decompressed first before
converting through qemu-img.

Signed-off-by: Lin Ma <lma@suse.com>
2016-03-09 20:06:16 -05:00
Michal Privoznik
58ac786b6b virt-convert: Don't detect existing paths in test suite
We have this option --dry-run that should run through the
installation process but don't actually touch anything. Just
pretend the installation. And we have a test that uses it
heavily. However, the test is failing:

  Traceback (most recent call last):
    File "/home/zippy/work/virt-manager.git/tests/clitest.py", line 161, in _launch_command
      ret = virtconvert.main(conn=conn)
    File "virt-convert", line 111, in main
      destdir=options.destination, dry=options.dry)
    File "/home/zippy/work/virt-manager.git/virtconv/formats.py", line 314, in convert_disks
      newpath)
  RuntimeError: New path name '/var/lib/libvirt/images/fedora.qcow2' already exists

Problem is, even in test suite we really touch the host paths.
This in general will spit unpredictable results. Resolution
consists of making this specific part of the code fault tolerant
if ran under test suite.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-15 11:42:37 -05:00
Lin Ma
21fd079eb1 Replace the unar to more common archivers
Because some of distributions dont provide the unar (universal archiver),
Using more common archivers to replace it.

Signed-off-by: Lin Ma <lma@suse.com>

(crobinso: adjust test suite)
2016-01-10 18:23:29 -05:00
Pavel Hrdina
c7049eb120 pep8 W503: line break before binary operator
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-07-14 13:01:20 -04:00
Pavel Hrdina
0fbe8e7a1f translation: fix wrong usage of _() function
All the strings have to be at first translated and then we can fill the
formated and translated string.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-06-05 16:33:51 -04:00
Cole Robinson
45e6cd4cac Remove redundant 'default dir' functions 2015-05-02 19:48:04 -04:00
Cole Robinson
97259c4d9b capabilities: Store results of guest_lookup together
Simplifies API users lives to not have to remember whether caps guest
or caps domain contains a particular value.
2015-04-03 17:37:08 -04:00
Cole Robinson
e3de3d8b69 virt-convert: Fix pointing to relative config file 2014-09-20 18:29:20 -04:00
Cole Robinson
eb7612356e virtinst: Switch to relative imports, fix cyclic import warnings 2014-09-12 16:28:38 -04:00
Chen Hanxiao
75d43f6a37 fix some missed binary prefixes for units
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-06-17 09:33:14 +08:00
Cole Robinson
506791157e Fix some pylint 2014-05-31 17:37:19 -04:00
Cole Robinson
eca6cd9471 virt-convert: Don't print 'convert' output with --print-xml 2014-05-31 16:41:30 -04:00
Cole Robinson
ceab99cf7b virtconv: Don't create default pool when in dry mode
We will still need to create pools to probe source storage if doing
--print-xml.
2014-05-31 16:30:00 -04:00
Cole Robinson
876c721d8e virt-convert: Fix use of relative OVF file 2014-05-31 16:05:29 -04:00
Cole Robinson
196ff823b3 Fix warnings with latest pep8 2014-05-02 10:20:59 -04:00
Chen Hanxiao
98a27fc7fd formats: make sure 'unar' is existed
Commit 0b4a72fd77
need unar command to do something.

But if we haven't installed it, the error message
told us nothing valuable as:
"OSError: [Errno 2] No such file or directory"

This patch will impove the error message.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-03-06 09:22:03 +08:00
Cole Robinson
0b4a72fd77 virt-convert: Reimplement it
We totally break CLI compat here, but the previous tool wasn't sustainable.
Instead, repurpose the tool as strictly converting external formats
like ovf/vmx to native libvirt XML, and launch the guest.

So we drop vmx/virt-image output, and virt-image input, and a slew of
command line options. I don't think anyone was depending on this in a
scripted fashion, so in practice I don't think anyone will care.

Add much more comprehensive unit tests while we are at it.
2014-02-07 21:16:09 -05:00
Giuseppe Scrivano
2a040ccd17 mass update: remove double spaces from comments
Updated by this script:

find -name '*.py' -exec sed -i "s|^\(#.*[^.?\!]\)  \(.*[^#]\)$|\1 \2|g" \{\} \;

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2013-10-28 17:22:31 +01:00
Giuseppe Scrivano
0df75c7603 headers: update "Red Hat, Inc." copyright for the year 2013
Ensure that any file touched by a @redhat.com author in 2013 has an
updated copyright header.

The files were updated using the build-aux/update-copyright gnulib
script and manually added where the copyright line wasn't present.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2013-10-28 17:22:26 +01:00
Cole Robinson
a6d92c7001 Drop a lot of usage of utility XML functions 2013-09-22 17:34:53 -04:00
Cole Robinson
c426d5a16f Guest: Drop os_type, just use single os_variant
Internally the distinction hasn't been valuable for a long time,
so simplify the API here.
2013-08-11 12:39:36 -04:00
Cole Robinson
1d0695abd2 virtconv: Drop reference to OS_TYPES 2013-08-11 12:39:28 -04:00
Cole Robinson
01629d3f2c virtinst: Combine ImageInstaller and ImageParser code
They aren't touched much these days, so unify the files for clarity.
2013-08-08 21:00:37 -04:00
Cole Robinson
0d5fe93048 Centralize XML helpers in virtinst/util.py 2013-07-12 13:10:23 -04:00
Cole Robinson
94f8d4cfa9 VirtualConnection: cache capabilities XML
This means we can drop passing around the pre-parsed caps info everywhere.
2013-07-06 14:12:13 -04:00
Cole Robinson
4672ed3a0a Drop most explicit SunOS support
We haven't had a patch from Sun/Oracle in over 4 years, nor a libvirt
patch in about as long. I don't think anyone cares.
2013-07-03 12:15:56 -04:00
Cole Robinson
191fff8c0c tests: Make sure virtinst doesn't pull in Gtk
Add an explicit test to warn if it inadvertently happens
2013-04-18 16:41:02 -04:00
Cole Robinson
0d243983d0 Revive pep8 and clean up the code
autopep8 is pretty cool :)
2013-04-13 15:22:43 -04:00
Cole Robinson
3f79fa3919 Fix the last of the pylint messages
If using an older pylint, there are still some complaints about hashlib
and Popen, but those aren't our problems.
2013-04-13 13:45:08 -04:00
Cole Robinson
9359ad2bb6 virtinst: Remove ParaVirt and FullVirtGuest
They were just around for back compat at this point, the tools
have moved on.
2013-04-13 13:40:45 -04:00
Cole Robinson
ae471007fc Tons of misc pylint fixes 2013-04-13 13:40:29 -04:00
Cole Robinson
a386186c74 Remove most map() and filter() usage
They aren't available on python3 so pylint complains, and list
comprehensions are usually better.
2013-04-12 08:27:44 -04:00
Cole Robinson
d6c8ad0297 Wire up python unit tests, unify gettext setup 2013-04-03 18:22:05 -04:00
Cole Robinson
88603e4fad Merge code from python-virtinst.git
As outlined here:

https://www.redhat.com/archives/virt-tools-list/2012-February/msg00040.html

For now this is just a direct import of the code from virtinst commit
dca5a4d6245f21d554f8853197a6a234bfc8e52c. History is not merged, so
please refer to original git for detailed commit histor:

http://git.fedorahosted.org/cgit/python-virtinst.git/
2013-04-03 18:22:05 -04:00