-
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from appium/isaac-logger
Add error handling when real device logger does not exist
- Loading branch information
Showing
3 changed files
with
44 additions
and
19 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
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 |
---|---|---|
@@ -1,48 +1,54 @@ | ||
import { exec } from 'teen_process'; | ||
import { fs } from 'appium-support'; | ||
import logger from './logger'; | ||
|
||
const IOSDEPLOY_PATH = `ios-deploy`; | ||
|
||
class IOSDeploy { | ||
|
||
constructor (udid) { | ||
this.udid = udid; | ||
this.cmd = IOSDEPLOY_PATH;// this.cmd is in accordance with iDevice | ||
} | ||
|
||
async checkStatus () { | ||
// make sure we actually have the program | ||
await fs.which(this.cmd); | ||
} | ||
|
||
async remove (bundleid) { | ||
let remove = [`--uninstall_only`, `--id`, this.udid, `--bundle_id`, bundleid]; | ||
try { | ||
let {stdout} = await exec(this.cmd, remove, { maxBuffer: 524288}); | ||
logger.debug(`app uninstall stdout : ${stdout}`); | ||
} catch (err) { | ||
logger.debug(`Error : ${err.message}`); | ||
logger.debug(`Error : ${err.message}`); | ||
throw new Error(`coulld not remove app ${err.message}`); | ||
} | ||
} | ||
|
||
async install (app) { | ||
let install = [`--id`, this.udid, `--uninstall`, `--bundle`, app]; | ||
let install = [`--id`, this.udid, `--uninstall`, `--bundle`, app]; | ||
try { | ||
let {stdout} = await exec(this.cmd, install, { maxBuffer: 524288}); | ||
logger.debug(`app install stdout : ${stdout}`); | ||
} catch (err) { | ||
logger.debug(`Error : ${err.message}`); | ||
logger.debug(`Error : ${err.message}`); | ||
throw new Error(`could not install app ${err.message}`); | ||
} | ||
} | ||
} | ||
|
||
async isInstalled (bundleid) { | ||
let isInstalled = [`--exists`, `--id`, this.udid, `--bundle_id`, bundleid]; | ||
try { | ||
let {stdout} = await exec(this.cmd, isInstalled, { maxBuffer: 524288}); | ||
logger.debug(`app isInstalled stdout : ${stdout}`); | ||
logger.debug(`Stdout from app isInstalled check: ${stdout}`); | ||
return (stdout && (stdout.indexOf("true") > -1)); | ||
} catch (err) { | ||
logger.debug(`Error : ${err.message}`); | ||
logger.debug(`Error checking install status: ${err.message}`); | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default IOSDeploy; | ||
export default IOSDeploy; |
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