public void Init(PluginInitContext context)
        {
            var s = Utilities.GetInstalledPath();

            if (string.IsNullOrEmpty(s))
            {
                Task.Run(async delegate
                {
                    context.API.ShowMsg(context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"),
                                        context.API.GetTranslation("flowlauncher_plugin_everything_installing_subtitle"), "", useMainWindowAsOwner: false);

                    await DroplexPackage.Drop(App.Everything1_3_4_686).ConfigureAwait(false);

                    context.API.ShowMsg(context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"),
                                        context.API.GetTranslation("flowlauncher_plugin_everything_installationsuccess_subtitle"), "", useMainWindowAsOwner: false);

                    SharedCommands.FilesFolders.OpenPath(installationFilePath);
                }).ContinueWith(t =>
                {
                    Log.Exception("Main", $"Failed to install Everything service", t.Exception.InnerException, "DroplexPackage.Drop");
                    MessageBox.Show(context.API.GetTranslation("flowlauncher_plugin_everything_installationfailed_subtitle"),
                                    context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"));
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
            else
            {
                installationFilePath = s;
            }

            _context  = context;
            _storage  = new PluginJsonStorage <Settings>();
            _settings = _storage.Load();
            if (_settings.MaxSearchCount <= 0)
            {
                _settings.MaxSearchCount = Settings.DefaultMaxSearchCount;
            }

            var          pluginDirectory     = context.CurrentPluginMetadata.PluginDirectory;
            const string sdk                 = "EverythingSDK";
            var          bundledSDKDirectory = Path.Combine(pluginDirectory, sdk, CpuType());
            var          sdkDirectory        = Path.Combine(_storage.DirectoryPath, sdk, CpuType());

            Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory);

            var sdkPath = Path.Combine(sdkDirectory, DLL);

            _api.Load(sdkPath);
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                Task a = DroplexPackage.Drop(App.python3_9_1);
                Task b = DroplexPackage.Drop(App.Everything1_3_4_686);
                Task c = DroplexPackage.Drop(App.Putty_0_74);

                Task.WaitAll(a, b, c);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.ReadKey();
            }
        }
示例#3
0
        static async Task Main(string[] args)
        {
            try
            {
                Task a = DroplexPackage.Drop(App.python3_9_1);
                Task b = DroplexPackage.Drop(App.Everything1_3_4_686);
                Task c = DroplexPackage.Drop(App.Putty_0_74);

                await Task.WhenAll(a, b, c);

                await DroplexPackage.Drop(App.python_3_8_9_embeddable, @"C:\temp\python-embeddable").ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.ReadKey();
            }
        }
示例#4
0
        public void Init(PluginInitContext context)
        {
            _context  = context;
            _settings = context.API.LoadSettingJsonStorage <Settings>();
            SortOptionTranlationHelper.API = context.API;

            if (_settings.MaxSearchCount <= 0)
            {
                _settings.MaxSearchCount = Settings.DefaultMaxSearchCount;
            }

            if (!_settings.EverythingInstalledPath.FileExists())
            {
                var installedLocation = Utilities.GetInstalledPath();

                if (string.IsNullOrEmpty(installedLocation) &&
                    System.Windows.Forms.MessageBox.Show(
                        string.Format(context.API.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine),
                        context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"),
                        System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    // Solves single thread apartment (STA) mode requirement error when using OpenFileDialog
                    Thread t = new Thread(() =>
                    {
                        var dlg = new System.Windows.Forms.OpenFileDialog
                        {
                            InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
                        };

                        var result = dlg.ShowDialog();
                        if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dlg.FileName))
                        {
                            installedLocation = dlg.FileName;
                        }
                    });

                    // Run your code from a thread that joins the STA Thread
                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();
                    t.Join();
                }

                if (string.IsNullOrEmpty(installedLocation))
                {
                    Task.Run(async delegate
                    {
                        context.API.ShowMsg(context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"),
                                            context.API.GetTranslation("flowlauncher_plugin_everything_installing_subtitle"), "", useMainWindowAsOwner: false);

                        await DroplexPackage.Drop(App.Everything1_4_1_1009).ConfigureAwait(false);

                        context.API.ShowMsg(context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"),
                                            context.API.GetTranslation("flowlauncher_plugin_everything_installationsuccess_subtitle"), "", useMainWindowAsOwner: false);

                        _settings.EverythingInstalledPath = "C:\\Program Files\\Everything\\Everything.exe";

                        FilesFolders.OpenPath(_settings.EverythingInstalledPath);
                    }).ContinueWith(t =>
                    {
                        _context.API.LogException("Everything.Main", $"Failed to install Everything service", t.Exception.InnerException, "DroplexPackage.Drop");
                        MessageBox.Show(context.API.GetTranslation("flowlauncher_plugin_everything_installationfailed_subtitle"),
                                        context.API.GetTranslation("flowlauncher_plugin_everything_installing_title"));
                    }, TaskContinuationOptions.OnlyOnFaulted);
                }
                else
                {
                    _settings.EverythingInstalledPath = installedLocation;
                }
            }

            var          pluginDirectory     = context.CurrentPluginMetadata.PluginDirectory;
            const string sdk                 = "EverythingSDK";
            var          bundledSdkDirectory = Path.Combine(pluginDirectory, sdk, CpuType());

            var sdkPath = Path.Combine(bundledSdkDirectory, DLL);

            _api.Load(sdkPath);
        }
示例#5
0
        public static IEnumerable <PluginPair> PythonPlugins(List <PluginMetadata> source, PluginsSettings settings)
        {
            if (!source.Any(o => o.Language.ToUpper() == AllowedLanguage.Python))
            {
                return(new List <PluginPair>());
            }

            if (!string.IsNullOrEmpty(settings.PythonDirectory) && FilesFolders.LocationExists(settings.PythonDirectory))
            {
                return(SetPythonPathForPluginPairs(source, Path.Combine(settings.PythonDirectory, PythonExecutable)));
            }

            var pythonPath = string.Empty;

            if (MessageBox.Show("Flow detected you have installed Python plugins, which " +
                                "will need Python to run. Would you like to download Python? " +
                                Environment.NewLine + Environment.NewLine +
                                "Click no if it's already installed, " +
                                "and you will be prompted to select the folder that contains the Python executable",
                                string.Empty, MessageBoxButtons.YesNo) == DialogResult.No &&
                string.IsNullOrEmpty(settings.PythonDirectory))
            {
                var dlg = new FolderBrowserDialog
                {
                    SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
                };

                var result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string pythonDirectory = dlg.SelectedPath;
                    if (!string.IsNullOrEmpty(pythonDirectory))
                    {
                        pythonPath = Path.Combine(pythonDirectory, PythonExecutable);
                        if (File.Exists(pythonPath))
                        {
                            settings.PythonDirectory = pythonDirectory;
                            Constant.PythonPath      = pythonPath;
                        }
                        else
                        {
                            MessageBox.Show("Can't find python in given directory");
                        }
                    }
                }
            }
            else
            {
                var installedPythonDirectory = Path.Combine(DataLocation.DataDirectory(), "PythonEmbeddable");

                // Python 3.8.9 is used for Windows 7 compatibility
                DroplexPackage.Drop(App.python_3_8_9_embeddable, installedPythonDirectory).Wait();

                pythonPath = Path.Combine(installedPythonDirectory, PythonExecutable);
                if (FilesFolders.FileExists(pythonPath))
                {
                    settings.PythonDirectory = installedPythonDirectory;
                    Constant.PythonPath      = pythonPath;
                }
                else
                {
                    Log.Error("PluginsLoader",
                              $"Failed to set Python path after Droplex install, {pythonPath} does not exist",
                              "PythonPlugins");
                }
            }

            if (string.IsNullOrEmpty(settings.PythonDirectory) || string.IsNullOrEmpty(pythonPath))
            {
                MessageBox.Show(
                    "Unable to set Python executable path, please try from Flow's settings (scroll down to the bottom).");
                Log.Error("PluginsLoader",
                          $"Not able to successfully set Python path, the PythonDirectory variable is still an empty string.",
                          "PythonPlugins");

                return(new List <PluginPair>());
            }

            return(SetPythonPathForPluginPairs(source, pythonPath));
        }