-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
US-9484 Added Install/Delete/Launch/Close commands for BlueSky
- Loading branch information
1 parent
cd0def8
commit 4845e2e
Showing
3 changed files
with
127 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import logger from './logger'; | ||
import commands from './commands/index'; | ||
|
||
let bluesky = {}; | ||
|
||
bluesky.startSession = function (caps) { | ||
logger.info("BlueSky: Start Session"); | ||
let channelId = 'dev'; | ||
if (caps.channelId) { | ||
logger.info("caps.channelId: " + caps.channelId); | ||
channelId = caps.channelId; | ||
} | ||
// Check if app is installed | ||
let devAppInstalled = this.isAppInstalled(caps.youiEngineAppAddress, channelId); | ||
|
||
if (caps.fullReset || !devAppInstalled) { | ||
this.installApp(caps.username, caps.password, caps.app, caps.youiEngineAppAddress); | ||
} else{ | ||
this.launchApp(caps.youiEngineAppAddress, channelId); | ||
} | ||
}; | ||
|
||
bluesky.endSession = function (caps) { | ||
logger.info("BlueSky: End Session"); | ||
if (caps.fullReset) { | ||
this.removeApp(caps.username, caps.password, caps.youiEngineAppAddress); | ||
} else { | ||
this.closeApp(caps.youiEngineAppAddress); | ||
} | ||
}; | ||
|
||
bluesky.removeApp = function (username, password, youiEngineAppAddress, channelId = 'dev') { | ||
logger.info("BlueSky: Delete app"); | ||
let shell = require('shelljs'); | ||
let bluesky_delete_script = "curl --user " + username + ":" + password + " --digest --progress-bar --show-error -F 'mysubmit=Delete' -F 'archive=' --output /tmp/dev_server_out --write-out '%{http_code}' 'http://" + youiEngineAppAddress + "/plugin_install'"; | ||
shell.exec(bluesky_delete_script); | ||
}; | ||
|
||
bluesky.installApp = async function (username, password, app, youiEngineAppAddress, channelId = 'dev') { | ||
logger.info("BlueSky: Installing and launching app"); | ||
if (this.isAppInstalled(youiEngineAppAddress, channelId)){ | ||
this.removeApp(); | ||
} | ||
let bluesky_install_script = "curl -v -# -f -i --user '" + username + ":" + password + "' --digest --progress-bar -F 'mysubmit=Install' -F 'archive=@" + app + "' -F 'passwd=' http://" + youiEngineAppAddress + "/plugin_install | grep '<font color' | sed 's/<font color=\'red\'>//' "; // eslint-disable-line no-useless-escape | ||
let shell = require('shelljs'); | ||
shell.exec(bluesky_install_script); | ||
}; | ||
|
||
bluesky.launchApp = function (youiEngineAppAddress, channelId = 'dev') { | ||
logger.info("BlueSky: Launch app"); | ||
let shell = require('shelljs'); | ||
let bluesky_install_script = "curl -d '' http://" + youiEngineAppAddress + ":8060/launch/" + channelId; | ||
logger.info("BlueSky: Launch app " + bluesky_install_script); | ||
shell.exec(bluesky_install_script); | ||
}; | ||
|
||
bluesky.isAppInstalled = function (youiEngineAppAddress, channelId = 'dev') { | ||
logger.info("BlueSky: Check if App is installed"); | ||
// Check if app is installed | ||
let devAppInstalled = false; | ||
let shell = require('shelljs'); | ||
let installedApps = shell.exec("curl http://" + youiEngineAppAddress + ":8060/query/apps"); | ||
if (installedApps.includes("id=\"" + channelId + "\"")){ | ||
devAppInstalled = true; | ||
} | ||
return devAppInstalled; | ||
}; | ||
|
||
bluesky.closeApp = function (youiEngineAppAddress) { | ||
logger.info("BlueSky: Close App"); | ||
let shell = require('shelljs'); | ||
logger.info("Returning to Home Screen"); | ||
shell.exec("curl -d '' http://" + youiEngineAppAddress + ":8060/keypress/home"); | ||
}; | ||
|
||
export default bluesky; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters