Example #1
0
        /// <summary>
        /// Create a CreateVirtualEnvironmentView with default values.
        /// </summary>
        public CreateVirtualEnvironmentView(bool isCreate)
        {
            _isCreate = isCreate;
            var componentService = (IComponentModel)(PythonToolsPackage.GetGlobalService(typeof(SComponentModel)));
            var factoryProviders = componentService.GetExtensions <IPythonInterpreterFactoryProvider>();

            var availableInterpreters = new List <PythonInterpreterView>();

            // TODO: Can we filter based upon interpreters w/ virtual env installed?
            foreach (var factoryProvider in factoryProviders)
            {
                foreach (var factory in factoryProvider.GetInterpreterFactories())
                {
                    availableInterpreters.Add(new PythonInterpreterView(factory));
                }
            }
            _availableInterpreters = new ReadOnlyCollection <PythonInterpreterView>(availableInterpreters);

            PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            if (IsAnyAvailableInterpreters)
            {
                Interpreter = AvailableInterpreters[0];
            }
        }
Example #2
0
 internal static void GotoSource(this LocationInfo location)
 {
     PythonToolsPackage.NavigateTo(
         location.FilePath,
         Guid.Empty,
         location.Line - 1,
         location.Column - 1);
 }
Example #3
0
        private void BrowseSurveyNewsOnIdle(object sender, ComponentManagerEventArgs e)
        {
            _pyService.OnIdle -= BrowseSurveyNewsOnIdle;

            lock (_surveyNewsUrlLock) {
                if (!string.IsNullOrEmpty(_surveyNewsUrl))
                {
                    PythonToolsPackage.OpenVsWebBrowser(_pyService.Site, _surveyNewsUrl);
                    _surveyNewsUrl = null;
                }
            }
        }
Example #4
0
        internal static void GotoSource(this LocationInfo location, IServiceProvider serviceProvider)
        {
            string zipFileName = VsProjectAnalyzer.GetZipFileName(location.ProjectEntry);

            if (zipFileName == null)
            {
                PythonToolsPackage.NavigateTo(
                    serviceProvider,
                    location.FilePath,
                    Guid.Empty,
                    location.Line - 1,
                    location.Column - 1);
            }
        }
        /// <summary>
        /// Default constructor of the package.
        /// Inside this method you can place any initialization code that does not require
        /// any Visual Studio service because at this point the package object is created but
        /// not sited yet inside Visual Studio environment. The place to do all the other
        /// initialization is the Initialize method.
        /// </summary>
        public PythonToolsPackage()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
#pragma warning disable 0618
            Instance = this;
#pragma warning restore 0618

#if DEBUG
            System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (sender, e) => {
                if (!e.Observed)
                {
                    var str = e.Exception.ToString();
                    if (str.Contains("Python"))
                    {
                        try {
                            ActivityLog.LogError(
                                "UnobservedTaskException",
                                string.Format("An exception in a task was not observed: {0}", e.Exception.ToString())
                                );
                        } catch (InvalidOperationException) {
                        }
                        Debug.Fail("An exception in a task was not observed. See ActivityLog.xml for more details.", e.Exception.ToString());
                    }
                    e.SetObserved();
                }
            };
#endif

            if (IsIpyToolsInstalled())
            {
                MessageBox.Show(
                    @"WARNING: Both Python Tools for Visual Studio and IronPython Tools are installed.

Only one extension can handle Python source files and having both installed will usually cause both to be broken.

You should uninstall IronPython 2.7 and re-install it with the ""Tools for Visual Studio"" option unchecked.",
                    "Python Tools for Visual Studio",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
        }
Example #6
0
        /// <summary>
        /// Default constructor of the package.
        /// Inside this method you can place any initialization code that does not require 
        /// any Visual Studio service because at this point the package object is created but 
        /// not sited yet inside Visual Studio environment. The place to do all the other 
        /// initialization is the Initialize method.
        /// </summary>
        public PythonToolsPackage() {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
#pragma warning disable 0618
            Instance = this;
#pragma warning restore 0618

#if DEBUG
            System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (sender, e) => {
                if (!e.Observed) {
                    var str = e.Exception.ToString();
                    if (str.Contains("Python")) {
                        try {
                            ActivityLog.LogError(
                                "UnobservedTaskException",
                                string.Format("An exception in a task was not observed: {0}", e.Exception.ToString())
                            );
                        } catch (InvalidOperationException) {
                        }
                        Debug.Fail("An exception in a task was not observed. See ActivityLog.xml for more details.", e.Exception.ToString());
                    }
                    e.SetObserved();
                }
            };
#endif

            if (IsIpyToolsInstalled()) {
                MessageBox.Show(
                    @"WARNING: Both Python Tools for Visual Studio and IronPython Tools are installed.

Only one extension can handle Python source files and having both installed will usually cause both to be broken.

You should uninstall IronPython 2.7 and re-install it with the ""Tools for Visual Studio"" option unchecked.",
                    "Python Tools for Visual Studio",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
        }
Example #7
0
 /// <summary>
 /// Default constructor of the package.
 /// Inside this method you can place any initialization code that does not require
 /// any Visual Studio service because at this point the package object is created but
 /// not sited yet inside Visual Studio environment. The place to do all the other
 /// initialization is the Initialize method.
 /// </summary>
 public PythonToolsPackage()
 {
     Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
     Instance = this;
 }