- Timestamp:
- Feb 18, 2009 2:17:15 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r16873 r16903 749 749 { 750 750 LogFlowThisFuncEnter(); 751 LogFlowThisFunc (("aName=\"%ls\",aOsTypeId =\"%ls\",aBaseFolder=\"%ls\"\n", aName, aOsTypeId, aBaseFolder)); 751 752 752 753 CheckComArgStrNotEmptyOrNull (aName); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r16867 r16903 1497 1497 However, this is not recommended and you should normally pass an empty 1498 1498 (null) UUID to this method so that a new UUID will be automatically 1499 generated for every created machine. 1499 generated for every created machine. You can use UUID 1500 00000000-0000-0000-0000-000000000000 as null value. 1500 1501 1501 1502 <note> -
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r16366 r16903 145 145 return s.split() 146 146 147 def startVm(mgr,vb,mach,type,perf): 147 def createVm(ctx,name,kind,base): 148 mgr = ctx['mgr'] 149 vb = ctx['vb'] 150 session = mgr.getSessionObject(vb) 151 mach = vb.createMachine(name, kind, base, 152 "00000000-0000-0000-0000-000000000000") 153 mach.saveSettings() 154 print "created machine with UUID",mach.id 155 vb.registerMachine(mach) 156 157 def removeVm(ctx,mach): 158 mgr = ctx['mgr'] 159 vb = ctx['vb'] 160 print "removing machine ",mach.name,"with UUID",mach.id 161 mach = vb.unregisterMachine(mach.id) 162 if mach: 163 mach.deleteSettings() 164 165 def startVm(ctx,mach,type): 166 mgr = ctx['mgr'] 167 vb = ctx['vb'] 168 perf = ctx['perf'] 148 169 session = mgr.getSessionObject(vb) 149 170 uuid = mach.id … … 152 173 completed = progress.completed 153 174 rc = progress.resultCode 154 print "Completed:", completed, "rc:", rc175 print "Completed:", completed, "rc:",hex(rc&0xffffffff) 155 176 if int(rc) == 0: 156 177 # we ignore exceptions to allow starting VM even if … … 163 184 traceback.print_exc() 164 185 pass 165 session.close() 186 # if session not opened, close doesn't make sense 187 session.close() 188 else: 189 # Not yet implemented error string query API for remote API 190 if not ctx['remote']: 191 print session.QueryErrorObject(rc) 166 192 167 193 def getMachines(ctx): … … 282 308 else: 283 309 type = "gui" 284 startVm(ctx['mgr'], ctx['vb'], mach, type, ctx['perf']) 310 startVm(ctx, mach, type) 311 return 0 312 313 def createCmd(ctx, args): 314 if (len(args) < 3 or len(args) > 4): 315 print "usage: create name ostype <basefolder>" 316 return 0 317 name = args[1] 318 oskind = args[2] 319 if len(args) == 4: 320 base = args[3] 321 else: 322 base = '' 323 try: 324 ctx['vb'].getGuestOSType(oskind) 325 except Exception, e: 326 print 'Unknown OS type:',oskind 327 return 0 328 createVm(ctx, name, oskind, base) 329 return 0 330 331 def removeCmd(ctx, args): 332 mach = argsToMach(ctx,args) 333 if mach == None: 334 return 0 335 removeVm(ctx, mach) 285 336 return 0 286 337 … … 382 433 commands = {'help':['Prints help information', helpCmd], 383 434 'start':['Start virtual machine by name or uuid', startCmd], 435 'create':['Create virtual machine', createCmd], 436 'remove':['Remove virtual machine', removeCmd], 384 437 'pause':['Pause virtual machine', pauseCmd], 385 438 'resume':['Resume virtual machine', resumeCmd], -
trunk/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
r12752 r16903 51 51 #ifdef VBOX 52 52 #include <nsIExceptionService.h> 53 #include <iprt/err.h> 53 54 #endif 54 55 #include "nspr.h" // PR_fprintf … … 210 211 // state when called back from the C code is clear. Only Python 2.4 211 212 // and later allows an explicit exc_info tuple(). 212 213 213 214 // Don't use VLogF here, instead arrange for exception info and 214 215 // traceback to be in the same buffer. … … 243 244 #endif 244 245 246 #ifdef VBOX 247 PyObject *PyXPCOM_BuildErrorMessage(nsresult r) 248 { 249 char msg[512]; 250 bool gotMsg = false; 251 252 const RTCOMERRMSG* pMsg = RTErrCOMGet(r); 253 if (strncmp(pMsg->pszMsgFull, "Unknown", 7) != 0) 254 { 255 gotMsg = true; 256 PR_snprintf(msg, sizeof(msg), "%s (%s)", 257 pMsg->pszMsgFull, pMsg->pszDefine); 258 gotMsg = true; 259 } 260 261 nsresult rc; 262 nsCOMPtr <nsIExceptionService> es; 263 es = do_GetService (NS_EXCEPTIONSERVICE_CONTRACTID, &rc); 264 if (!gotMsg && NS_SUCCEEDED (rc)) 265 { 266 nsCOMPtr <nsIExceptionManager> em; 267 rc = es->GetCurrentExceptionManager (getter_AddRefs (em)); 268 if (NS_SUCCEEDED (rc)) 269 { 270 nsCOMPtr <nsIException> ex; 271 rc = em->GetExceptionFromProvider(r, NULL, getter_AddRefs (ex)); 272 if (NS_SUCCEEDED (rc) && ex) 273 { 274 nsXPIDLCString emsg; 275 ex->GetMessage(getter_Copies(emsg)); 276 PR_snprintf(msg, sizeof(msg), "%s", 277 emsg.get()); 278 gotMsg = true; 279 } 280 } 281 } 282 283 if (!gotMsg) 284 { 285 PR_snprintf(msg, sizeof(msg), "Error %d in module %d", 286 NS_ERROR_GET_CODE(r), NS_ERROR_GET_MODULE(r)); 287 } 288 PyObject *evalue = Py_BuildValue("is", r, msg); 289 return evalue; 290 } 291 #endif 245 292 246 293 PyObject *PyXPCOM_BuildPyException(nsresult r) 247 294 { 248 #ifndef VBOX 295 #ifndef VBOX 249 296 // Need the message etc. 250 297 PyObject *evalue = Py_BuildValue("i", r); 298 #else 299 PyObject *evalue = PyXPCOM_BuildErrorMessage(r); 300 #endif 251 301 PyErr_SetObject(PyXPCOM_Error, evalue); 252 302 Py_XDECREF(evalue); 253 303 return NULL; 254 #else255 char msg[256];256 257 nsresult rc;258 nsCOMPtr <nsIExceptionService> es;259 es = do_GetService (NS_EXCEPTIONSERVICE_CONTRACTID, &rc);260 bool gotMsg = false;261 if (NS_SUCCEEDED (rc))262 {263 nsCOMPtr <nsIExceptionManager> em;264 rc = es->GetCurrentExceptionManager (getter_AddRefs (em));265 if (NS_SUCCEEDED (rc))266 {267 nsCOMPtr <nsIException> ex;268 rc = em->GetExceptionFromProvider(r, NULL, getter_AddRefs (ex));269 if (NS_SUCCEEDED (rc) && ex)270 {271 nsXPIDLCString emsg;272 ex->GetMessage(getter_Copies(emsg));273 PR_snprintf(msg, sizeof(msg), "%s",274 emsg.get());275 gotMsg = true;276 }277 }278 }279 280 if (!gotMsg)281 {282 PR_snprintf(msg, sizeof(msg), "Error %d in module %d",283 NS_ERROR_GET_CODE(r), NS_ERROR_GET_MODULE(r));284 }285 PyObject *evalue = Py_BuildValue("is", r, msg);286 PyErr_SetObject(PyXPCOM_Error, evalue);287 Py_XDECREF(evalue);288 return NULL;289 #endif290 304 } 291 305 … … 348 362 TRACEBACK_FETCH_ERROR("cant find traceback.print_tb\n"); 349 363 350 argsTB = Py_BuildValue("OOO", 364 argsTB = Py_BuildValue("OOO", 351 365 exc_tb ? exc_tb : Py_None, 352 Py_None, 366 Py_None, 353 367 obStringIO); 354 if (argsTB==NULL) 368 if (argsTB==NULL) 355 369 TRACEBACK_FETCH_ERROR("cant make print_tb arguments\n"); 356 370 357 371 obResult = PyObject_CallObject(obFuncTB, argsTB); 358 if (obResult==NULL) 372 if (obResult==NULL) 359 373 TRACEBACK_FETCH_ERROR("traceback.print_tb() failed\n"); 360 374 /* Now call the getvalue() method in the StringIO instance */ … … 365 379 Py_DECREF(obResult); 366 380 obResult = PyObject_CallObject(obFuncStringIO, NULL); 367 if (obResult==NULL) 381 if (obResult==NULL) 368 382 TRACEBACK_FETCH_ERROR("getvalue() failed.\n"); 369 383 -
trunk/src/libs/xpcom18a4/python/src/PyISupports.cpp
r11746 r16903 53 53 54 54 PyObject *PyObject_FromNSInterface( nsISupports *aInterface, 55 const nsIID &iid, 55 const nsIID &iid, 56 56 PRBool bMakeNicePyObject /*= PR_TRUE */) 57 57 { … … 60 60 } 61 61 62 PRInt32 62 PRInt32 63 63 _PyXPCOM_GetInterfaceCount(void) 64 64 { … … 79 79 Py_nsISupports::~Py_nsISupports() 80 80 { 81 SafeRelease(this); 81 SafeRelease(this); 82 82 PR_AtomicDecrement(&cInterfaces); 83 83 PyXPCOM_DLLRelease(); … … 130 130 if (NS_SUCCEEDED(rv)) 131 131 rv = ss->ToString(&val); 132 } // end-scope 132 } // end-scope 133 133 Py_END_ALLOW_THREADS; 134 134 PyObject *ret = NS_FAILED(rv) ? … … 154 154 Py_nsISupports::Constructor(nsISupports *pInitObj, const nsIID &iid) 155 155 { 156 return new Py_nsISupports(pInitObj, 157 iid, 156 return new Py_nsISupports(pInitObj, 157 iid, 158 158 type); 159 159 } 160 160 161 161 PRBool 162 Py_nsISupports::InterfaceFromPyISupports(PyObject *ob, 163 const nsIID &iid, 162 Py_nsISupports::InterfaceFromPyISupports(PyObject *ob, 163 const nsIID &iid, 164 164 nsISupports **ppv) 165 165 { … … 178 178 if (iid.Equals(Py_nsIID_NULL)) { 179 179 // a bit of a hack - we are asking for the arbitary interface 180 // wrapped by this object, not some other specific interface - 180 // wrapped by this object, not some other specific interface - 181 181 // so no QI, just an AddRef(); 182 182 Py_BEGIN_ALLOW_THREADS … … 209 209 210 210 PRBool 211 Py_nsISupports::InterfaceFromPyObject(PyObject *ob, 212 const nsIID &iid, 213 nsISupports **ppv, 211 Py_nsISupports::InterfaceFromPyObject(PyObject *ob, 212 const nsIID &iid, 213 nsISupports **ppv, 214 214 PRBool bNoneOK, 215 215 PRBool bTryAutoWrap /* = PR_TRUE */) … … 300 300 301 301 /*static */PyObject * 302 Py_nsISupports::PyObjectFromInterface(nsISupports *pis, 303 const nsIID &riid, 302 Py_nsISupports::PyObjectFromInterface(nsISupports *pis, 303 const nsIID &riid, 304 304 PRBool bMakeNicePyObject, /* = PR_TRUE */ 305 305 PRBool bIsInternalCall /* = PR_FALSE */) … … 359 359 // the object to actually pass to Python. 360 360 PyObject * 361 Py_nsISupports::MakeDefaultWrapper(PyObject *pyis, 361 Py_nsISupports::MakeDefaultWrapper(PyObject *pyis, 362 362 const nsIID &iid) 363 363 { … … 374 374 if (g_obFuncMakeInterfaceCount==NULL) { 375 375 PyObject *mod = PyImport_ImportModule("xpcom.client"); 376 if (mod) 376 if (mod) 377 377 g_obFuncMakeInterfaceCount = PyObject_GetAttrString(mod, "MakeInterfaceResult"); 378 378 Py_XDECREF(mod); … … 393 393 Py_XDECREF(obIID); 394 394 if (ret==NULL) // eek - error - return the original with no refcount mod. 395 ret = pyis; 395 ret = pyis; 396 396 else 397 397 // no error - decref the old object … … 442 442 443 443 444 #ifdef VBOX 445 static PyObject * 446 QueryErrorObject(PyObject *self, PyObject *args) 447 { 448 nsresult rc = 0; 449 450 if (!PyArg_ParseTuple(args, "i", &rc)) 451 return NULL; 452 453 return PyXPCOM_BuildErrorMessage(rc); 454 } 455 #endif 456 444 457 // @object Py_nsISupports|The base object for all PythonCOM objects. Wraps a COM nsISupports interface. 445 /*static*/ struct PyMethodDef 458 /*static*/ struct PyMethodDef 446 459 Py_nsISupports::methods[] = 447 460 { 448 461 { "queryInterface", Py_nsISupports::QueryInterface, 1, "Queries the object for an interface."}, 449 462 { "QueryInterface", Py_nsISupports::QueryInterface, 1, "An alias for queryInterface."}, 463 #ifdef VBOX 464 { "QueryErrorObject", QueryErrorObject, 1, "Query an error object for given status code."}, 465 #endif 450 466 {NULL} 451 467 }; -
trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h
r11746 r16903 153 153 PYXPCOM_EXPORT PyObject *PyXPCOM_BuildPyException(nsresult res); 154 154 155 #ifdef VBOX 156 // Build human readable error message out of XPCOM error 157 PYXPCOM_EXPORT PyObject *PyXPCOM_BuildErrorMessage(nsresult r); 158 #endif 159 155 160 // Used in gateways to handle the current Python exception 156 161 // NOTE: this function assumes it is operating within the Python context
Note:
See TracChangeset
for help on using the changeset viewer.