Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
3897ebfc
Commit
3897ebfc
authored
Aug 24, 2015
by
Ian Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup of paths and quotes.
parent
a4182561
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
40 deletions
+36
-40
sky_tool
packages/flutter/lib/sky_tool
+36
-40
No files found.
packages/flutter/lib/sky_tool
View file @
3897ebfc
...
@@ -28,7 +28,7 @@ SKY_SERVER_PORT = 9888
...
@@ -28,7 +28,7 @@ SKY_SERVER_PORT = 9888
OBSERVATORY_PORT
=
8181
OBSERVATORY_PORT
=
8181
ADB_PATH
=
'adb'
ADB_PATH
=
'adb'
APK_NAME
=
'SkyShell.apk'
APK_NAME
=
'SkyShell.apk'
ANDROID_PACKAGE
=
"org.domokit.sky.shell"
ANDROID_PACKAGE
=
'org.domokit.sky.shell'
ANDROID_COMPONENT
=
'
%
s/
%
s.SkyActivity'
%
(
ANDROID_PACKAGE
,
ANDROID_PACKAGE
)
ANDROID_COMPONENT
=
'
%
s/
%
s.SkyActivity'
%
(
ANDROID_PACKAGE
,
ANDROID_PACKAGE
)
SKY_SHELL_APP_ID
=
'com.google.SkyShell'
SKY_SHELL_APP_ID
=
'com.google.SkyShell'
...
@@ -38,7 +38,7 @@ IOS_APP_NAME = 'SkyShell.app'
...
@@ -38,7 +38,7 @@ IOS_APP_NAME = 'SkyShell.app'
DART_PATH
=
'dart'
DART_PATH
=
'dart'
PUB_PATH
=
'pub'
PUB_PATH
=
'pub'
PID_FILE_PATH
=
"/tmp/sky_tool.pids"
PID_FILE_PATH
=
'/tmp/sky_tool.pids'
PID_FILE_KEYS
=
frozenset
([
PID_FILE_KEYS
=
frozenset
([
'remote_sky_server_port'
,
'remote_sky_server_port'
,
'sky_server_pid'
,
'sky_server_pid'
,
...
@@ -47,18 +47,19 @@ PID_FILE_KEYS = frozenset([
...
@@ -47,18 +47,19 @@ PID_FILE_KEYS = frozenset([
])
])
IOS_SIM_PATH
=
[
IOS_SIM_PATH
=
[
'/Applications/iOS Simulator.app/Contents/MacOS/iOS Simulator'
os
.
path
.
join
(
'/Applications'
,
'iOS Simulator.app'
,
'Contents'
,
'MacOS'
,
'iOS Simulator'
)
]
]
SIMCTL
_PATH
=
[
XCRUN
_PATH
=
[
'/usr/bin/env'
,
os
.
path
.
join
(
'/usr'
,
'bin'
,
'env'
)
,
'xcrun'
,
'xcrun'
,
]
SIMCTL_PATH
=
XCRUN_PATH
+
[
'simctl'
,
'simctl'
,
]
]
PLIST_BUDDY_PATH
=
[
PLIST_BUDDY_PATH
=
XCRUN_PATH
+
[
'/usr/bin/env'
,
'xcrun'
,
'PlistBuddy'
,
'PlistBuddy'
,
]
]
...
@@ -171,13 +172,13 @@ class StartSky(object):
...
@@ -171,13 +172,13 @@ class StartSky(object):
if
os
.
path
.
isdir
(
project_or_path
):
if
os
.
path
.
isdir
(
project_or_path
):
sky_server_root
=
project_or_path
sky_server_root
=
project_or_path
main_dart
=
os
.
path
.
join
(
project_or_path
,
'lib'
,
'main.dart'
)
main_dart
=
os
.
path
.
join
(
project_or_path
,
'lib'
,
'main.dart'
)
missing_msg
=
"Missing lib/main.dart in project:
%
s"
%
project_or_path
missing_msg
=
'Missing lib/main.dart in project:
%
s'
%
project_or_path
else
:
else
:
# FIXME: This assumes the path is at the root of the project!
# FIXME: This assumes the path is at the root of the project!
# Instead we should walk up looking for a pubspec.yaml
# Instead we should walk up looking for a pubspec.yaml
sky_server_root
=
os
.
path
.
dirname
(
project_or_path
)
sky_server_root
=
os
.
path
.
dirname
(
project_or_path
)
main_dart
=
project_or_path
main_dart
=
project_or_path
missing_msg
=
"
%
s does not exist."
%
main_dart
missing_msg
=
'
%
s does not exist.'
%
main_dart
if
not
os
.
path
.
isfile
(
main_dart
):
if
not
os
.
path
.
isfile
(
main_dart
):
logging
.
error
(
missing_msg
)
logging
.
error
(
missing_msg
)
...
@@ -185,7 +186,7 @@ class StartSky(object):
...
@@ -185,7 +186,7 @@ class StartSky(object):
package_root
=
os
.
path
.
join
(
sky_server_root
,
'packages'
)
package_root
=
os
.
path
.
join
(
sky_server_root
,
'packages'
)
if
not
os
.
path
.
isdir
(
package_root
):
if
not
os
.
path
.
isdir
(
package_root
):
logging
.
error
(
"
%
s is not a valid packages path."
%
package_root
)
logging
.
error
(
'
%
s is not a valid packages path.'
%
package_root
)
return
2
return
2
if
not
self
.
_is_package_installed
(
ANDROID_PACKAGE
):
if
not
self
.
_is_package_installed
(
ANDROID_PACKAGE
):
...
@@ -194,17 +195,16 @@ class StartSky(object):
...
@@ -194,17 +195,16 @@ class StartSky(object):
if
args
.
install
:
if
args
.
install
:
if
not
self
.
_is_valid_script_path
():
if
not
self
.
_is_valid_script_path
():
logging
.
error
(
"'
%
s' must be located in packages/sky. "
\
logging
.
error
(
'"
%
s" must be located in packages/sky. '
"The directory packages/sky_engine must also "
\
'The directory packages/sky_engine must also '
"exist to locate
%
s."
\
'exist to locate
%
s.'
%
(
os
.
path
.
basename
(
__file__
),
APK_NAME
))
%
(
os
.
path
.
basename
(
__file__
),
APK_NAME
))
return
2
return
2
if
args
.
local_build
:
if
args
.
local_build
:
apk_path
=
os
.
path
.
join
(
os
.
path
.
normpath
(
args
.
sky_src_path
),
args
.
android_debug_build_path
,
'apks'
,
APK_NAME
)
apk_path
=
os
.
path
.
join
(
os
.
path
.
normpath
(
args
.
sky_src_path
),
args
.
android_debug_build_path
,
'apks'
,
APK_NAME
)
else
:
else
:
apk_path
=
os
.
path
.
join
(
APK_DIR
,
APK_NAME
)
apk_path
=
os
.
path
.
join
(
APK_DIR
,
APK_NAME
)
if
not
os
.
path
.
exists
(
apk_path
):
if
not
os
.
path
.
exists
(
apk_path
):
logging
.
error
(
"'
%
s' does not exist?"
%
apk_path
)
logging
.
error
(
'"
%
s" does not exist.'
%
apk_path
)
return
2
return
2
cmd
=
[
ADB_PATH
,
'install'
,
'-r'
,
apk_path
]
cmd
=
[
ADB_PATH
,
'install'
,
'-r'
,
apk_path
]
...
@@ -365,9 +365,7 @@ class IOSSimulator(object):
...
@@ -365,9 +365,7 @@ class IOSSimulator(object):
def
get_simulator_device_id
(
cls
):
def
get_simulator_device_id
(
cls
):
if
cls
.
_device_id
is
not
None
:
if
cls
.
_device_id
is
not
None
:
return
cls
.
_device_id
return
cls
.
_device_id
cmd
=
[
cmd
=
SIMCTL_PATH
+
[
'xcrun'
,
'simctl'
,
'list'
,
'list'
,
'devices'
,
'devices'
,
]
]
...
@@ -389,7 +387,7 @@ class IOSSimulator(object):
...
@@ -389,7 +387,7 @@ class IOSSimulator(object):
def
get_simulator_path
(
cls
):
def
get_simulator_path
(
cls
):
if
cls
.
_simulator_path
is
not
None
:
if
cls
.
_simulator_path
is
not
None
:
return
cls
.
_simulator_path
return
cls
.
_simulator_path
home_dir
=
os
.
path
.
expanduser
(
"~"
)
home_dir
=
os
.
path
.
expanduser
(
'~'
)
device_id
=
cls
.
get_simulator_device_id
()
device_id
=
cls
.
get_simulator_device_id
()
if
device_id
is
None
:
if
device_id
is
None
:
# TODO: Maybe start the simulator?
# TODO: Maybe start the simulator?
...
@@ -405,7 +403,7 @@ class IOSSimulator(object):
...
@@ -405,7 +403,7 @@ class IOSSimulator(object):
simulator_path
=
cls
.
get_simulator_path
()
simulator_path
=
cls
.
get_simulator_path
()
cmd
=
[
cmd
=
[
'find'
,
'find'
,
simulator_path
+
'/data/Containers/Data/Application'
,
os
.
path
.
join
(
simulator_path
,
'data'
,
'Containers'
,
'Data'
,
'Application'
)
,
'-name'
,
'-name'
,
SKY_SHELL_APP_ID
SKY_SHELL_APP_ID
]
]
...
@@ -450,15 +448,15 @@ class IOSSimulator(object):
...
@@ -450,15 +448,15 @@ class IOSSimulator(object):
subprocess
.
check_call
(
cmd
)
subprocess
.
check_call
(
cmd
)
def
get_application_identifier
(
self
,
path
):
def
get_application_identifier
(
self
,
path
):
identifier
=
subprocess
.
check_output
(
PLIST_BUDDY_PATH
+
[
identifier
=
subprocess
.
check_output
(
PLIST_BUDDY_PATH
+
[
'-c'
,
'-c'
,
'Print CFBundleIdentifier'
,
'Print CFBundleIdentifier'
,
'
%
s/Info.plist'
%
path
,
os
.
path
.
join
(
path
,
'Info.plist'
)
])
])
return
identifier
.
strip
()
return
identifier
.
strip
()
def
is_simulator_booted
(
self
):
def
is_simulator_booted
(
self
):
devices
=
subprocess
.
check_output
(
SIMCTL_PATH
+
[
'list'
,
'devices'
])
.
strip
()
.
split
(
'
\n
'
)
devices
=
subprocess
.
check_output
(
SIMCTL_PATH
+
[
'list'
,
'devices'
])
.
strip
()
.
split
(
'
\n
'
)
for
device
in
devices
:
for
device
in
devices
:
if
re
.
search
(
r'\(Booted\)'
,
device
):
if
re
.
search
(
r'\(Booted\)'
,
device
):
return
True
return
True
...
@@ -473,7 +471,7 @@ class IOSSimulator(object):
...
@@ -473,7 +471,7 @@ class IOSSimulator(object):
subprocess
.
Popen
(
args
.
ios_sim_path
)
subprocess
.
Popen
(
args
.
ios_sim_path
)
else
:
else
:
subprocess
.
Popen
(
IOS_SIM_PATH
)
subprocess
.
Popen
(
IOS_SIM_PATH
)
while
not
is_simulator_booted
():
while
not
self
.
is_simulator_booted
():
print
(
'Waiting for iOS Simulator to boot...'
)
print
(
'Waiting for iOS Simulator to boot...'
)
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
...
@@ -502,7 +500,7 @@ class IOSSimulator(object):
...
@@ -502,7 +500,7 @@ class IOSSimulator(object):
'-server'
,
'-server'
,
args
.
server
args
.
server
]
]
return
subprocess
.
check_output
(
SIMCTL_PATH
+
launch_args
)
.
strip
()
return
subprocess
.
check_output
(
SIMCTL_PATH
+
launch_args
)
.
strip
()
def
launch_app
(
self
,
args
,
pids
):
def
launch_app
(
self
,
args
,
pids
):
self
.
install_launch_and_wait
(
args
,
pids
,
False
)
self
.
install_launch_and_wait
(
args
,
pids
,
False
)
...
@@ -510,9 +508,7 @@ class IOSSimulator(object):
...
@@ -510,9 +508,7 @@ class IOSSimulator(object):
def
debug_app
(
self
,
args
,
pids
):
def
debug_app
(
self
,
args
,
pids
):
launch_res
=
self
.
install_launch_and_wait
(
args
,
pids
,
True
)
launch_res
=
self
.
install_launch_and_wait
(
args
,
pids
,
True
)
launch_pid
=
re
.
search
(
'.*: (
\
d+)'
,
launch_res
)
.
group
(
1
)
launch_pid
=
re
.
search
(
'.*: (
\
d+)'
,
launch_res
)
.
group
(
1
)
return
os
.
system
(
' '
.
join
([
return
os
.
system
(
' '
.
join
(
XCRUN_PATH
+
[
'/usr/bin/env'
,
'xcrun'
,
'lldb'
,
'lldb'
,
# TODO(iansf): get this working again
# TODO(iansf): get this working again
# '-s',
# '-s',
...
@@ -718,10 +714,10 @@ class SkyShellRunner(object):
...
@@ -718,10 +714,10 @@ class SkyShellRunner(object):
global
ADB_PATH
global
ADB_PATH
if
'ANDROID_HOME'
in
os
.
environ
:
if
'ANDROID_HOME'
in
os
.
environ
:
android_home_dir
=
os
.
environ
[
'ANDROID_HOME'
]
android_home_dir
=
os
.
environ
[
'ANDROID_HOME'
]
ADB_PATH
=
os
.
path
.
join
(
android_home_dir
,
'sdk
/platform-tools/
adb'
)
ADB_PATH
=
os
.
path
.
join
(
android_home_dir
,
'sdk
'
,
'platform-tools'
,
'
adb'
)
def
_is_valid_adb_version
(
self
,
adb_version
):
def
_is_valid_adb_version
(
self
,
adb_version
):
# Sample output:
"Android Debug Bridge version 1.0.31"
# Sample output:
'Android Debug Bridge version 1.0.31'
version_fields
=
re
.
search
(
'(
\
d+)
\
.(
\
d+)
\
.(
\
d+)'
,
adb_version
)
version_fields
=
re
.
search
(
'(
\
d+)
\
.(
\
d+)
\
.(
\
d+)'
,
adb_version
)
if
version_fields
:
if
version_fields
:
major_version
=
int
(
version_fields
.
group
(
1
))
major_version
=
int
(
version_fields
.
group
(
1
))
...
@@ -744,13 +740,13 @@ class SkyShellRunner(object):
...
@@ -744,13 +740,13 @@ class SkyShellRunner(object):
if
self
.
_is_valid_adb_version
(
adb_version
):
if
self
.
_is_valid_adb_version
(
adb_version
):
return
True
return
True
adb_path
=
subprocess
.
check_output
(
[
'which'
,
ADB_PATH
])
.
rstrip
()
adb_path
=
subprocess
.
check_output
([
'which'
,
ADB_PATH
])
.
rstrip
()
logging
.
error
(
"'
%
s' is too old. Need 1.0.32 or later. "
\
logging
.
error
(
'"
%
s" is too old. Need 1.0.32 or later. '
"Try setting ANDROID_HOME."
%
adb_path
)
'Try setting ANDROID_HOME.'
%
adb_path
)
return
False
return
False
except
OSError
:
except
OSError
:
logging
.
error
(
"'adb' (from the Android SDK) not in $PATH, can't continue."
)
logging
.
error
(
'"adb" (from the Android SDK) not in $PATH, cannot continue.'
)
return
False
return
False
return
True
return
True
...
@@ -764,14 +760,14 @@ class SkyShellRunner(object):
...
@@ -764,14 +760,14 @@ class SkyShellRunner(object):
subprocess
.
call
([
ADB_PATH
,
'start-server'
])
subprocess
.
call
([
ADB_PATH
,
'start-server'
])
sdk_version
=
subprocess
.
check_output
(
sdk_version
=
subprocess
.
check_output
(
[
ADB_PATH
,
'shell'
,
'getprop'
,
'ro.build.version.sdk'
])
.
rstrip
()
[
ADB_PATH
,
'shell'
,
'getprop'
,
'ro.build.version.sdk'
])
.
rstrip
()
# Sample output:
"22"
# Sample output:
'22'
if
not
sdk_version
.
isdigit
():
if
not
sdk_version
.
isdigit
():
logging
.
error
(
"Unexpected response from getprop: '
%
s'."
%
sdk_version
)
logging
.
error
(
'Unexpected response from getprop: "
%
s".'
%
sdk_version
)
return
False
return
False
if
int
(
sdk_version
)
<
22
:
if
int
(
sdk_version
)
<
22
:
logging
.
error
(
"Version '
%
s' of the Android SDK is too old. "
\
logging
.
error
(
'Version "
%
s" of the Android SDK is too old. '
"Need Lollipop (22) or later. "
%
sdk_version
)
'Need Lollipop (22) or later. '
%
sdk_version
)
return
False
return
False
except
subprocess
.
CalledProcessError
as
e
:
except
subprocess
.
CalledProcessError
as
e
:
...
@@ -783,7 +779,7 @@ class SkyShellRunner(object):
...
@@ -783,7 +779,7 @@ class SkyShellRunner(object):
try
:
try
:
subprocess
.
check_output
([
DART_PATH
,
'--version'
],
stderr
=
subprocess
.
STDOUT
)
subprocess
.
check_output
([
DART_PATH
,
'--version'
],
stderr
=
subprocess
.
STDOUT
)
except
OSError
:
except
OSError
:
logging
.
error
(
"'dart' (from the Dart SDK) not in $PATH, can't continue."
)
logging
.
error
(
'"dart" (from the Dart SDK) not in $PATH, cannot continue.'
)
return
False
return
False
return
True
return
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment