aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.12/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tools/addon-sdk-1.12/bin')
-rw-r--r--tools/addon-sdk-1.12/bin/activate86
-rw-r--r--tools/addon-sdk-1.12/bin/activate.bat135
-rw-r--r--tools/addon-sdk-1.12/bin/activate.ps199
-rwxr-xr-xtools/addon-sdk-1.12/bin/cfx33
-rw-r--r--tools/addon-sdk-1.12/bin/cfx.bat6
-rw-r--r--tools/addon-sdk-1.12/bin/deactivate.bat23
-rwxr-xr-xtools/addon-sdk-1.12/bin/integration-scripts/buildbot-run-cfx-helper14
-rw-r--r--tools/addon-sdk-1.12/bin/integration-scripts/integration-check364
8 files changed, 760 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.12/bin/activate b/tools/addon-sdk-1.12/bin/activate
new file mode 100644
index 0000000..8f2d9dd
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/activate
@@ -0,0 +1,86 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# This file must be used with "source bin/activate" *from bash*
+# you cannot run it directly
+
+deactivate () {
+ if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
+ PATH="$_OLD_VIRTUAL_PATH"
+ export PATH
+ unset _OLD_VIRTUAL_PATH
+ fi
+
+ # This should detect bash and zsh, which have a hash command that must
+ # be called to get it to forget past commands. Without forgetting
+ # past commands the $PATH changes we made may not be respected
+ if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
+ hash -r
+ fi
+
+ if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
+ PS1="$_OLD_VIRTUAL_PS1"
+ export PS1
+ unset _OLD_VIRTUAL_PS1
+ fi
+
+ if [ -n "$_OLD_PYTHONPATH" ] ; then
+ PYTHONPATH="$_OLD_PYTHONPATH"
+ export PYTHONPATH
+ unset _OLD_PYTHONPATH
+ fi
+
+ unset CUDDLEFISH_ROOT
+
+ unset VIRTUAL_ENV
+ if [ ! "$1" = "nondestructive" ] ; then
+ # Self destruct!
+ unset deactivate
+ fi
+}
+
+# unset irrelavent variables
+deactivate nondestructive
+
+_OLD_PYTHONPATH="$PYTHONPATH"
+_OLD_VIRTUAL_PATH="$PATH"
+
+VIRTUAL_ENV="`pwd`"
+
+if [ "x$OSTYPE" = "xmsys" ] ; then
+ CUDDLEFISH_ROOT="`pwd -W | sed s,/,\\\\\\\\,g`"
+ PATH="`pwd`/bin:$PATH"
+ # msys will convert any env vars with PATH in it to use msys
+ # form and will unconvert before launching
+ PYTHONPATH="`pwd -W`/python-lib;$PYTHONPATH"
+else
+ CUDDLEFISH_ROOT="$VIRTUAL_ENV"
+ PYTHONPATH="$VIRTUAL_ENV/python-lib:$PYTHONPATH"
+ PATH="$VIRTUAL_ENV/bin:$PATH"
+fi
+
+VIRTUAL_ENV="`pwd`"
+
+export CUDDLEFISH_ROOT
+export PYTHONPATH
+export PATH
+
+_OLD_VIRTUAL_PS1="$PS1"
+if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
+ # special case for Aspen magic directories
+ # see http://www.zetadev.com/software/aspen/
+ PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
+else
+ PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
+fi
+export PS1
+
+# This should detect bash and zsh, which have a hash command that must
+# be called to get it to forget past commands. Without forgetting
+# past commands the $PATH changes we made may not be respected
+if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
+ hash -r
+fi
+
+python -c "from jetpack_sdk_env import welcome; welcome()"
diff --git a/tools/addon-sdk-1.12/bin/activate.bat b/tools/addon-sdk-1.12/bin/activate.bat
new file mode 100644
index 0000000..5a6b885
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/activate.bat
@@ -0,0 +1,135 @@
+@echo off
+rem This Source Code Form is subject to the terms of the Mozilla Public
+rem License, v. 2.0. If a copy of the MPL was not distributed with this
+rem file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+set VIRTUAL_ENV=%~dp0
+set VIRTUAL_ENV=%VIRTUAL_ENV:~0,-5%
+set CUDDLEFISH_ROOT=%VIRTUAL_ENV%
+
+SET PYTHONKEY=SOFTWARE\Python\PythonCore
+
+rem look for 32-bit windows and python, or 64-bit windows and python
+
+SET PYTHONVERSION=2.7
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+SET PYTHONVERSION=2.6
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+SET PYTHONVERSION=2.5
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+if not defined ProgramFiles(x86) goto win32
+
+rem look for 32-bit python on 64-bit windows
+
+SET PYTHONKEY=SOFTWARE\Wow6432Node\Python\PythonCore
+
+SET PYTHONVERSION=2.7
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+SET PYTHONVERSION=2.6
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+SET PYTHONVERSION=2.5
+call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
+if "%PYTHONINSTALL%" NEQ "" goto FoundPython
+
+:win32
+
+SET PYTHONVERSION=
+set PYTHONKEY=
+echo Warning: Failed to find Python installation directory
+goto :EOF
+
+:FoundPython
+
+if defined _OLD_PYTHONPATH (
+ set PYTHONPATH=%_OLD_PYTHONPATH%
+)
+if not defined PYTHONPATH (
+ set PYTHONPATH=;
+)
+set _OLD_PYTHONPATH=%PYTHONPATH%
+set PYTHONPATH=%VIRTUAL_ENV%\python-lib;%PYTHONPATH%
+
+if not defined PROMPT (
+ set PROMPT=$P$G
+)
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set PROMPT=%_OLD_VIRTUAL_PROMPT%
+)
+
+set _OLD_VIRTUAL_PROMPT=%PROMPT%
+set PROMPT=(%VIRTUAL_ENV%) %PROMPT%
+
+if defined _OLD_VIRTUAL_PATH goto OLDPATH
+goto SKIPPATH
+:OLDPATH
+PATH %_OLD_VIRTUAL_PATH%
+
+:SKIPPATH
+set _OLD_VIRTUAL_PATH=%PATH%
+PATH %VIRTUAL_ENV%\bin;%PYTHONINSTALL%;%PATH%
+set PYTHONKEY=
+set PYTHONINSTALL=
+set PYTHONVERSION=
+set key=
+set reg=
+set _tokens=
+cd "%VIRTUAL_ENV%"
+python -c "from jetpack_sdk_env import welcome; welcome()"
+GOTO :EOF
+
+:CheckPython
+::CheckPython(retVal, key)
+::Reads the registry at %2% and checks if a Python exists there.
+::Checks both HKLM and HKCU, then checks the executable actually exists.
+SET key=%2%
+SET "%~1="
+SET reg=reg
+if defined ProgramFiles(x86) (
+ rem 32-bit cmd on 64-bit windows
+ if exist %WINDIR%\sysnative\reg.exe SET reg=%WINDIR%\sysnative\reg.exe
+)
+rem On Vista+, the last line of output is:
+rem (default) REG_SZ the_value
+rem (but note the word "default" will be localized.
+rem On XP, the last line of output is:
+rem <NO NAME>\tREG_SZ\tthe_value
+rem (not sure if "NO NAME" is localized or not!)
+rem SO: we use ")>" as the tokens to split on, then nuke
+rem the REG_SZ and any tabs or spaces.
+FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKLM\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
+rem Remove the REG_SZ
+set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
+rem Remove tabs (note the literal \t in the next line
+set PYTHONINSTALL=%PYTHONINSTALL: =%
+rem Remove spaces.
+set PYTHONINSTALL=%PYTHONINSTALL: =%
+if exist %PYTHONINSTALL%\python.exe goto :EOF
+rem It may be a 32bit Python directory built from source, in which case the
+rem executable is in the PCBuild directory.
+if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
+rem Or maybe a 64bit build directory.
+if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
+
+rem And try HKCU
+FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKCU\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
+set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
+set PYTHONINSTALL=%PYTHONINSTALL: =%
+set PYTHONINSTALL=%PYTHONINSTALL: =%
+if exist %PYTHONINSTALL%\python.exe goto :EOF
+if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
+if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
+rem can't find it here, so arrange to try the next key
+set PYTHONINSTALL=
+
+GOTO :EOF
diff --git a/tools/addon-sdk-1.12/bin/activate.ps1 b/tools/addon-sdk-1.12/bin/activate.ps1
new file mode 100644
index 0000000..5d939d4
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/activate.ps1
@@ -0,0 +1,99 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$Env:VIRTUAL_ENV = (gl);
+$Env:CUDDLEFISH_ROOT = $Env:VIRTUAL_ENV;
+
+# http://stackoverflow.com/questions/5648931/powershell-test-if-registry-value-exists/5652674#5652674
+Function Test-RegistryValue {
+ param(
+ [Alias("PSPath")]
+ [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
+ [String]$Path
+ ,
+ [Parameter(Position = 1, Mandatory = $true)]
+ [String]$Name
+ ,
+ [Switch]$PassThru
+ )
+
+ process {
+ if (Test-Path $Path) {
+ $Key = Get-Item -LiteralPath $Path
+ if ($Key.GetValue($Name, $null) -ne $null) {
+ if ($PassThru) {
+ Get-ItemProperty $Path $Name
+ } else {
+ $true
+ }
+ } else {
+ $false
+ }
+ } else {
+ $false
+ }
+ }
+}
+
+$WINCURVERKEY = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion';
+$WIN64 = (Test-RegistryValue $WINCURVERKEY 'ProgramFilesDir (x86)');
+
+if($WIN64) {
+ $PYTHONKEY='HKLM:SOFTWARE\Wow6432Node\Python\PythonCore';
+}
+else {
+ $PYTHONKEY='HKLM:SOFTWARE\Python\PythonCore';
+}
+
+$Env:PYTHONVERSION = '';
+$Env:PYTHONINSTALL = '';
+
+foreach ($version in @('2.6', '2.5', '2.4')) {
+ if (Test-RegistryValue "$PYTHONKEY\$version\InstallPath" '(default)') {
+ $Env:PYTHONVERSION = $version;
+ }
+}
+
+if ($Env:PYTHONVERSION) {
+ $Env:PYTHONINSTALL = (Get-Item "$PYTHONKEY\$version\InstallPath)").'(default)';
+}
+
+if ($Env:PYTHONINSTALL) {
+ $Env:Path += ";$Env:PYTHONINSTALL";
+}
+
+if (Test-Path Env:_OLD_PYTHONPATH) {
+ $Env:PYTHONPATH = $Env:_OLD_PYTHONPATH;
+}
+else {
+ $Env:PYTHONPATH = '';
+}
+
+$Env:_OLD_PYTHONPATH=$Env:PYTHONPATH;
+$Env:PYTHONPATH= "$Env:VIRTUAL_ENV\python-lib;$Env:PYTHONPATH";
+
+if (Test-Path Function:_OLD_VIRTUAL_PROMPT) {
+ Set-Content Function:Prompt (Get-Content Function:_OLD_VIRTUAL_PROMPT);
+}
+else {
+ function global:_OLD_VIRTUAL_PROMPT {}
+}
+
+Set-Content Function:_OLD_VIRTUAL_PROMPT (Get-Content Function:Prompt);
+
+function global:prompt { "($Env:VIRTUAL_ENV) $(_OLD_VIRTUAL_PROMPT)"; };
+
+if (Test-Path Env:_OLD_VIRTUAL_PATH) {
+ $Env:PATH = $Env:_OLD_VIRTUAL_PATH;
+}
+else {
+ $Env:_OLD_VIRTUAL_PATH = $Env:PATH;
+}
+
+$Env:Path="$Env:VIRTUAL_ENV\bin;$Env:Path"
+
+[System.Console]::WriteLine("Note: this PowerShell SDK activation script is experimental.")
+
+python -c "from jetpack_sdk_env import welcome; welcome()"
+
diff --git a/tools/addon-sdk-1.12/bin/cfx b/tools/addon-sdk-1.12/bin/cfx
new file mode 100755
index 0000000..2be9d19
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/cfx
@@ -0,0 +1,33 @@
+#! /usr/bin/env python
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+import os
+import sys
+
+# set the cuddlefish "root directory" for this process if it's not already
+# set in the environment
+cuddlefish_root = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
+
+if 'CUDDLEFISH_ROOT' not in os.environ:
+ os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root
+
+# add our own python-lib path to the python module search path.
+python_lib_dir = os.path.join(cuddlefish_root, "python-lib")
+if python_lib_dir not in sys.path:
+ sys.path.append(python_lib_dir)
+
+# now export to env so sub-processes get it too
+if 'PYTHONPATH' not in os.environ:
+ os.environ['PYTHONPATH'] = python_lib_dir
+elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep):
+ paths = os.environ['PYTHONPATH'].split(os.pathsep)
+ paths.insert(0, python_lib_dir)
+ os.environ['PYTHONPATH'] = os.pathsep.join(paths)
+
+import cuddlefish
+
+if __name__ == '__main__':
+ cuddlefish.run()
diff --git a/tools/addon-sdk-1.12/bin/cfx.bat b/tools/addon-sdk-1.12/bin/cfx.bat
new file mode 100644
index 0000000..215b034
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/cfx.bat
@@ -0,0 +1,6 @@
+@echo off
+rem This Source Code Form is subject to the terms of the Mozilla Public
+rem License, v. 2.0. If a copy of the MPL was not distributed with this
+rem file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+python "%VIRTUAL_ENV%\bin\cfx" %*
diff --git a/tools/addon-sdk-1.12/bin/deactivate.bat b/tools/addon-sdk-1.12/bin/deactivate.bat
new file mode 100644
index 0000000..e6bcd92
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/deactivate.bat
@@ -0,0 +1,23 @@
+@echo off
+rem This Source Code Form is subject to the terms of the Mozilla Public
+rem License, v. 2.0. If a copy of the MPL was not distributed with this
+rem file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
+)
+set _OLD_VIRTUAL_PROMPT=
+
+if defined _OLD_VIRTUAL_PATH (
+ set "PATH=%_OLD_VIRTUAL_PATH%"
+)
+set _OLD_VIRTUAL_PATH=
+
+if defined _OLD_PYTHONPATH (
+ set "PYTHONPATH=%_OLD_PYTHONPATH%"
+)
+set _OLD_PYTHONPATH=
+
+set CUDDLEFISH_ROOT=
+
+:END
diff --git a/tools/addon-sdk-1.12/bin/integration-scripts/buildbot-run-cfx-helper b/tools/addon-sdk-1.12/bin/integration-scripts/buildbot-run-cfx-helper
new file mode 100755
index 0000000..56c76ad
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/integration-scripts/buildbot-run-cfx-helper
@@ -0,0 +1,14 @@
+#!/bin/bash
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+source ./bin/activate
+if [ type -P xvfb-run ]
+then
+ xvfb-run cfx $*
+else
+ cfx $*
+fi
+deactivate
diff --git a/tools/addon-sdk-1.12/bin/integration-scripts/integration-check b/tools/addon-sdk-1.12/bin/integration-scripts/integration-check
new file mode 100644
index 0000000..8faec50
--- /dev/null
+++ b/tools/addon-sdk-1.12/bin/integration-scripts/integration-check
@@ -0,0 +1,364 @@
+#!/usr/bin/env python
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import signal
+import threading
+import urllib2, urllib
+import zipfile
+import tarfile
+import subprocess
+import optparse
+import sys, re
+#import win32api
+
+
+class SDK:
+ def __init__(self):
+ try:
+ # Take the current working directory
+ self.default_path = os.getcwd()
+ if sys.platform == "win32":
+ self.mswindows = True
+ else:
+ self.mswindows = False
+ # Take the default home path of the user.
+ home = os.path.expanduser('~')
+
+ # The following are the parameters that can be used to pass a dynamic URL, a specific path or a binry. The binary is not used yet. It will be used in version 2.0
+ # If a dynamic path is to be mentioned, it should start with a '/'. For eg. "/Desktop"
+ parser = optparse.OptionParser()
+ parser.add_option('-u', '--url', dest = 'url', default = 'https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/addon-sdk-latest.zip')
+ parser.add_option('-p', '--path', dest = 'path', default = self.default_path)
+ parser.add_option('-b', '--binary', dest = 'binary')#, default='/Applications/Firefox.app')
+ (options, args) = parser.parse_args()
+
+ # Get the URL from the parameter
+ self.link = options.url
+ # Set the base path for the user. If the user supplies the path, use the home variable as well. Else, take the default path of this script as the installation directory.
+ if options.path!=self.default_path:
+ if self.mswindows:
+ self.base_path = home + str(options.path).strip() + '\\'
+ else:
+ self.base_path = home + str(options.path).strip() + '/'
+ else:
+ if self.mswindows:
+ self.base_path = str(options.path).strip() + '\\'
+ else:
+ self.base_path = str(options.path).strip() + '/'
+ assert ' ' not in self.base_path, "You cannot have a space in your home path. Please remove the space before you continue."
+ print('Your Base path is =' + self.base_path)
+
+ # This assignment is not used in this program. It will be used in version 2 of this script.
+ self.bin = options.binary
+ # if app or bin is empty, dont pass anything
+
+ # Search for the .zip file or tarball file in the URL.
+ i = self.link.rfind('/')
+
+ self.fname = self.link[i+1:]
+ z = re.search('zip',self.fname,re.I)
+ g = re.search('gz',self.fname,re.I)
+ if z:
+ print 'zip file present in the URL.'
+ self.zip = True
+ self.gz = False
+ elif g:
+ print 'gz file present in the URL'
+ self.gz = True
+ self.zip = False
+ else:
+ print 'zip/gz file not present. Check the URL.'
+ return
+ print("File name is =" + self.fname)
+
+ # Join the base path and the zip/tar file name to crate a complete Local file path.
+ self.fpath = self.base_path + self.fname
+ print('Your local file path will be=' + self.fpath)
+ except AssertionError, e:
+ print e.args[0]
+ sys.exit(1)
+
+ # Download function - to download the SDK from the URL to the local machine.
+ def download(self,url,fpath,fname):
+ try:
+ # Start the download
+ print("Downloading...Please be patient!")
+ urllib.urlretrieve(url,filename = fname)
+ print('Download was successful.')
+ except ValueError: # Handles broken URL errors.
+ print 'The URL is ether broken or the file does not exist. Please enter the correct URL.'
+ raise
+ except urllib2.URLError: # Handles URL errors
+ print '\nURL not correct. Check again!'
+ raise
+
+ # Function to extract the downloaded zipfile.
+ def extract(self, zipfilepath, extfile):
+ try:
+ # Timeout is set to 30 seconds.
+ timeout = 30
+ # Change the directory to the location of the zip file.
+ try:
+ os.chdir(zipfilepath)
+ except OSError:
+ # Will reach here if zip file doesnt exist
+ print 'O/S Error:' + zipfilepath + 'does not exist'
+ raise
+
+ # Get the folder name of Jetpack to get the exact version number.
+ if self.zip:
+ try:
+ f = zipfile.ZipFile(extfile, "r")
+ except IOError as (errno, strerror): # Handles file errors
+ print "I/O error - Cannot perform extract operation: {1}".format(errno, strerror)
+ raise
+ list = f.namelist()[0]
+ temp_name = list.split('/')
+ print('Folder Name= ' +temp_name[0])
+ self.folder_name = temp_name[0]
+ elif self.gz:
+ try:
+ f = tarfile.open(extfile,'r')
+ except IOError as (errno, strerror): # Handles file errors
+ print "I/O error - Cannot perform extract operation: {1}".format(errno, strerror)
+ raise
+ list = f.getnames()[0]
+ temp_name = list.split('/')
+ print('Folder Name= ' +temp_name[0])
+ self.folder_name = temp_name[0]
+
+ print ('Starting to Extract...')
+
+ # Timeout code. The subprocess.popen exeutes the command and the thread waits for a timeout. If the process does not finish within the mentioned-
+ # timeout, the process is killed.
+ kill_check = threading.Event()
+
+ if self.zip:
+ # Call the command to unzip the file.
+ if self.mswindows:
+ zipfile.ZipFile.extractall(f)
+ else:
+ p = subprocess.Popen('unzip '+extfile, stdout=subprocess.PIPE, shell=True)
+ pid = p.pid
+ elif self.gz:
+ # Call the command to untar the file.
+ if self.mswindows:
+ tarfile.TarFile.extractall(f)
+ else:
+ p = subprocess.Popen('tar -xf '+extfile, stdout=subprocess.PIPE, shell=True)
+ pid = p.pid
+
+ #No need to handle for windows because windows automatically replaces old files with new files. It does not ask the user(as it does in Mac/Unix)
+ if self.mswindows==False:
+ watch = threading.Timer(timeout, kill_process, args=(pid, kill_check, self.mswindows ))
+ watch.start()
+ (stdout, stderr) = p.communicate()
+ watch.cancel() # if it's still waiting to run
+ success = not kill_check.isSet()
+
+ # Abort process if process fails.
+ if not success:
+ raise RuntimeError
+ kill_check.clear()
+ print('Extraction Successful.')
+ except RuntimeError:
+ print "Ending the program"
+ sys.exit(1)
+ except:
+ print "Error during file extraction: ", sys.exc_info()[0]
+ raise
+
+ # Function to run the cfx testall comands and to make sure the SDK is not broken.
+ def run_testall(self, home_path, folder_name):
+ try:
+ timeout = 500
+
+ self.new_dir = home_path + folder_name
+ try:
+ os.chdir(self.new_dir)
+ except OSError:
+ # Will reach here if the jetpack 0.X directory doesnt exist
+ print 'O/S Error: Jetpack directory does not exist at ' + self.new_dir
+ raise
+ print '\nStarting tests...'
+ # Timeout code. The subprocess.popen exeutes the command and the thread waits for a timeout. If the process does not finish within the mentioned-
+ # timeout, the process is killed.
+ kill_check = threading.Event()
+
+ # Set the path for the logs. They will be in the parent directory of the Jetpack SDK.
+ log_path = home_path + 'tests.log'
+
+ # Subprocess call to set up the jetpack environment and to start the tests. Also sends the output to a log file.
+ if self.bin != None:
+ if self.mswindows:
+ p = subprocess.Popen("bin\\activate && cfx testall -a firefox -b \"" + self.bin + "\"" , stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ proc_handle = p._handle
+ (stdout,stderr) = p.communicate()
+ else:
+ p = subprocess.Popen('. bin/activate; cfx testall -a firefox -b ' + self.bin , stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ pid = p.pid
+ (stdout,stderr) = p.communicate()
+ elif self.bin == None:
+ if self.mswindows:
+ p=subprocess.Popen('bin\\activate && cfx testall -a firefox > '+log_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ proc_handle = p._handle
+ (stdout,stderr) = p.communicate()
+ else:
+ p = subprocess.Popen('. bin/activate; cfx testall -a firefox > '+log_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ pid = p.pid
+ (stdout,stderr) = p.communicate()
+
+ #Write the output to log file
+ f=open(log_path,"w")
+ f.write(stdout+stderr)
+ f.close()
+
+ #Watchdog for timeout process
+ if self.mswindows:
+ watch = threading.Timer(timeout, kill_process, args=(proc_handle, kill_check, self.mswindows))
+ else:
+ watch = threading.Timer(timeout, kill_process, args=(pid, kill_check, self.mswindows))
+ watch.start()
+ watch.cancel() # if it's still waiting to run
+ success = not kill_check.isSet()
+ if not success:
+ raise RuntimeError
+ kill_check.clear()
+
+ if p.returncode!=0:
+ print('\nAll tests were not successful. Check the test-logs in the jetpack directory.')
+ result_sdk(home_path)
+ #sys.exit(1)
+ raise RuntimeError
+ else:
+ ret_code=result_sdk(home_path)
+ if ret_code==0:
+ print('\nAll tests were successful. Yay \o/ . Running a sample package test now...')
+ else:
+ print ('\nThere were errors during the tests.Take a look at logs')
+ raise RuntimeError
+ except RuntimeError:
+ print "Ending the program"
+ sys.exit(1)
+ except:
+ print "Error during the testall command execution:", sys.exc_info()[0]
+ raise
+
+ def package(self, example_dir):
+ try:
+ timeout = 30
+
+ print '\nNow Running packaging tests...'
+
+ kill_check = threading.Event()
+
+ # Set the path for the example logs. They will be in the parent directory of the Jetpack SDK.
+ exlog_path = example_dir + 'test-example.log'
+ # Subprocess call to test the sample example for packaging.
+ if self.bin!=None:
+ if self.mswindows:
+ p = subprocess.Popen('bin\\activate && cfx run --pkgdir examples\\reading-data --static-args="{\\"quitWhenDone\\":true}" -b \"" + self.bin + "\"' , stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ proc_handle = p._handle
+ (stdout, stderr) = p.communicate()
+ else:
+ p = subprocess.Popen('. bin/activate; cfx run --pkgdir examples/reading-data --static-args=\'{\"quitWhenDone\":true}\' -b ' + self.bin , stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ pid = p.pid
+ (stdout, stderr) = p.communicate()
+ elif self.bin==None:
+ if self.mswindows:
+ p = subprocess.Popen('bin\\activate && cfx run --pkgdir examples\\reading-data --static-args="{\\"quitWhenDone\\":true}"', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ proc_handle = p._handle
+ (stdout, stderr) = p.communicate()
+ else:
+ p = subprocess.Popen('. bin/activate; cfx run --pkgdir examples/reading-data --static-args=\'{\"quitWhenDone\":true}\' ', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ pid = p.pid
+ (stdout, stderr) = p.communicate()
+
+ #Write the output to log file
+ f=open(exlog_path,"w")
+ f.write(stdout+stderr)
+ f.close()
+
+ #Watch dog for timeout process
+ if self.mswindows:
+ watch = threading.Timer(timeout, kill_process, args=(proc_handle, kill_check, self.mswindows))
+ else:
+ watch = threading.Timer(timeout, kill_process, args=(pid, kill_check, self.mswindows))
+ watch.start()
+ watch.cancel() # if it's still waiting to run
+ success = not kill_check.isSet()
+ if not success:
+ raise RuntimeError
+ kill_check.clear()
+
+ if p.returncode != 0:
+ print('\nSample tests were not executed correctly. Check the test-example log in jetpack diretory.')
+ result_example(example_dir)
+ raise RuntimeError
+ else:
+ ret_code=result_example(example_dir)
+ if ret_code==0:
+ print('\nAll tests pass. The SDK is working! Yay \o/')
+ else:
+ print ('\nTests passed with warning.Take a look at logs')
+ sys.exit(1)
+
+ except RuntimeError:
+ print "Ending program"
+ sys.exit(1)
+ except:
+ print "Error during running sample tests:", sys.exc_info()[0]
+ raise
+
+def result_sdk(sdk_dir):
+ log_path = sdk_dir + 'tests.log'
+ print 'Results are logged at:' + log_path
+ try:
+ f = open(log_path,'r')
+ # Handles file errors
+ except IOError :
+ print 'I/O error - Cannot open test log at ' + log_path
+ raise
+
+ for line in reversed(open(log_path).readlines()):
+ if line.strip()=='FAIL':
+ print ('\nOverall result - FAIL. Look at the test log at '+log_path)
+ return 1
+ return 0
+
+
+def result_example(sdk_dir):
+ exlog_path = sdk_dir + 'test-example.log'
+ print 'Sample test results are logged at:' + exlog_path
+ try:
+ f = open(exlog_path,'r')
+ # Handles file errors
+ except IOError :
+ print 'I/O error - Cannot open sample test log at ' + exlog_path
+ raise
+
+ #Read the file in reverse and check for the keyword 'FAIL'.
+ for line in reversed(open(exlog_path).readlines()):
+ if line.strip()=='FAIL':
+ print ('\nOverall result for Sample tests - FAIL. Look at the test log at '+exlog_path)
+ return 1
+ return 0
+
+def kill_process(process, kill_check, mswindows):
+ print '\nProcess Timedout. Killing the process. Please Rerun this script.'
+ if mswindows:
+ win32api.TerminateProcess(process, -1)
+ else:
+ os.kill(process, signal.SIGKILL)
+ kill_check.set()# tell the main routine to kill. Used SIGKILL to hard kill the process.
+ return
+
+if __name__ == "__main__":
+ obj = SDK()
+ obj.download(obj.link,obj.fpath,obj.fname)
+ obj.extract(obj.base_path,obj.fname)
+ obj.run_testall(obj.base_path,obj.folder_name)
+ obj.package(obj.base_path)