Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable app download #69

Merged
merged 20 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Calabash Launcher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ED66FA821E0AB8570081A30D /* quit_irb_session.command in Resources */ = {isa = PBXBuildFile; fileRef = ED66FA811E0AB8570081A30D /* quit_irb_session.command */; };
ED7045051DD61B9000272059 /* get_screen.command in Resources */ = {isa = PBXBuildFile; fileRef = ED7045041DD61B9000272059 /* get_screen.command */; };
ED7045071DD6202400272059 /* get_elements_by_offset.command in Resources */ = {isa = PBXBuildFile; fileRef = ED7045061DD6202400272059 /* get_elements_by_offset.command */; };
ED7278961FA78E050022505E /* app_download.command in Resources */ = {isa = PBXBuildFile; fileRef = ED7278951FA78E050022505E /* app_download.command */; };
ED85D2ED1F94D8A000E5E2D8 /* change_sim_language.command in Resources */ = {isa = PBXBuildFile; fileRef = ED85D2EC1F94D8A000E5E2D8 /* change_sim_language.command */; };
ED85D2F01F950A9400E5E2D8 /* LanguageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED85D2EF1F950A9400E5E2D8 /* LanguageViewController.swift */; };
ED9472941E365F9D00FE2982 /* ElementConstructorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED9472931E365F9C00FE2982 /* ElementConstructorViewController.swift */; };
Expand Down Expand Up @@ -98,6 +99,7 @@
ED66FA811E0AB8570081A30D /* quit_irb_session.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = quit_irb_session.command; sourceTree = "<group>"; };
ED7045041DD61B9000272059 /* get_screen.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = get_screen.command; sourceTree = "<group>"; };
ED7045061DD6202400272059 /* get_elements_by_offset.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = get_elements_by_offset.command; sourceTree = "<group>"; };
ED7278951FA78E050022505E /* app_download.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = app_download.command; sourceTree = "<group>"; };
ED85D2EC1F94D8A000E5E2D8 /* change_sim_language.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = change_sim_language.command; sourceTree = "<group>"; };
ED85D2EF1F950A9400E5E2D8 /* LanguageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageViewController.swift; sourceTree = "<group>"; };
ED9472931E365F9C00FE2982 /* ElementConstructorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementConstructorViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,6 +199,7 @@
EDD303941F8F86B00042E27F /* bash */ = {
isa = PBXGroup;
children = (
ED7278951FA78E050022505E /* app_download.command */,
ED85D2EC1F94D8A000E5E2D8 /* change_sim_language.command */,
ED9472951E37BD3E00FE2982 /* get_uniq_elements.command */,
ED66FA811E0AB8570081A30D /* quit_irb_session.command */,
Expand Down Expand Up @@ -354,6 +357,7 @@
ED4C14F01DB2A10E00A1190E /* BuildScript.command in Resources */,
EDBC88071DFEE8A6004CB840 /* kill_process.command in Resources */,
D74D80851F97F7BA0049A84F /* click_image.png in Resources */,
ED7278961FA78E050022505E /* app_download.command in Resources */,
ED7045051DD61B9000272059 /* get_screen.command in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
1 change: 1 addition & 0 deletions Launcher/Classes/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum Constants {
static let buildScript = main.path(forResource: "BuildScript", ofType: .bash)
static let killProcess = main.path(forResource: "kill_process", ofType: .bash)
static let flash = main.path(forResource: "flash", ofType: .bash)
static let appDownload = main.path(forResource: "app_download", ofType: .bash)

// Interactive Ruby Shell
static let createIRBSession = main.path(forResource: "create_irb_session", ofType: .bash)
Expand Down
18 changes: 16 additions & 2 deletions Launcher/Classes/ViewControllers/TasksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TasksViewController: NSViewController {
var devices = [""]
var timer: Timer!
var pathToCalabashFolder = ""
var linkInfoArray: ([String], [String]) = ([], [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d make it a map 🗺

var isDeviceListEmpty: Bool {
return phoneComboBox.numberOfItems == 0
}
Expand Down Expand Up @@ -128,7 +129,7 @@ class TasksViewController: NSViewController {
}

@IBAction func clickDownloadButton(_ sender: Any) {
// buildPicker.indexOfSelectedItem
downloadAppFromLink(link: linkInfoArray.0[buildPicker.indexOfSelectedItem])
}

@IBAction func buildPicker(_ sender: Any) {
Expand Down Expand Up @@ -322,7 +323,7 @@ class TasksViewController: NSViewController {

func getValuesForBuildPicker() {
buildPicker.removeAllItems()
let linkInfoArray = plistOperations.readFromPlist(forKey: Constants.Strings.linkInfoKey)
linkInfoArray = plistOperations.readFromPlist(forKey: Constants.Strings.linkInfoKey)
buildPicker.addItems(withTitles: linkInfoArray.1)

buildPicker.selectItem(at: applicationStateHandler.buildNumber)
Expand All @@ -333,6 +334,19 @@ class TasksViewController: NSViewController {
}
}

func downloadAppFromLink(link: String) {
if let launchPath = Constants.FilePaths.Bash.appDownload {
let outputStream = CommandsCore.CommandTextOutputStream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the CommandsCore prefix here?

Also, can we please not add this to the VC?

outputStream.textHandler = {text in
DispatchQueue.main.async {
self.textViewPrinter.printToTextView(text)
}
}
let commands = CommandsCore.CommandExecutor()
commands.executeCommand(at: launchPath, arguments: [link, pathToCalabashFolder], outputStream: outputStream)
}
}

func quitIrbSession() {
commands.executeCommand(at: Constants.FilePaths.Bash.quitIRBSession ?? "", arguments: [])
}
Expand Down
23 changes: 23 additions & 0 deletions Scripts/bash/app_download.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash --login
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

filename=${1##*/}
extension=${filename##*.}

cd ${2}
rm ${filename}
curl -O ${1}
if [ -e "$filename" ]; then
echo "${filename} has been succesfully downloaded"
else
echo "Whoops, looks like your link is incorrect: '${1}'"
fi

if [ ${extension} == "zip" ]; then
echo "Extracting APP from archieve"
ditto -xk ${filename} .
rm ${filename}
echo "Extracted Succesfully"
fi