How to edit offline vmx file using python

S

sasikiran2k7

Hi,

I am new to python, how can we edit a .vmx file offline or just simply a file containing the data in the below format.

My file sample.vmx contains data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testvmdk.nvram"
virtualHW.productCompatibility = "hosted"
powerType.powerOff = "soft"
powerType.powerOn = "hard"


I need to update those values and the updated file should contains the data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testing.nvram"
virtualHW.productCompatibility = "hosted"
powerType.poweroff='hard"
powerType.poweron="sof't"


Can anyone please help me in solving this problem

Thanks,
Sasikiran
 
D

Dave Angel

Hi,

I am new to python, how can we edit a .vmx file offline or just simply a file containing the data in the below format.

My file sample.vmx contains data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testvmdk.nvram"
virtualHW.productCompatibility = "hosted"
powerType.powerOff = "soft"
powerType.powerOn = "hard"


I need to update those values and the updated file should contains the data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testing.nvram"
virtualHW.productCompatibility = "hosted"
powerType.poweroff='hard"
powerType.poweron="sof't"

Since the file is tiny, start by reading it all into memory, into a
list. Then replace last two line's 16th character with a lowercase "O"
And replace the last line's string following the equals sign with the
string "\"sof't\"

There are also some spacing differences, but they're harder to describe,
and I suspect they were accidental.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,303
Latest member
Ketonara

Latest Threads

Top