forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonExecutionFactory.ts
More file actions
24 lines (22 loc) · 1.37 KB
/
Copy pathpythonExecutionFactory.ts
File metadata and controls
24 lines (22 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { IConfigurationService } from '../types';
import { PythonExecutionService } from './pythonProcess';
import { ExecutionFactoryCreationOptions, IProcessServiceFactory, IPythonExecutionFactory, IPythonExecutionService } from './types';
@injectable()
export class PythonExecutionFactory implements IPythonExecutionFactory {
private readonly configService: IConfigurationService;
private processServiceFactory: IProcessServiceFactory;
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
this.processServiceFactory = serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory);
this.configService = serviceContainer.get<IConfigurationService>(IConfigurationService);
}
public async create(options: ExecutionFactoryCreationOptions): Promise<IPythonExecutionService> {
const pythonPath = options.pythonPath ? options.pythonPath : this.configService.getSettings(options.resource).pythonPath;
const processService = await this.processServiceFactory.create(options.resource);
return new PythonExecutionService(this.serviceContainer, processService, pythonPath);
}
}