def run(self, args): os.environ['PATH'] = "{}:{}".format(os.path.join(self.sdk_path(args), "arm-cs-tools", "bin"), os.environ['PATH']) cmdLine = self.waf_path(args) + " " + self.waf_cmds retval = subprocess.call(cmdLine, shell=True) # If an error occurred, we need to do some sleuthing to determine a # cause. This allows the caller to post more useful information to # analytics. We normally don't capture stdout and stderr using Poepn() # because you lose the nice color coding produced when the command # outputs to a terminal directly. # # But, if an error occurs, let's run it again capturing the output # so we can determine the cause if (retval): cmdArgs = cmdLine.split() try: cmdObj = create_sh_cmd_obj(cmdArgs[0]) output = cmdObj(*cmdArgs[1:]) stderr = output.stderr except sh.ErrorReturnCode as e: stderr = e.stderr # Look for common problems if "Could not determine the compiler version" in stderr: raise NoCompilerException elif "region `APP' overflowed" in stderr: raise AppTooBigException else: raise BuildErrorException elif args.command == 'build': # No error building. Send up app memory usage and resource usage # up to analytics # Read in the appinfo.json to get the list of resources try: appInfo = json.load(open("appinfo.json")) self._send_memory_usage(args, appInfo) self._send_resource_usage(args, appInfo) self._send_line_counts(args, appInfo) hasJS = os.path.exists(os.path.join('src', 'js')) PblAnalytics.code_has_java_script_evt(uuid=appInfo["uuid"], hasJS=hasJS) except Exception as e: logging.error("Exception occurred collecting app analytics: " "%s" % str(e)) logging.debug(traceback.format_exc()) return 0
def run(self, args): os.environ['PATH'] = "{}:{}".format( os.path.join(self.sdk_path(args), "arm-cs-tools", "bin"), os.environ['PATH']) # If python3 is the default and python2 is available, then plug in # our stub 'python' shell script which passes control to python2 py_version = sh.python("-c", "import sys;print(sys.version_info[0])", _tty_out=False).strip() if py_version != '2': if sh.which('python2', _tty_out=False) is None: raise RuntimeError("The Pebble SDK requires python version 2.6 " "or 2.7 (python2). You are currently running 'python%s' " "by default and a 'python2' executable could not be found." % py_version) os.environ['PATH'] = "{}:{}".format( os.path.join(os.path.normpath(os.path.dirname(__file__))), os.environ['PATH']) # Execute the build command cmdLine = '"%s" %s' % (self.waf_path(args), self.waf_cmds) retval = subprocess.call(cmdLine, shell=True) # If an error occurred, we need to do some sleuthing to determine a # cause. This allows the caller to post more useful information to # analytics. We normally don't capture stdout and stderr using Poepn() # because you lose the nice color coding produced when the command # outputs to a terminal directly. # # But, if an error occurs, let's run it again capturing the output # so we can determine the cause if (retval): cmdArgs = [self.waf_path(args)] + self.waf_cmds.split() try: cmdObj = create_sh_cmd_obj(cmdArgs[0]) output = cmdObj(*cmdArgs[1:]) stderr = output.stderr except sh.ErrorReturnCode as e: stderr = e.stderr # Look for common problems if "Could not determine the compiler version" in stderr: raise NoCompilerException elif "region `APP' overflowed" in stderr: raise AppTooBigException else: raise BuildErrorException elif args.command == 'build': # No error building. Send up app memory usage and resource usage # up to analytics # Read in the appinfo.json to get the list of resources try: appInfo = json.load(open("appinfo.json")) self._send_memory_usage(args, appInfo) self._send_resource_usage(args, appInfo) self._send_line_counts(args, appInfo) hasJS = os.path.exists(os.path.join('src', 'js')) PblAnalytics.code_has_java_script_evt(uuid=appInfo["uuid"], hasJS=hasJS) except Exception as e: logging.error("Exception occurred collecting app analytics: " "%s" % str(e)) logging.debug(traceback.format_exc()) return 0
def run(self, args): os.environ['PATH'] = "{}:{}".format( os.path.join(self.sdk_path(args), "arm-cs-tools", "bin"), os.environ['PATH']) # If python3 is the default and python2 is available, then plug in # our stub 'python' shell script which passes control to python2 py_version = sh.python( "-c", "import sys;print(sys.version_info[0])").strip() if py_version != '2': if sh.which('python2') is None: raise RuntimeError( "The Pebble SDK requires python version 2.6 " "or 2.7 (python2). You are currently running 'python%s' " "by default and a 'python2' executable could not be found." % py_version) os.environ['PATH'] = "{}:{}".format( os.path.join(os.path.normpath(os.path.dirname(__file__))), os.environ['PATH']) # Execute the build command cmdLine = '"%s" %s' % (self.waf_path(args), self.waf_cmds) retval = subprocess.call(cmdLine, shell=True) # If an error occurred, we need to do some sleuthing to determine a # cause. This allows the caller to post more useful information to # analytics. We normally don't capture stdout and stderr using Poepn() # because you lose the nice color coding produced when the command # outputs to a terminal directly. # # But, if an error occurs, let's run it again capturing the output # so we can determine the cause if (retval): cmdArgs = [self.waf_path(args)] + self.waf_cmds.split() try: cmdObj = create_sh_cmd_obj(cmdArgs[0]) output = cmdObj(*cmdArgs[1:]) stderr = output.stderr except sh.ErrorReturnCode as e: stderr = e.stderr # Look for common problems if "Could not determine the compiler version" in stderr: raise NoCompilerException elif "region `APP' overflowed" in stderr: raise AppTooBigException else: raise BuildErrorException elif args.command == 'build': # No error building. Send up app memory usage and resource usage # up to analytics # Read in the appinfo.json to get the list of resources try: appInfo = json.load(open("appinfo.json")) self._send_memory_usage(args, appInfo) self._send_resource_usage(args, appInfo) self._send_line_counts(args, appInfo) hasJS = os.path.exists(os.path.join('src', 'js')) PblAnalytics.code_has_java_script_evt(uuid=appInfo["uuid"], hasJS=hasJS) except Exception as e: logging.error("Exception occurred collecting app analytics: " "%s" % str(e)) logging.debug(traceback.format_exc()) return 0