Skip to content

Commit

Permalink
Correct MacOS check and lay infra for Linux checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailArkhipov committed Aug 8, 2018
1 parent 462ff7c commit 4e12b3c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
10 changes: 7 additions & 3 deletions src/client/activation/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ export class LanguageServerExtensionActivator implements IExtensionActivator {

private checkSupportedPlatform(): boolean {
const platform = this.services.get<IPlatformService>(IPlatformService);
if (platform.isMac && platform.versionMajor === 10 && platform.versionMinor < 12) {
this.services.get<ILogger>(ILogger).logError('Unsupported MacOS');
this.appShell.showErrorMessage('Microsoft Python Language Server does not support MacOS older than 10.12.');
if (!platform.isNetCoreCompatibleOS) {
if (platform.isMac) {
this.services.get<ILogger>(ILogger).logError('Unsupported MacOS');
this.appShell.showErrorMessage('Microsoft Python Language Server does not support MacOS older than 10.12.');
}
// tslint:disable-next-line:no-suspicious-comment
// TODO: Linux messages
return false;
}
return true;
Expand Down
47 changes: 36 additions & 11 deletions src/client/common/platform/platformService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
import { injectable } from 'inversify';
import { arch, release } from 'os';
import { NON_WINDOWS_PATH_VARIABLE_NAME, WINDOWS_PATH_VARIABLE_NAME } from './constants';
import { IPlatformService } from './types';
import { IPlatformService, IVersion } from './types';

class OSVersion implements IVersion {
public get versionString(): string {
return release();
}
public get versionMajor(): number {
const parts = this.versionString.split('.');
return parts.length > 0 ? parseInt(parts[0], 10) : 0;
}
public get versionMinor(): number {
const parts = this.versionString.split('.');
return parts.length > 1 ? parseInt(parts[1], 10) : 0;
}
}

class MacOSVersion {
public get isCompatibleOS(): boolean {
// https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history
// 10.12 == Darwin 16.0
return new OSVersion().versionMajor >= 16;
}
}

@injectable()
export class PlatformService implements IPlatformService {
Expand Down Expand Up @@ -34,15 +56,18 @@ export class PlatformService implements IPlatformService {
public get virtualEnvBinName() {
return this.isWindows ? 'scripts' : 'bin';
}
public get version(): string {
return release();
}
public get versionMajor(): number {
const parts = this.version.split('.');
return parts.length > 0 ? parseInt(parts[0], 10) : 0;
}
public get versionMinor(): number {
const parts = this.version.split('.');
return parts.length > 1 ? parseInt(parts[1], 10) : 0;
public get isNetCoreCompatibleOS(): boolean {
if (this.isMac) {
return new MacOSVersion().isCompatibleOS;
}
// tslint:disable-next-line:no-suspicious-comment
// TODO: implement Linux checks. They are all over.
// release() reports kernel version. For the actual
// OS version run 'lsb_release -a' on Ubuntu,
// 'cat /etc/centos-release' on CentOS
// 'cat /etc/fedora-release' on Fedora
// 'cat /etc/lsb-release' on Mint
// 'cat /etc/redhat-release' on Red Hat
return true; // Windows matches between .NET Core and VS Code.
}
}
10 changes: 7 additions & 3 deletions src/client/common/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export interface IPlatformService {
is64bit: boolean;
pathVariableName: 'Path' | 'PATH';
virtualEnvBinName: 'bin' | 'scripts';
version: string;
versionMajor: number;
versionMinor: number;
isNetCoreCompatibleOS: boolean;
}

export type TemporaryFile = { filePath: string } & Disposable;
Expand All @@ -56,3 +54,9 @@ export interface IFileSystem {
search(globPattern: string): Promise<string[]>;
createTemporaryFile(extension: string): Promise<TemporaryFile>;
}

export interface IVersion {
readonly versionString: string;
readonly versionMajor: number;
readonly versionMinor: number;
}

0 comments on commit 4e12b3c

Please sign in to comment.