Skip to content

Commit

Permalink
add missing, change launch kill from false to true
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Jan 12, 2023
1 parent f20fa00 commit b026902
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,4 @@ usbmuxd-dumpdata
.DS_Store
tmp/
*.pem
dumpdata/
6 changes: 2 additions & 4 deletions tidevice/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def cmd_launch(args: argparse.Namespace):
pid = ts.app_launch(args.bundle_id,
app_env=env,
args=args.arguments,
kill_running=args.kill)
kill_running=not args.skip_running)
print("PID:", pid)
except ServiceError as e:
sys.exit(e)
Expand Down Expand Up @@ -764,9 +764,7 @@ def cmd_test(args: argparse.Namespace):
dict(action=cmd_launch,
command="launch",
flags=[
dict(args=['--kill'],
action='store_true',
help='kill app if running'),
dict(args=['--skip-running'], action='store_true', help='not kill app if running'),
dict(args=["bundle_id"], help="app bundleId"),
dict(args=['arguments'], nargs='*', help='app arguments'),
dict(args=['-e', '--env'],
Expand Down
36 changes: 36 additions & 0 deletions tidevice/session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Created on Wed Jan 11 2023 17:00:08 by codeskyblue
"""

from .exceptions import MuxServiceError
from ._safe_socket import PlistSocketProxy
from ._proto import PROGRAM_NAME


class Session:
def __init__(self, s: PlistSocketProxy, session_id: str):
self.__ps = s
self.__session_id = session_id

def get_plistsocket(self) -> PlistSocketProxy:
return self.__ps

def close(self):
s = self.__ps
s.send_packet({
"Request": "StopSession",
"ProtocolVersion": '2',
"Label": PROGRAM_NAME,
"SessionID": self.__session_id,
})
s.recv_packet()

def __enter__(self):
return self.__ps

def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
self.__ps.close()

0 comments on commit b026902

Please sign in to comment.