Skip to content

Commit

Permalink
fix: Update the path to the system macOS Python interpreter (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Jun 2, 2022
1 parent 5d47028 commit eed9f58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash';
import log from './logger';
import { exec } from 'teen_process';
import { fs } from '@appium/support';
import { SYSTEM_PYTHON_PATH } from './utils';

const LYFT_SET_LOCATION = 'set-simulator-location';

Expand Down Expand Up @@ -72,7 +73,7 @@ async function setLocationWithIdb (idb, latitude, longitude) {
*/
async function setLocationWithAppleScript (sim, latitude, longitude, menu = 'Debug') {
// Make sure system-wide decimal separator is used
const decimalSeparator = (await exec('/usr/bin/python', [
const decimalSeparator = (await exec(SYSTEM_PYTHON_PATH, [
'-c',
'from AppKit import NSNumberFormatter;' +
'import sys;' +
Expand Down
6 changes: 4 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import Simulator from './simulator-xcode-6';
const DEFAULT_SIM_SHUTDOWN_TIMEOUT = 30000;
const SAFARI_STARTUP_TIMEOUT = 25 * 1000;
const MOBILE_SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
const SYSTEM_PYTHON_PATH = '/usr/bin/python3';
const PROCESS_LAUNCH_OK_PATTERN = (bundleId) => new RegExp(`${bundleId.replace('.', '\\.')}:\\s+\\d+`);
const APP_ACTIVATION_SCRIPT = (pid) => `#!/usr/bin/python
const APP_ACTIVATION_SCRIPT = (pid) => `#!${SYSTEM_PYTHON_PATH}
from AppKit import NSApplicationActivateIgnoringOtherApps, NSApplicationActivateAllWindows
from Cocoa import NSRunningApplication
Expand Down Expand Up @@ -322,7 +323,7 @@ async function activateApp (pid) {
});
await fs.writeFile(tmpScript, APP_ACTIVATION_SCRIPT(pid), 'utf8');
try {
await exec('/usr/bin/python', [tmpScript]);
await exec(SYSTEM_PYTHON_PATH, [tmpScript]);
} finally {
await fs.rimraf(tmpScript);
}
Expand Down Expand Up @@ -373,5 +374,6 @@ export {
activateApp,
SAFARI_STARTUP_TIMEOUT,
MOBILE_SAFARI_BUNDLE_ID,
SYSTEM_PYTHON_PATH,
launchApp,
};

0 comments on commit eed9f58

Please sign in to comment.