Skip to content

Commit

Permalink
Merge pull request Hexxeh#28 from pebble/feature-build-return-code
Browse files Browse the repository at this point in the history
Make pb-sdk py return error codes from a waf build
  • Loading branch information
martijnthe committed Sep 6, 2013
2 parents 81d2a4f + 90e0f73 commit 52d8ab8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
12 changes: 9 additions & 3 deletions pb-sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import logging
import sys

import pebble as libpebble
from pebble.PblCommand import PblCommand
Expand Down Expand Up @@ -39,19 +40,24 @@ def main(self):

logging.basicConfig(format='[%(levelname)-8s] %(message)s', level = log_level)

self.run_action(args.command, args)
return self.run_action(args.command, args)

def run_action(self, action, args):
# Find the extension that was called
command = [x for x in self.commands if x.name == args.command][0]

try:
command.run(args)
return command.run(args)
except libpebble.PebbleError as e:
if args.debug:
raise e
else:
logging.error(e)
return 1

if __name__ == '__main__':
PbSDKShell().main()
retval = PbSDKShell().main()
if retval is None:
retval = 0
sys.exit(retval)

5 changes: 4 additions & 1 deletion pebble/LibPebblesCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def run(self, args):
apps = response['apps']
if len(apps) == 0:
logging.info("No apps installed.")
return
for app in apps:
logging.info('[{}] {}'.format(app['index'], app['name']))
except:
logging.error("Error getting apps list.")
return 1

class PblRemoveCommand(LibPebbleCommand):
name = 'rm'
Expand All @@ -101,6 +101,9 @@ def run(self, args):
logging.info("App removed")
return 0

logging.info("No app found in bank %u" % args.bank_id)
return 1


class PblLogsCommand(LibPebbleCommand):
name = 'logs'
Expand Down
4 changes: 2 additions & 2 deletions pebble/PblBuildCommand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sh, os
import sh, os, subprocess
from PblCommand import PblCommand

class PblWafCommand(PblCommand):
Expand All @@ -15,7 +15,7 @@ def configure_subparser(self, parser):
PblCommand.configure_subparser(self, parser)

def run(self, args):
os.system(self.waf_path(args) + " configure build")
return subprocess.call(self.waf_path(args) + " configure build", shell=True)

class PblCleanCommand(PblWafCommand):
name = 'clean'
Expand Down

0 comments on commit 52d8ab8

Please sign in to comment.