michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import sys michael@0: import os michael@0: import time michael@0: import tempfile michael@0: import traceback michael@0: michael@0: # We need to know our current directory so that we can serve our test files from it. michael@0: SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0]))) michael@0: michael@0: from runreftest import RefTest michael@0: from runreftest import ReftestOptions michael@0: from automation import Automation michael@0: import devicemanager michael@0: import droid michael@0: import moznetwork michael@0: from remoteautomation import RemoteAutomation, fennecLogcatFilters michael@0: michael@0: class RemoteOptions(ReftestOptions): michael@0: def __init__(self, automation): michael@0: ReftestOptions.__init__(self, automation) michael@0: michael@0: defaults = {} michael@0: defaults["logFile"] = "reftest.log" michael@0: # app, xrePath and utilityPath variables are set in main function michael@0: defaults["app"] = "" michael@0: defaults["xrePath"] = "" michael@0: defaults["utilityPath"] = "" michael@0: defaults["runTestsInParallel"] = False michael@0: michael@0: self.add_option("--remote-app-path", action="store", michael@0: type = "string", dest = "remoteAppPath", michael@0: help = "Path to remote executable relative to device root using only forward slashes. Either this or app must be specified, but not both.") michael@0: defaults["remoteAppPath"] = None michael@0: michael@0: self.add_option("--deviceIP", action="store", michael@0: type = "string", dest = "deviceIP", michael@0: help = "ip address of remote device to test") michael@0: defaults["deviceIP"] = None michael@0: michael@0: self.add_option("--devicePort", action="store", michael@0: type = "string", dest = "devicePort", michael@0: help = "port of remote device to test") michael@0: defaults["devicePort"] = 20701 michael@0: michael@0: self.add_option("--remote-product-name", action="store", michael@0: type = "string", dest = "remoteProductName", michael@0: help = "Name of product to test - either fennec or firefox, defaults to fennec") michael@0: defaults["remoteProductName"] = "fennec" michael@0: michael@0: self.add_option("--remote-webserver", action="store", michael@0: type = "string", dest = "remoteWebServer", michael@0: help = "IP Address of the webserver hosting the reftest content") michael@0: defaults["remoteWebServer"] = moznetwork.get_ip() michael@0: michael@0: self.add_option("--http-port", action = "store", michael@0: type = "string", dest = "httpPort", michael@0: help = "port of the web server for http traffic") michael@0: defaults["httpPort"] = automation.DEFAULT_HTTP_PORT michael@0: michael@0: self.add_option("--ssl-port", action = "store", michael@0: type = "string", dest = "sslPort", michael@0: help = "Port for https traffic to the web server") michael@0: defaults["sslPort"] = automation.DEFAULT_SSL_PORT michael@0: michael@0: self.add_option("--remote-logfile", action="store", michael@0: type = "string", dest = "remoteLogFile", michael@0: help = "Name of log file on the device relative to device root. PLEASE USE ONLY A FILENAME.") michael@0: defaults["remoteLogFile"] = None michael@0: michael@0: self.add_option("--enable-privilege", action="store_true", dest = "enablePrivilege", michael@0: help = "add webserver and port to the user.js file for remote script access and universalXPConnect") michael@0: defaults["enablePrivilege"] = False michael@0: michael@0: self.add_option("--pidfile", action = "store", michael@0: type = "string", dest = "pidFile", michael@0: help = "name of the pidfile to generate") michael@0: defaults["pidFile"] = "" michael@0: michael@0: self.add_option("--bootstrap", action="store_true", dest = "bootstrap", michael@0: help = "test with a bootstrap addon required for native Fennec") michael@0: defaults["bootstrap"] = False michael@0: michael@0: self.add_option("--dm_trans", action="store", michael@0: type = "string", dest = "dm_trans", michael@0: help = "the transport to use to communicate with device: [adb|sut]; default=sut") michael@0: defaults["dm_trans"] = "sut" michael@0: michael@0: self.add_option("--remoteTestRoot", action = "store", michael@0: type = "string", dest = "remoteTestRoot", michael@0: help = "remote directory to use as test root (eg. /mnt/sdcard/tests or /data/local/tests)") michael@0: defaults["remoteTestRoot"] = None michael@0: michael@0: self.add_option("--httpd-path", action = "store", michael@0: type = "string", dest = "httpdPath", michael@0: help = "path to the httpd.js file") michael@0: defaults["httpdPath"] = None michael@0: michael@0: defaults["localLogName"] = None michael@0: michael@0: self.set_defaults(**defaults) michael@0: michael@0: def verifyRemoteOptions(self, options): michael@0: if options.runTestsInParallel: michael@0: self.error("Cannot run parallel tests here") michael@0: michael@0: # Ensure our defaults are set properly for everything we can infer michael@0: if not options.remoteTestRoot: michael@0: options.remoteTestRoot = self.automation._devicemanager.getDeviceRoot() + '/reftest' michael@0: options.remoteProfile = options.remoteTestRoot + "/profile" michael@0: michael@0: # Verify that our remotewebserver is set properly michael@0: if (options.remoteWebServer == None or michael@0: options.remoteWebServer == '127.0.0.1'): michael@0: print "ERROR: Either you specified the loopback for the remote webserver or ", michael@0: print "your local IP cannot be detected. Please provide the local ip in --remote-webserver" michael@0: return None michael@0: michael@0: # One of remoteAppPath (relative path to application) or the app (executable) must be michael@0: # set, but not both. If both are set, we destroy the user's selection for app michael@0: # so instead of silently destroying a user specificied setting, we error. michael@0: if (options.remoteAppPath and options.app): michael@0: print "ERROR: You cannot specify both the remoteAppPath and the app" michael@0: return None michael@0: elif (options.remoteAppPath): michael@0: options.app = options.remoteTestRoot + "/" + options.remoteAppPath michael@0: elif (options.app == None): michael@0: # Neither remoteAppPath nor app are set -- error michael@0: print "ERROR: You must specify either appPath or app" michael@0: return None michael@0: michael@0: if (options.xrePath == None): michael@0: print "ERROR: You must specify the path to the controller xre directory" michael@0: return None michael@0: else: michael@0: # Ensure xrepath is a full path michael@0: options.xrePath = os.path.abspath(options.xrePath) michael@0: michael@0: # Default to /reftest/reftest.log michael@0: if (options.remoteLogFile == None): michael@0: options.remoteLogFile = 'reftest.log' michael@0: michael@0: options.localLogName = options.remoteLogFile michael@0: options.remoteLogFile = options.remoteTestRoot + '/' + options.remoteLogFile michael@0: michael@0: # Ensure that the options.logfile (which the base class uses) is set to michael@0: # the remote setting when running remote. Also, if the user set the michael@0: # log file name there, use that instead of reusing the remotelogfile as above. michael@0: if (options.logFile): michael@0: # If the user specified a local logfile name use that michael@0: options.localLogName = options.logFile michael@0: michael@0: options.logFile = options.remoteLogFile michael@0: michael@0: if (options.pidFile != ""): michael@0: f = open(options.pidFile, 'w') michael@0: f.write("%s" % os.getpid()) michael@0: f.close() michael@0: michael@0: # httpd-path is specified by standard makefile targets and may be specified michael@0: # on the command line to select a particular version of httpd.js. If not michael@0: # specified, try to select the one from hostutils.zip, as required in bug 882932. michael@0: if not options.httpdPath: michael@0: options.httpdPath = os.path.join(options.utilityPath, "components") michael@0: michael@0: # TODO: Copied from main, but I think these are no longer used in a post xulrunner world michael@0: #options.xrePath = options.remoteTestRoot + self.automation._product + '/xulrunner' michael@0: #options.utilityPath = options.testRoot + self.automation._product + '/bin' michael@0: return options michael@0: michael@0: class ReftestServer: michael@0: """ Web server used to serve Reftests, for closer fidelity to the real web. michael@0: It is virtually identical to the server used in mochitest and will only michael@0: be used for running reftests remotely. michael@0: Bug 581257 has been filed to refactor this wrapper around httpd.js into michael@0: it's own class and use it in both remote and non-remote testing. """ michael@0: michael@0: def __init__(self, automation, options, scriptDir): michael@0: self.automation = automation michael@0: self._utilityPath = options.utilityPath michael@0: self._xrePath = options.xrePath michael@0: self._profileDir = options.serverProfilePath michael@0: self.webServer = options.remoteWebServer michael@0: self.httpPort = options.httpPort michael@0: self.scriptDir = scriptDir michael@0: self.pidFile = options.pidFile michael@0: self._httpdPath = os.path.abspath(options.httpdPath) michael@0: self.shutdownURL = "http://%(server)s:%(port)s/server/shutdown" % { "server" : self.webServer, "port" : self.httpPort } michael@0: michael@0: def start(self): michael@0: "Run the Refest server, returning the process ID of the server." michael@0: michael@0: env = self.automation.environment(xrePath = self._xrePath) michael@0: env["XPCOM_DEBUG_BREAK"] = "warn" michael@0: if self.automation.IS_WIN32: michael@0: env["PATH"] = env["PATH"] + ";" + self._xrePath michael@0: michael@0: args = ["-g", self._xrePath, michael@0: "-v", "170", michael@0: "-f", os.path.join(self._httpdPath, "httpd.js"), michael@0: "-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = '%(port)s'; const _SERVER_ADDR ='%(server)s';" % michael@0: {"profile" : self._profileDir.replace('\\', '\\\\'), "port" : self.httpPort, "server" : self.webServer }, michael@0: "-f", os.path.join(self.scriptDir, "server.js")] michael@0: michael@0: xpcshell = os.path.join(self._utilityPath, michael@0: "xpcshell" + self.automation.BIN_SUFFIX) michael@0: michael@0: if not os.access(xpcshell, os.F_OK): michael@0: raise Exception('xpcshell not found at %s' % xpcshell) michael@0: if self.automation.elf_arm(xpcshell): michael@0: raise Exception('xpcshell at %s is an ARM binary; please use ' michael@0: 'the --utility-path argument to specify the path ' michael@0: 'to a desktop version.' % xpcshell) michael@0: michael@0: self._process = self.automation.Process([xpcshell] + args, env = env) michael@0: pid = self._process.pid michael@0: if pid < 0: michael@0: print "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server." michael@0: return 2 michael@0: self.automation.log.info("INFO | remotereftests.py | Server pid: %d", pid) michael@0: michael@0: if (self.pidFile != ""): michael@0: f = open(self.pidFile + ".xpcshell.pid", 'w') michael@0: f.write("%s" % pid) michael@0: f.close() michael@0: michael@0: def ensureReady(self, timeout): michael@0: assert timeout >= 0 michael@0: michael@0: aliveFile = os.path.join(self._profileDir, "server_alive.txt") michael@0: i = 0 michael@0: while i < timeout: michael@0: if os.path.exists(aliveFile): michael@0: break michael@0: time.sleep(1) michael@0: i += 1 michael@0: else: michael@0: print "TEST-UNEXPECTED-FAIL | remotereftests.py | Timed out while waiting for server startup." michael@0: self.stop() michael@0: return 1 michael@0: michael@0: def stop(self): michael@0: if hasattr(self, '_process'): michael@0: try: michael@0: c = urllib2.urlopen(self.shutdownURL) michael@0: c.read() michael@0: c.close() michael@0: michael@0: rtncode = self._process.poll() michael@0: if (rtncode == None): michael@0: self._process.terminate() michael@0: except: michael@0: self._process.kill() michael@0: michael@0: class RemoteReftest(RefTest): michael@0: remoteApp = '' michael@0: michael@0: def __init__(self, automation, devicemanager, options, scriptDir): michael@0: RefTest.__init__(self, automation) michael@0: self._devicemanager = devicemanager michael@0: self.scriptDir = scriptDir michael@0: self.remoteApp = options.app michael@0: self.remoteProfile = options.remoteProfile michael@0: self.remoteTestRoot = options.remoteTestRoot michael@0: self.remoteLogFile = options.remoteLogFile michael@0: self.localLogName = options.localLogName michael@0: self.pidFile = options.pidFile michael@0: if self.automation.IS_DEBUG_BUILD: michael@0: self.SERVER_STARTUP_TIMEOUT = 180 michael@0: else: michael@0: self.SERVER_STARTUP_TIMEOUT = 90 michael@0: self.automation.deleteANRs() michael@0: michael@0: def findPath(self, paths, filename = None): michael@0: for path in paths: michael@0: p = path michael@0: if filename: michael@0: p = os.path.join(p, filename) michael@0: if os.path.exists(self.getFullPath(p)): michael@0: return path michael@0: return None michael@0: michael@0: def startWebServer(self, options): michael@0: """ Create the webserver on the host and start it up """ michael@0: remoteXrePath = options.xrePath michael@0: remoteUtilityPath = options.utilityPath michael@0: localAutomation = Automation() michael@0: localAutomation.IS_WIN32 = False michael@0: localAutomation.IS_LINUX = False michael@0: localAutomation.IS_MAC = False michael@0: localAutomation.UNIXISH = False michael@0: hostos = sys.platform michael@0: if (hostos == 'mac' or hostos == 'darwin'): michael@0: localAutomation.IS_MAC = True michael@0: elif (hostos == 'linux' or hostos == 'linux2'): michael@0: localAutomation.IS_LINUX = True michael@0: localAutomation.UNIXISH = True michael@0: elif (hostos == 'win32' or hostos == 'win64'): michael@0: localAutomation.BIN_SUFFIX = ".exe" michael@0: localAutomation.IS_WIN32 = True michael@0: michael@0: paths = [options.xrePath, localAutomation.DIST_BIN, self.automation._product, os.path.join('..', self.automation._product)] michael@0: options.xrePath = self.findPath(paths) michael@0: if options.xrePath == None: michael@0: print "ERROR: unable to find xulrunner path for %s, please specify with --xre-path" % (os.name) michael@0: return 1 michael@0: paths.append("bin") michael@0: paths.append(os.path.join("..", "bin")) michael@0: michael@0: xpcshell = "xpcshell" michael@0: if (os.name == "nt"): michael@0: xpcshell += ".exe" michael@0: michael@0: if (options.utilityPath): michael@0: paths.insert(0, options.utilityPath) michael@0: options.utilityPath = self.findPath(paths, xpcshell) michael@0: if options.utilityPath == None: michael@0: print "ERROR: unable to find utility path for %s, please specify with --utility-path" % (os.name) michael@0: return 1 michael@0: michael@0: options.serverProfilePath = tempfile.mkdtemp() michael@0: self.server = ReftestServer(localAutomation, options, self.scriptDir) michael@0: retVal = self.server.start() michael@0: if retVal: michael@0: return retVal michael@0: retVal = self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT) michael@0: if retVal: michael@0: return retVal michael@0: michael@0: options.xrePath = remoteXrePath michael@0: options.utilityPath = remoteUtilityPath michael@0: return 0 michael@0: michael@0: def stopWebServer(self, options): michael@0: self.server.stop() michael@0: michael@0: def createReftestProfile(self, options, reftestlist): michael@0: profile = RefTest.createReftestProfile(self, options, reftestlist, server=options.remoteWebServer) michael@0: profileDir = profile.profile michael@0: michael@0: prefs = {} michael@0: prefs["browser.firstrun.show.localepicker"] = False michael@0: prefs["font.size.inflation.emPerLine"] = 0 michael@0: prefs["font.size.inflation.minTwips"] = 0 michael@0: prefs["reftest.remote"] = True michael@0: # Set a future policy version to avoid the telemetry prompt. michael@0: prefs["toolkit.telemetry.prompted"] = 999 michael@0: prefs["toolkit.telemetry.notifiedOptOut"] = 999 michael@0: prefs["reftest.uri"] = "%s" % reftestlist michael@0: prefs["datareporting.policy.dataSubmissionPolicyBypassAcceptance"] = True michael@0: michael@0: # Point the url-classifier to the local testing server for fast failures michael@0: prefs["browser.safebrowsing.gethashURL"] = "http://127.0.0.1:8888/safebrowsing-dummy/gethash" michael@0: prefs["browser.safebrowsing.updateURL"] = "http://127.0.0.1:8888/safebrowsing-dummy/update" michael@0: # Point update checks to the local testing server for fast failures michael@0: prefs["extensions.update.url"] = "http://127.0.0.1:8888/extensions-dummy/updateURL" michael@0: prefs["extensions.update.background.url"] = "http://127.0.0.1:8888/extensions-dummy/updateBackgroundURL" michael@0: prefs["extensions.blocklist.url"] = "http://127.0.0.1:8888/extensions-dummy/blocklistURL" michael@0: prefs["extensions.hotfix.url"] = "http://127.0.0.1:8888/extensions-dummy/hotfixURL" michael@0: # Turn off extension updates so they don't bother tests michael@0: prefs["extensions.update.enabled"] = False michael@0: # Make sure opening about:addons won't hit the network michael@0: prefs["extensions.webservice.discoverURL"] = "http://127.0.0.1:8888/extensions-dummy/discoveryURL" michael@0: # Make sure AddonRepository won't hit the network michael@0: prefs["extensions.getAddons.maxResults"] = 0 michael@0: prefs["extensions.getAddons.get.url"] = "http://127.0.0.1:8888/extensions-dummy/repositoryGetURL" michael@0: prefs["extensions.getAddons.getWithPerformance.url"] = "http://127.0.0.1:8888/extensions-dummy/repositoryGetWithPerformanceURL" michael@0: prefs["extensions.getAddons.search.browseURL"] = "http://127.0.0.1:8888/extensions-dummy/repositoryBrowseURL" michael@0: prefs["extensions.getAddons.search.url"] = "http://127.0.0.1:8888/extensions-dummy/repositorySearchURL" michael@0: # Make sure that opening the plugins check page won't hit the network michael@0: prefs["plugins.update.url"] = "http://127.0.0.1:8888/plugins-dummy/updateCheckURL" michael@0: prefs["layout.css.devPixelsPerPx"] = "1.0" michael@0: michael@0: # Disable skia-gl: see bug 907351 michael@0: prefs["gfx.canvas.azure.accelerated"] = False michael@0: michael@0: # Set the extra prefs. michael@0: profile.set_preferences(prefs) michael@0: michael@0: try: michael@0: self._devicemanager.pushDir(profileDir, options.remoteProfile) michael@0: except devicemanager.DMError: michael@0: print "Automation Error: Failed to copy profiledir to device" michael@0: raise michael@0: michael@0: return profile michael@0: michael@0: def copyExtraFilesToProfile(self, options, profile): michael@0: profileDir = profile.profile michael@0: RefTest.copyExtraFilesToProfile(self, options, profile) michael@0: try: michael@0: self._devicemanager.pushDir(profileDir, options.remoteProfile) michael@0: except devicemanager.DMError: michael@0: print "Automation Error: Failed to copy extra files to device" michael@0: raise michael@0: michael@0: def getManifestPath(self, path): michael@0: return path michael@0: michael@0: def printDeviceInfo(self, printLogcat=False): michael@0: try: michael@0: if printLogcat: michael@0: logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters) michael@0: print ''.join(logcat) michael@0: print "Device info: %s" % self._devicemanager.getInfo() michael@0: print "Test root: %s" % self._devicemanager.getDeviceRoot() michael@0: except devicemanager.DMError: michael@0: print "WARNING: Error getting device information" michael@0: michael@0: def cleanup(self, profileDir): michael@0: # Pull results back from device michael@0: if self.remoteLogFile and \ michael@0: self._devicemanager.fileExists(self.remoteLogFile): michael@0: self._devicemanager.getFile(self.remoteLogFile, self.localLogName) michael@0: else: michael@0: print "WARNING: Unable to retrieve log file (%s) from remote " \ michael@0: "device" % self.remoteLogFile michael@0: self._devicemanager.removeDir(self.remoteProfile) michael@0: self._devicemanager.removeDir(self.remoteTestRoot) michael@0: RefTest.cleanup(self, profileDir) michael@0: if (self.pidFile != ""): michael@0: try: michael@0: os.remove(self.pidFile) michael@0: os.remove(self.pidFile + ".xpcshell.pid") michael@0: except: michael@0: print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % self.pidFile michael@0: michael@0: def main(args): michael@0: automation = RemoteAutomation(None) michael@0: parser = RemoteOptions(automation) michael@0: options, args = parser.parse_args() michael@0: michael@0: if (options.deviceIP == None): michael@0: print "Error: you must provide a device IP to connect to via the --device option" michael@0: return 1 michael@0: michael@0: try: michael@0: if (options.dm_trans == "adb"): michael@0: if (options.deviceIP): michael@0: dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot) michael@0: else: michael@0: dm = droid.DroidADB(None, None, deviceRoot=options.remoteTestRoot) michael@0: else: michael@0: dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot) michael@0: except devicemanager.DMError: michael@0: print "Automation Error: exception while initializing devicemanager. Most likely the device is not in a testable state." michael@0: return 1 michael@0: michael@0: automation.setDeviceManager(dm) michael@0: michael@0: if (options.remoteProductName != None): michael@0: automation.setProduct(options.remoteProductName) michael@0: michael@0: # Set up the defaults and ensure options are set michael@0: options = parser.verifyRemoteOptions(options) michael@0: if (options == None): michael@0: print "ERROR: Invalid options specified, use --help for a list of valid options" michael@0: return 1 michael@0: michael@0: if not options.ignoreWindowSize: michael@0: parts = dm.getInfo('screen')['screen'][0].split() michael@0: width = int(parts[0].split(':')[1]) michael@0: height = int(parts[1].split(':')[1]) michael@0: if (width < 1050 or height < 1050): michael@0: print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height) michael@0: return 1 michael@0: michael@0: automation.setAppName(options.app) michael@0: automation.setRemoteProfile(options.remoteProfile) michael@0: automation.setRemoteLog(options.remoteLogFile) michael@0: reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY) michael@0: options = parser.verifyCommonOptions(options, reftest) michael@0: michael@0: # Hack in a symbolic link for jsreftest michael@0: os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest"))) michael@0: michael@0: # Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot michael@0: manifest = args[0] michael@0: if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])): michael@0: manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0] michael@0: elif os.path.exists(args[0]): michael@0: manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/') michael@0: manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath michael@0: else: michael@0: print "ERROR: Could not find test manifest '%s'" % manifest michael@0: return 1 michael@0: michael@0: # Start the webserver michael@0: retVal = reftest.startWebServer(options) michael@0: if retVal: michael@0: return retVal michael@0: michael@0: procName = options.app.split('/')[-1] michael@0: if (dm.processExist(procName)): michael@0: dm.killProcess(procName) michael@0: michael@0: reftest.printDeviceInfo() michael@0: michael@0: #an example manifest name to use on the cli michael@0: # manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list" michael@0: retVal = 0 michael@0: try: michael@0: cmdlineArgs = ["-reftest", manifest] michael@0: if options.bootstrap: michael@0: cmdlineArgs = [] michael@0: dm.recordLogcat() michael@0: retVal = reftest.runTests(manifest, options, cmdlineArgs) michael@0: except: michael@0: print "Automation Error: Exception caught while running tests" michael@0: traceback.print_exc() michael@0: retVal = 1 michael@0: michael@0: reftest.stopWebServer(options) michael@0: michael@0: reftest.printDeviceInfo(printLogcat=True) michael@0: michael@0: return retVal michael@0: michael@0: if __name__ == "__main__": michael@0: sys.exit(main(sys.argv[1:])) michael@0: