Skip to content

Commit

Permalink
Merge pull request #1 from pebble/feature-remove-app-by-uuid
Browse files Browse the repository at this point in the history
Feature remove app by uuid
  • Loading branch information
PaulMcInnis committed Mar 27, 2013
2 parents 1b5e04a + 34e939b commit 3caec95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
22 changes: 17 additions & 5 deletions p.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,24 @@ def cmd_list_apps(pebble, args):
print '[{}] {}'.format(app['index'], app['name'])

def cmd_rm_app(pebble, args):
for app in pebble.get_appbank_status()['apps']:
if app['index'] == args.app_index:
pebble.remove_app(app["id"], app["index"])

try:
uuid = args.app_index_or_hex_uuid.decode('hex')
if len(uuid) == 16:
pebble.remove_app_by_uuid(uuid)
print 'removed app'
return
except:
pass
try:
idx = int(args.app_index_or_hex_uuid)
for app in pebble.get_appbank_status()['apps']:
if app['index'] == idx:
pebble.remove_app(app["id"], app["index"])
print 'removed app'
return
except:
print 'Invalid arguments. Use bank index or hex app UUID (16 bytes / 32 hex digits)'
pass

def cmd_reset(pebble, args):
pebble.reset()
Expand Down Expand Up @@ -123,7 +135,7 @@ def main():
list_apps_parser.set_defaults(func=cmd_list_apps)

rm_app_parser = subparsers.add_parser('rm', help='remove installed apps')
rm_app_parser.add_argument('app_index', metavar='IDX', type=int, help='the app index to delete')
rm_app_parser.add_argument('app_index_or_hex_uuid', metavar='IDX or UUID', type=str, help='the app index or UUID to delete')
rm_app_parser.set_defaults(func=cmd_rm_app)

reset_parser = subparsers.add_parser('reset', help='reset the watch remotely')
Expand Down
7 changes: 7 additions & 0 deletions pebble/pebble.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ def remove_app(self, appid, index):
data = pack("!bII", 2, appid, index)
self._send_message("APP_MANAGER", data)

def remove_app_by_uuid(self, uuid):

"""Remove an installed application by UUID."""

data = pack("b", 0x02) + uuid
self._send_message("APP_MANAGER", data)

def get_time(self, async = False):

"""Retrieve the time from the Pebble's RTC."""
Expand Down

0 comments on commit 3caec95

Please sign in to comment.