LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   Virtual Machine Manager - Invalid Syntax (https://www.linuxquestions.org/questions/red-hat-31/virtual-machine-manager-invalid-syntax-683567/)

rajeshux 11-15-2008 08:49 AM

Virtual Machine Manager - Invalid Syntax
 
Hi Linuxies!,

I was successfull in setting local repos and installing all dependencies for xen and virt-manager packages.

When I try to open virtual manager machine in gnome, i'm getting following error.

Code:

Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virt-manager.py", line 346, in ?
    main()
  File "/usr/local/share/virt-manager/virt-manager.py", line 287, in main
    from virtManager.engine import vmmEngine
  File "/usr/local/share/virt-manager/virtManager/engine.py", line 31, in ?
    from virtManager.connection import vmmConnection
  File "/usr/local/share/virt-manager/virtManager/connection.py", line 36, in ?
    from virtManager.domain import vmmDomain
  File "/usr/local/share/virt-manager/virtManager/domain.py", line 669
    finally:
          ^
SyntaxError: invalid syntax

? I googled the error, it said something about "try,finally" python constructs. Can U globe it out.

:)
Rajesh SR,Bangalore,India.

stuart_cherrington 11-17-2008 05:52 AM

Did you run a command to open the Virtual manager? If so, what was it?

Stuart.

mmarshall 11-19-2008 03:53 PM

My first guess is that you're running python 2.3 or earlier, but this code is written for python 2.4 or later.

MWM

mmarshall 11-19-2008 03:55 PM

Oops, I got my python versions mixed up. The code requires python 2.5 but you probably have 2.4.

Here's a simple patch to domain.py that fixes the problem:

http://hg.et.redhat.com/virt/applica...s=a8cafeaa92a6

MWM

rajeshux 11-19-2008 11:32 PM

I'm running from Gnome, system-tools->Virtual Machine Manager.

I'm currently using python 2.4.

How to apply the patch or should i install python 2.5 ?

mmarshall 11-20-2008 10:35 AM

I would just apply the patch manually.

Open up /usr/local/share/virt-manager/virtManager/domain.py, go to line 660, and change the code that looks like this:

Code:

        ctx = None
        ret = []
        try:
            doc = libxml2.parseDoc(self.get_xml())
            ctx = doc.xpathNewContext()
            ret = parse_function(ctx)
        except Exception, e:
            logging.debug("Error parsing domain xml: %s" % str(e))
        finally:
            if ctx:
                ctx.xpathFreeContext()

... so that it looks like this:

Code:

        ctx = None
        ret = []
        try:
            try:
                doc = libxml2.parseDoc(self.get_xml())
                ctx = doc.xpathNewContext()
                ret = parse_function(ctx)
            except Exception, e:
                logging.debug("Error parsing domain xml: %s" % str(e))
        finally:
            if ctx:
                ctx.xpathFreeContext()

You're just adding four spaces before every line between the "try:" and "finally:" lines and adding a second "try:" line. Make sure to get the indention just like I show above, using spaces, not tabs.

MWM


All times are GMT -5. The time now is 02:37 PM.