create vm using pyvbox module - python-2.7

I'm using the pyvbox, the complete implementation of the virtualBox main API. In my use case i just want to write a python code in order to start and stop VMs. When i use python GUI every things works fine.But when i try to run the python code from the CMD i got this error:
echec de l'ouverture de session pour la machine 'test'
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: C:\Program Files\Oracle\VirtualBox\VBoxSVC.exe
R6025
-pure virtual function call
PS:
python version 2.7.11
pyvbox 1.0.0
OS windows 8
startvm.py:
import virtualbox
vbox = virtualbox.VirtualBox()
session = virtualbox.Session()
vm = vbox.find_machine('test_vm')
progress = vm.launch_vm_process(session, 'gui', '')

probably you don't need any help on this anymore :D, but I write it here anyway, maybe it can be helpful to someone.
Starting and stopping a VM with the python pyvbox library is very simple:
import virtualbox
from vboxapi import VirtualBoxManager
vbox = virtualbox.VirtualBox()
session = virtualbox.Session()
# This part starts the machine:
# machine_name is a simple string containing the name of your VM. For example "ubuntu"
machine = vbox.find_machine(machine_name)
proc = machine.launch_vm_process(session, "headless")
proc.wait_for_completion(timeout=-1)
# This part stops it:
process, unused_variable = session.machine.take_snapshot("snapshot_name", "snapshot_description", False)
# False means "do not pause the machine while snapshotting"
process.wait_for_completion(timeout=-1)
session.unlock_machine()
I created a simple script to automatically snapshot my virtual machines.
GitHub:
https://github.com/Meru3m/virtualbox-snapshotter

Related

LLDB SBProcess stuck on launching Ubuntu 18.04

I'm getting started with LLDB and am following the tutorial here: https://lldb.llvm.org/python_reference/lldb.SBDebugger-class.html. Whenever I Launch a target the process gets stuck in the launching state and will never launch. I've tried lldb in bash and it works perfectly. I've read through the documentation with the tutorial and can't find an explanation about the launching state, or how to discover what is causing it to get stuck.
System is Ubuntu 18.04 64 bit dual core 8GB RAM using python2.7.
The most simple code to reproduce the error is as follows:
import lldb
import os
exe = './a.out'
db = lldb.SBDebugger.Create()
db.SetAsync(False)
target = db.CreateTargetWithFileAndArch(exe, 'x86_64-linux-gnu')
pro = target.LaunchSimple(None,None,os.getcwd())
print(pro)
Running the python code will always give me the following output:
SBProcess: pid = 0, state = launching, threads = 0, executable = a.out
The a.out is just a heloworld.cpp compiled with clang++ -fstandalone-debug
UPDATE:
Thanks to Jim's suggestion I tried SBTarget.Launch() instead and used the error to discover that lldb could not find lldb-server-6.0.0 because it installs as lldb-server-6.0
The Fix
sudo ln -s /usr/bin/lldb-server6.0 /usr/bin/lldb-server6.0.0

lldb cannot connect to debugserver using python API

I'm trying to connect to debugserver on Mac, using lldb. While the following set of commands work fine and in the lldb cli, the same set of commands fails with error: the platform is not currently connected when run from python using the debugger.GetCommandInterpreter().HandleCommand.
I also tried using the direct Python APIs without much luck. Though, I'm interested to learn more about the difference and making it work with interpreter in python.enter code here
For more context: https://github.com/vadimcn/vscode-lldb/issues/411
Start debug server:
$ lldb/bin/debugserver 127.0.0.1:1234
...
lldb CLI (works):
(lldb) platform select remote-macosx
(lldb) target create ~/Projects/vscode-lldb/build/debuggee/debuggee
(lldb) process connect connect://127.0.0.1:1234
(lldb) process launch
Process 64302 launched: '/Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee' (x86_64)
...
Python (error: the platform is not currently connected):
>>> import sys; sys.path.append('/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python3')
>>> from lldb import *
>>> debugger = SBDebugger.Create()
>>> inter = debugger.GetCommandInterpreter()
>>> res = SBCommandReturnObject()
>>> commands = ['platform select remote-macosx', 'target create /Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee', 'process connect connect://127.0.0.1:1234', 'process launch']
>>> for command in commands: inter.HandleCommand(command, res); print(command); print(res.Succeeded()); print(res.GetOutput(), "\n", res.GetError())
...
2
platform select remote-macosx
True
Platform: remote-macosx
Connected: no
1
target create /Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee
True
Current executable set to '/Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee' (x86_64).
1
process connect connect://127.0.0.1:1234
True
There is a running process, kill it and restart?: [Y/n] y
6
process launch
False
error: the platform is not currently connected
The same behaviour is observed when trying to connect to debugserver running locally on Mac or forwarded debugserver from iOS.

Spider Run button doesn't behave as expected

I am a newbie with python and today I have tried to set the Spyder IDE to run PySide clases in order to make some applications. The thing is, once Spyder was installed (Spyder (Python 2.7) in Ubuntu) I tried to launch a hello world in order to check if all was correctly tied up. Before installing Spyder I had Python 2.7 with the PySide packages properly intalled. This is what my PySide Hello World program look like:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
# Create a Qt application
app = QApplication(sys.argv)
# Create a Label and show it
label = QLabel("Hello World")
label.show()
# Enter Qt application main loop
app.exec_()
sys.exit()
When I tried to run the code pushing the Run File button (F5) the console only shows
runfile('/home/leo/.spyder2/temp.py', wdir='/home/leo/.spyder2')
And the same thing selectig a IPython console throws
runfile('/home/leo/.spyder2/temp.py', wdir='/home/leo/.spyder2')
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
...etc...
But nothing happens, no application launched. However, if I select the whole text in the code editor, and then press F9 (which only executes the selected lines) everything works fine and the test application pops up!!! This happens with both Console and IPython Console.
I looked for some explanation about this awkward behaviour on the internet (like this post spider IDE python. Difference in running by pressing F5 and F9?) but in the end my question ends unanswered...
One more thing, executing the code in IPython console succesfully launches the test application, but once it is closed, a second attempt in the same console throws en error
RuntimeError: A QApplication instance already exists.
Any help would be very appreciated, thank you community.

c++, Voce - how to compile a project?

My problem is that I wanted to try out Voce, however I wasn't able to start a sample program. I had to tweak lots of things, and as I can see the only remaining barrier between me and Voce is the following error(hopefully):
whenever I compile the sample program, it compiles succesfully but then, when I would like to launch it it gives me the following error:
[Voce] Java virtual machine created
[Voce ERROR] The requested Java class: voce/SpeechInterface could not be found. Make sure the class path correctly points to the Voce classes.
This is a speech recognition test. Speak digits from 0-9 into the microphone. Speak 'quit' to quit.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f0824ffcbd2, pid=7537, tid=139672968279936
#
# JRE version: OpenJDK Runtime Environment (8.0_72-b15) (build 1.8.0_72-internal-b15)
# Java VM: OpenJDK 64-Bit Server VM (25.72-b15 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x651bd2]
#
# Core dump written. Default location: /home/username/testAudio/folder/core or core.7537
#
# An error report file with more information is saved as:
# /home/username/testAudio/folder/enter code herehs_err_pid7537.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
This is the whole ouput.
Further information: I'm using Kubuntu as an OS(so Linux, basically).
Thank you in advance!
Meanwhile I was able to fix this issue.
I will post the solution in case anyone will experience the same issues:
I just had to edit the cpp files to match the location of the lib folder, because my program couldn't find it.

Run python script with droneapi without terminal

I managed to run examples in command prompt after running mavproxy.py and loading droneapi. But when I double click on on my script, it throws me "'local_connect' is not defined", it runs in terminal as was told above, but I cannot run it only with double click. So my question is: Is there any way to run script using droneapi only with double click?
using Windows 8.1
Thanks in advance
You'll want to look at the Running an App/Example section of the guide. For now, you can only run a DroneKit script by launching it from inside the MAVProxy terminal. For example, after launching:
$ mavproxy.py --master=127.0.0.1:14550
MANUAL> module load droneapi.module.api
DroneAPI loaded
You can use the api start command to run a local script:
MANUAL> api start vehicle_state.py
STABILIZE>
Get all vehicle attribute values:
Location: Attitude: Attitude:pitch=-0.00405988190323,yaw=-0.0973932668567,roll=-0.00393210304901
Velocity: [0.06, -0.07, 0.0]
GPS: GPSInfo:fix=3,num_sat=10
groundspeed: 0.0
airspeed: 0.0
mount_status: [None, None, None]
Mode: STABILIZE
Armed: False
I think Sony Nguyen is asking for running the vehicle_state.py outside the Mavproxy command prompt, just like runnning the .py file normally.
I'm also looking for a solution as well.
You can only run dronekit from mavproxy at the moment (its structured as a mavproxy module, there are plans to restructure it), however if you simply want to avoid having to load up MavProxy and then running code manually, you can use the cmd flag:
mavproxy.py --cmd="api start app.py"