use of com.jetbrains.python.packaging.PyPackage in project intellij-community by JetBrains.
the class SphinxRunConfiguration method createConfigurationEditor.
@Override
protected SettingsEditor<? extends RunConfiguration> createConfigurationEditor() {
final SphinxTasksModel model = new SphinxTasksModel();
if (!model.contains("pdf") && getSdk() != null) {
final List<PyPackage> packages = PyPackageManager.getInstance(getSdk()).getPackages();
if (packages != null) {
final PyPackage rst2pdf = PyPackageUtil.findPackage(packages, "rst2pdf");
if (rst2pdf != null) {
model.add(13, "pdf");
}
}
}
RestConfigurationEditor editor = new RestConfigurationEditor(getProject(), this, model);
editor.setConfigurationName("Sphinx task");
editor.setOpenInBrowserVisible(false);
editor.setInputDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor());
editor.setOutputDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor());
return editor;
}
use of com.jetbrains.python.packaging.PyPackage in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method checkValid.
@Override
public boolean checkValid() {
myInstallFramework = false;
if (!super.checkValid()) {
return false;
}
if (myProjectGenerator instanceof PythonProjectGenerator) {
final Sdk sdk = getSdk();
if (sdk == null) {
if (!((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
setErrorText("No Python interpreter selected");
return false;
}
return true;
}
if (PythonSdkType.isInvalid(sdk)) {
setErrorText("Choose valid python interpreter");
return false;
}
final List<String> warningList = new ArrayList<>();
final boolean isPy3k = PythonSdkType.getLanguageLevelForSdk(sdk).isPy3K();
try {
acceptsSdk(myProjectGenerator, sdk, new File(myLocationField.getText()));
} catch (final PythonProjectGenerator.PyNoProjectAllowedOnSdkException e) {
setErrorText(e.getMessage());
return false;
}
if (myRemotePathRequired && StringUtil.isEmpty(myRemotePathField.getTextField().getText())) {
setErrorText("Remote path not provided");
return false;
}
if (myProjectGenerator instanceof PyFrameworkProjectGenerator) {
PyFrameworkProjectGenerator frameworkProjectGenerator = (PyFrameworkProjectGenerator) myProjectGenerator;
String frameworkName = frameworkProjectGenerator.getFrameworkTitle();
if (!isFrameworkInstalled(sdk)) {
if (PyPackageUtil.packageManagementEnabled(sdk)) {
myInstallFramework = true;
final List<PyPackage> packages = PyPackageUtil.refreshAndGetPackagesModally(sdk);
if (packages == null) {
warningList.add(frameworkName + " will be installed on the selected interpreter");
return false;
}
if (!PyPackageUtil.hasManagement(packages)) {
warningList.add("Python packaging tools and " + frameworkName + " will be installed on the selected interpreter");
} else {
warningList.add(frameworkName + " will be installed on the selected interpreter");
}
} else {
warningList.add(frameworkName + " is not installed on the selected interpreter");
}
}
final ValidationResult warningResult = ((PythonProjectGenerator) myProjectGenerator).warningValidation(sdk);
if (!warningResult.isOk()) {
warningList.add(warningResult.getErrorMessage());
}
if (!warningList.isEmpty()) {
final String warning = StringUtil.join(warningList, "<br/>");
setWarningText(warning);
}
if (isPy3k && !((PyFrameworkProjectGenerator) myProjectGenerator).supportsPython3()) {
setErrorText(frameworkName + " is not supported for the selected interpreter");
return false;
}
}
}
return true;
}
use of com.jetbrains.python.packaging.PyPackage in project intellij-community by JetBrains.
the class IpnbConnectionManager method connectToIpythonServer.
private boolean connectToIpythonServer(@NotNull final IpnbCodePanel codePanel, @NotNull final IpnbFileEditor fileEditor, @NotNull final String path, @NotNull final String url) {
final IpnbSettings ipnbSettings = IpnbSettings.getInstance(myProject);
final boolean isRemote = ipnbSettings.isRemote();
if (!isRemote) {
if (myToken != null)
return startConnection(codePanel, path, url, true);
final Module module = ProjectFileIndex.SERVICE.getInstance(myProject).getModuleForFile(fileEditor.getVirtualFile());
if (module != null) {
final Sdk sdk = PythonSdkType.findPythonSdk(module);
if (sdk != null) {
final List<PyPackage> packages = PyPackageManager.getInstance(sdk).getPackages();
if (packages != null) {
final PyPackage notebookPackage = PyPackageUtil.findPackage(packages, "notebook");
if (notebookPackage != null && VersionComparatorUtil.compare(notebookPackage.getVersion(), "4.3.0") >= 0) {
ApplicationManager.getApplication().invokeAndWait(() -> myToken = askForToken(url));
if (myToken == null)
return false;
}
}
}
}
}
return startConnection(codePanel, path, url, isRemote);
}
Aggregations