noteirak wrote:Please show the output of your code, and stacktrace of error if you have one.
This output if I run standart command ls -la
Code: Select all
args = ["-l", "-a"]
gp = gs.processCreate('/bin/ls', args, [], [vbm.constants.ProcessCreateFlag_WaitForStdOut], 0)
and disable "if" in "while" loop where check status code "gp.status" because statment never passed
Code: Select all
if gp.status == vbm.constants.ProcessStatus_TerminatedNormally or \
gp.status == vbm.constants.ProcessStatus_Terminating or \
gp.status == vbm.constants.ProcessStatus_TerminatedSignal or \
gp.status == vbm.constants.ProcessStatus_TerminatedAbnormally or \
gp.status == vbm.constants.ProcessStatus_TimedOutKilled or \
gp.status == vbm.constants.ProcessStatus_TimedOutAbnormally:
Code: Select all
"C:\Program Files (x86)\Python27\python.exe" D:/projects/vbautotest/run.py
1
Result status for wating guest process: 9
.
..
bin
boot
dev
etc
home
initrd.img
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
vmlinuz
100
Process exit code: 0
Exception RuntimeError: 'sys.meta_path must be a list of import hooks' in <bound method VirtualBoxManager.__del__ of <vboxapi.VirtualBoxManager object at 0x020A7A90>> ignored
Process finished with exit code 0
This out when I try call git:
Code: Select all
1
try!
Result status for wating guest process: 9
100
Process exit code: 0
Exception RuntimeError: 'sys.meta_path must be a list of import hooks' in <bound method VirtualBoxManager.__del__ of <vboxapi.VirtualBoxManager object at 0x01F17A70>> ignored
In a while loop I checked event, but I think is wrong statement because variable "ev" saved object Library.Event and how check his empty or not I don't know
Code: Select all
ev = es.getEvent(el, 200)
if ev != '':
es.eventProcessed(el, ev)
noteirak wrote:Please show the output of your code, and stacktrace of error if you have one.
UPD:
I change my script, for see more output detaile.
This my code:
Code: Select all
def run_test():
vbm = VirtualBoxManager()
vbox = vbm.vbox
session = vbm.getSessionObject(vbox)
mach = vbox.findMachine(TARGET_NAME)
try:
mach.lockMachine(session, 1)
console = session.console
guest = console.guest
# gs = session.console.guest.createSession('t4ks', 'Qwerty123', '', '')
t = 50 * 1000
gs = guest.createSession('t4ks', 'Qwerty123', '', 'rungit')
gs_state_result = gs.waitForArray([vbm.constants.GuestSessionWaitForFlag_Start], t)
print gs_state_result
#args = ["-l", "-a"]
#gp = gs.processCreate('/bin/ls', args, [], [vbm.constants.ProcessCreateFlag_WaitForStdOut], 0)
args = ["clone", "<repo>", "/home/t4ks/pyteamcity"]
gp = gs.processCreate('/usr/bin/git', args, None, [vbm.constants.ProcessCreateFlag_WaitForStdOut], t)
gps = gs.processes
for i in gps:
gp_foo = i
print "Arguments: ", gp_foo.arguments
print "Ex path: ", gp_foo.executablePath
print "PID: ", gp_foo.PID
print "Status: " , gp_foo.status
foo = []
foo.append(vbm.constants.ProcessWaitForFlag_StdOut)
waitResult = gp.waitForArray(foo, t)
stdOut = gp.read(1, 10000, t)
print stdOut
if waitResult == vbm.constants.ProcessWaitResult_StdOut:
print "Process Load finished"
except:
print traceback.format_exc()
now I see process info, but git output not steel working:
Code: Select all
Arguments: (u'clone', u'<repo>', u'/home/t4ks/pyteamcity')
Ex path: /usr/bin/git
PID: 1490
Status: 100
Win32 exception occurred releasing IUnknown at 0x001aeff4
Win32 exception occurred releasing IUnknown at 0x040122a0
Win32 exception occurred releasing IUnknown at 0x001fb724
Win32 exception occurred releasing IUnknown at 0x001fbbec
Process finished with exit code 0
--------------UPD2-------------------
Great! I solved problem(not be sure what right). I added stdOut and errOut. And add in argument list args[] first element '/usr/lib/git' and it's working! WTF? =) How it can at be?
this my code:
Code: Select all
def run_test():
vbm = VirtualBoxManager()
vbox = vbm.vbox
session = vbm.getSessionObject(vbox)
mach = vbox.findMachine(TARGET_NAME)
try:
mach.lockMachine(session, 1)
console = session.console
guest = console.guest
# gs = session.console.guest.createSession('t4ks', 'Qwerty123', '', '')
t = 50 * 1000
gs = guest.createSession('t4ks', 'Qwerty123', '', 'rungit')
gs_state_result = gs.waitForArray([vbm.constants.GuestSessionWaitForFlag_Start], t)
print gs_state_result
args = ["/usr/bin/git", "clone", "<must be repo but I don't permission for this in this forum>" ,"/home/t4ks/pyteamcity"] #WTF
gp = gs.processCreate('/usr/bin/git', args, None, [vbm.constants.ProcessCreateFlag_WaitForStdOut , vbm.constants.ProcessCreateFlag_WaitForStdErr], t)
gps = gs.processes
for i in gps:
gp_foo = i
print "Arguments: ", gp_foo.arguments
print "Ex path: ", gp_foo.executablePath
print "PID: ", gp_foo.PID
print "Status: " , gp_foo.status
foo = []
foo.append(vbm.constants.ProcessWaitForFlag_StdOut)
foo.append(vbm.constants.ProcessCreateFlag_WaitForStdErr)
waitResult = gp.waitForArray(foo, t)
stdOut = gp.read(1, 10000, t)
print "stdOut: ", stdOut
stdErr = gp.read(2, 10000, t)
print "stdErr: ", stdErr
if waitResult == vbm.constants.ProcessWaitResult_StdOut:
print "Process Load finished"
except:
print traceback.format_exc()
this my output:
Code: Select all
Arguments: (u'/usr/bin/git', u'clone', u'<must be repo but I don't permission for this in this forum>', u'/home/t4ks/pyteamcity')
Ex path: /usr/bin/git
PID: 1429
Status: 100
stdOut:
stdErr: Cloning into '/home/t4ks/pyteamcity'...
Win32 exception occurred releasing IUnknown at 0x006ceff4
Win32 exception occurred releasing IUnknown at 0x041222a0
Win32 exception occurred releasing IUnknown at 0x0071b724
Win32 exception occurred releasing IUnknown at 0x0071bbec
Process finished with exit code 0
----------------UPD3----------------
I try run this script in my ubuntu 14-04 host, but I get stacktrace
Code: Select all
Traceback (most recent call last):
File "/home/administrator/PycharmProjects/vbautotest/run.py", line 85, in run_test
gps = gs.processes
File "/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/client/__init__.py", line 391, in __getattr__
raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr))
AttributeError: XPCOM component '<unknown>' has no attribute 'processes'
I wrapped string "gps = gs.processes" try/except and pass this error. This is not critical error, but maybe have alternative atribute "proccess" for check all proccess when I run this script on linux based system?
P.S. Sorry for my english =)