Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 842839: Some add-on SDK files use windows line endings.

  • Loading branch information...
commit 8d638e71c13910401d5b783cc3bdc0b2852228e7 1 parent 34d45c5
@Mossop authored
View
60 LICENSE
@@ -1,30 +1,30 @@
-The files which make up the SDK are developed by Mozilla and licensed
-under the MPL 2.0 (http://mozilla.org/MPL/2.0/), with the exception of the
-components listed below, which are made available by their authors under
-the licenses listed alongside.
-
-syntaxhighlighter
-------------------
-doc/static-files/syntaxhighlighter
-Made available under the MIT license.
-
-jQuery
-------
-examples/reddit-panel/data/jquery-1.4.4.min.js
-examples/annotator/data/jquery-1.4.2.min.js
-Made available under the MIT license.
-
-simplejson
-----------
-python-lib/simplejson
-Made available under the MIT license.
-
-Python Markdown
----------------
-python-lib/markdown
-Made available under the BSD license.
-
-LibraryDetector
----------------
-examples/library-detector/data/library-detector.js
-Made available under the MIT license.
+The files which make up the SDK are developed by Mozilla and licensed
+under the MPL 2.0 (http://mozilla.org/MPL/2.0/), with the exception of the
+components listed below, which are made available by their authors under
+the licenses listed alongside.
+
+syntaxhighlighter
+------------------
+doc/static-files/syntaxhighlighter
+Made available under the MIT license.
+
+jQuery
+------
+examples/reddit-panel/data/jquery-1.4.4.min.js
+examples/annotator/data/jquery-1.4.2.min.js
+Made available under the MIT license.
+
+simplejson
+----------
+python-lib/simplejson
+Made available under the MIT license.
+
+Python Markdown
+---------------
+python-lib/markdown
+Made available under the BSD license.
+
+LibraryDetector
+---------------
+examples/library-detector/data/library-detector.js
+Made available under the MIT license.
View
88 README
@@ -1,45 +1,45 @@
-Add-on SDK README
-==================
-
-Before proceeding, please make sure you've installed Python 2.5,
-2.6, or 2.7 (if it's not already on your system):
-
- http://python.org/download/
-
-Note that Python 3.0 and 3.1 are not supported in this release.
-
-For Windows users, MozillaBuild (https://wiki.mozilla.org/MozillaBuild)
-will install the correct version of Python and the MSYS package, which
-will make it easier to work with the SDK.
-
-To get started, first enter the same directory that this README file
-is in (the SDK's root directory) using a shell program. On Unix systems
-or on Windows with MSYS, you can execute the following command:
-
- source bin/activate
-
-Windows users using cmd.exe should instead run:
-
- bin\activate.bat
-
-Then run:
-
- cfx docs
-
-This should start a documentation server and open a web browser
-with further instructions.
-
-If you get an error when running cfx or have any other problems getting
-started, see the "Troubleshooting" guide at:
-https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/troubleshooting.html
-
-Bugs
--------
-
-* file a bug: https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK
-
-
-Style Guidelines
---------------------
-
+Add-on SDK README
+==================
+
+Before proceeding, please make sure you've installed Python 2.5,
+2.6, or 2.7 (if it's not already on your system):
+
+ http://python.org/download/
+
+Note that Python 3.0 and 3.1 are not supported in this release.
+
+For Windows users, MozillaBuild (https://wiki.mozilla.org/MozillaBuild)
+will install the correct version of Python and the MSYS package, which
+will make it easier to work with the SDK.
+
+To get started, first enter the same directory that this README file
+is in (the SDK's root directory) using a shell program. On Unix systems
+or on Windows with MSYS, you can execute the following command:
+
+ source bin/activate
+
+Windows users using cmd.exe should instead run:
+
+ bin\activate.bat
+
+Then run:
+
+ cfx docs
+
+This should start a documentation server and open a web browser
+with further instructions.
+
+If you get an error when running cfx or have any other problems getting
+started, see the "Troubleshooting" guide at:
+https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/troubleshooting.html
+
+Bugs
+-------
+
+* file a bug: https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK
+
+
+Style Guidelines
+--------------------
+
* https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide
View
728 bin/integration-scripts/integration-check
@@ -1,364 +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)
+#!/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)
View
6 data/mofo_logo.SVG
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: Adobe Illustrator 12.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
- <!ENTITY ns_svg "http://www.w3.org/2000/svg">
- <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_svg "http://www.w3.org/2000/svg">
+ <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg version="1.1" id="svg2997" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" viewBox="-0.5 -0.5 200 200" overflow="visible" enable-background="new -0.5 -0.5 200 200" xml:space="preserve">
<path id="path85" fill="#FFFFFF" d="M-2559.936,6359.65c19.127,26.489,46.371,47.744,80.988,44.707 C-2479.339,6371.648-2523.898,6352.641-2559.936,6359.65z"/>
Please sign in to comment.
Something went wrong with that request. Please try again.