Permalink
Browse files

Compatibility updates.

Changed from windows .vbs script to .bat script for VboxWebSrv startup.

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@104 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information...
1 parent 9d5801c commit 618b92775a7abfcab888fcd814502b043d127bbb Ian Moore committed Nov 12, 2010
Showing with 119 additions and 28 deletions.
  1. +6 −6 VBoxWebSrv.py
  2. +0 −16 VBoxWebSrv.vbs
  3. +100 −0 VboxWebSrv.bat
  4. +2 −0 lib/VirtualBox_wrappers.py
  5. +9 −4 lib/vboxactions.py
  6. +2 −2 www/js/utils.js
View
@@ -18,15 +18,13 @@
import re
import StringIO
import types
-import md5
import random
import uuid
import gc
from email.utils import parsedate_tz
# Enable garbage collection
gc.enable()
-gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
if sys.platform == 'win32':
try:
@@ -48,9 +46,11 @@
else:
import vboxapi # Main VirtualBox API
+from vboxapi.VirtualBox_constants import VirtualBoxReflectionInfo
+
# VBoxWeb modules
-sys.path.insert(0,'lib')
-sys.path.insert(0,'languages')
+sys.path.insert(0,os.path.abspath(os.path.dirname(__file__))+'/lib')
+sys.path.insert(0,os.path.abspath(os.path.dirname(__file__))+'/languages')
# Load vbox connector
import vboxactions
@@ -240,7 +240,7 @@ def __init__(self, ctx):
self.ctx['progressOps'] = {'get':progressObjGet,'store':progressObjStore,'delete':progressObjDel}
# generate session_cookie name. Not very secure, but better than a static / predictable key.
- self.session_cookie = md5.md5(os.path.abspath(os.path.dirname(__file__))).hexdigest()
+ self.session_cookie = hashlib.md5(os.path.abspath(os.path.dirname(__file__))).hexdigest()
"""
@@ -801,7 +801,7 @@ def main(argv = sys.argv):
'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__))
})
- ctx = {'global':g_vboxManager,'vbox':None}
+ ctx = {'global':g_vboxManager,'vbox':None, 'vboxTypes':VirtualBoxReflectionInfo(True)}
cherrypy.engine.subscribe('stop', onShutdown)
View
@@ -1,16 +0,0 @@
-Dim sh, scriptPath, p, WshShell, objArgs, strArgs
-
-set sh = WScript.CreateObject("WScript.Shell")
-scriptPath = Left ( WScript.ScriptFullName, InStrRev ( WScript.ScriptFullName, WScript.ScriptName) - 1 )
-p = sh.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Python.exe\")
-
-rem WScript.Echo p & " " & scriptPath
-
-Set WshShell = WScript.CreateObject("WScript.Shell")
-
-Set objArgs = WScript.Arguments
-For I = 0 to objArgs.Count - 1
- strArgs = strArgs & " " & objArgs(I)
-Next
-
-WshShell.Run "cmd /C " & p & " " & scriptPath & "VBoxWebSrv.py " & strArgs & " & pause", 1, True
View
@@ -0,0 +1,100 @@
+@Echo off
+echo.
+echo VBoxWebSrv Windows
+echo.
+
+::
+:: reset vars
+::
+set act=%1
+set puname=%2
+set pwset1=%3
+set pwset2=%3
+set arg1=%1
+set arg2=%2
+set arg3=%3
+
+:: Search the registry tree for the required values
+IF NOT EXIST "%PYTHON%" (
+ FOR /F "skip=2 tokens=3" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Python.exe"') DO (
+ IF EXIST "%%A" SET PYTHON=%%A
+ )
+)
+if NOT EXIST "%PYTHON%" GOTO NOPYTHON
+
+:PROMPTACT
+echo.
+echo Commands: start, adduser, deluser
+echo.
+if "%act%" == "" set /p act= Enter a command to run:
+
+if "%act%" == "start" (
+ echo Starting...
+ GOTO RUNPYTHON
+)
+if "%act%" == "adduser" GOTO PROMPTUSER
+if "%act%" == "deluser" GOTO PROMPTUSER
+echo %act% not understood.
+set act=
+GOTO PROMPTACT
+
+:PROMPTUSER
+if "%act%" == "deluser" (
+ if "%puname%" == "" set /p puname= Enter a user to remove:
+)
+if "%act%" == "adduser" (
+ if "%puname%" == "" set /p puname= Enter a user to add:
+)
+if "%puname%" == "" goto PROMPTUSER
+if "%act%" == "deluser" goto DELUSER
+if "%act%" == "adduser" goto PROMPTPW
+
+GOTO RUNPYTHON
+
+::
+:: Prompt for password
+::
+:PROMPTPW
+if "%pwset1%" == "" set /p pwset1= Enter password:
+if "%pwset1%" == "" GOTO PROMPTPW
+if "%pwset2%" == "" set /p pwset2= Again:
+if "%pwset1%" == "%pwset2%" GOTO ADDUSER
+echo Passwords do not match.
+set pwset1=
+set pwset2=
+GOTO PROMPTPW
+
+::
+:: Add a user
+::
+:ADDUSER
+set arg1="adduser"
+set arg2=%puname%
+set arg3="%pwset1%"
+GOTO RUNPYTHON
+
+::
+:: Python not found
+::
+:NOPYTHON
+echo Unable to find python.exe. Please set the PYTHON environment variable.
+pause
+GOTO :END
+
+::
+:: Delete a user
+::
+:DELUSER
+set arg1="deluser"
+set arg2=%puname%
+set arg3=
+GOTO RUNPYTHON
+
+::
+:: Start server
+::
+:RUNPYTHON
+%PYTHON% %~dp0VBoxWebSrv.py %arg1% %arg2% %arg3%
+pause
+
+:END
@@ -18,12 +18,14 @@
#
# This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
#
+"""
from VirtualBox_services import *
try:
from VirtualBox_client import *
except:
pass
+"""
class ManagedManager:
def __init__(self):
View
@@ -12,7 +12,7 @@
import time
import types
import traceback
-import md5
+import hashlib
import os
from VBoxWebSrv import trans
from vboxapi import VirtualBoxManager
@@ -115,10 +115,10 @@ def __init__(self, ctx):
self.cache.prefix = 'vbwc-'
if self.settings.get('location'):
- self.cache.prefix = self.cache.prefix + str(md5.md5(self.settings.get('location')).hexdigest())
+ self.cache.prefix = self.cache.prefix + str(hashlib.md5(self.settings.get('location')).hexdigest())
else:
# Handle both Win* And *nix
- self.cache.prefix = self.cache.prefix + str(md5.md5(str(os.environ.get('USERNAME',''))+str(os.environ.get('USER',''))).hexdigest())
+ self.cache.prefix = self.cache.prefix + str(hashlib.md5(str(os.environ.get('USERNAME',''))+str(os.environ.get('USER',''))).hexdigest())
# Progress operation handling
self.progressOps = ctx['progressOps']
@@ -196,7 +196,12 @@ def vboxType(self,vbtype,conv):
Return vbox type for setting values
"""
def vboxTypeSet(self,vbtype,conv):
- return int(self.vboxType(vbtype,conv))
+ i = 0
+ try:
+ i = self.vboxType(vbtype,conv)
+ except:
+ pass
+ return int(i)
"""
Return array of vbox items
View
@@ -716,10 +716,10 @@ function vboxParseCookies() {
/* Check version against supported versions */
function vboxVersionCheck(ver) {
- var supported = {'3':{'2':1}};
+ var supported = {'4':{'0':1}};
// No ver passed?
- if(ver && !supported[ver.major][ver.minor]) {
+ if(ver && !(supported[ver.major] && supported[ver.major][ver.minor])) {
vboxParseCookies();

0 comments on commit 618b927

Please sign in to comment.