Esempio n. 1
0
 public ServiceConfigurationForm()
 {
     hostReachabilityTimer = StartHostReachabilityTimer();
     InitializeComponent();
     FormClosed += ServiceConfigurationForm_FormClosed;
     try
     {
         configurationFilePath = Configuration.GetDefaultConfigFilePath();
         configuration         = new Configuration(configurationFilePath);
         LoadServices();
     }
     catch (Exception e)
     {
         Log.Error("Unable to load services.", e);
     }
     try
     {
         upToDateConfiguration = new Configuration(ThisAddIn.GetSetting("PathToUpToDateConfigurations"));
         LoadUpToDateServices();
     }
     catch (Exception e)
     {
         Log.Error("Unable to load up to date services.", e);
     }
 }
Esempio n. 2
0
        private static void InstallPythonModules(IList <string> pythonModules)
        {
            if (pythonModules == null || pythonModules.Count == 0)
            {
                return;
            }

            string pythonPath = ThisAddIn.GetSetting("PathToPython");

            if (!File.Exists(pythonPath))
            {
                throw new Exception(string.Format("Path to Python '{0}' cannot be found.", pythonPath));
            }

            string commandLine = "-m pip install ";

            foreach (string pythonModule in pythonModules)
            {
                commandLine += string.Format("{0} ", pythonModule);
            }
            commandLine += "--upgrade";

            Log.Debug("Install python modules...");
            Process installModules = new Process();

            installModules.StartInfo.FileName        = pythonPath;
            installModules.StartInfo.Arguments       = commandLine;
            installModules.StartInfo.UseShellExecute = false;
            installModules.StartInfo.CreateNoWindow  = true;
            installModules.Start();
        }
Esempio n. 3
0
 private void ActivateOrDeactivateUDFGeneration(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ThisAddIn.SetSetting("GenerateUDFAtStartup", "" + generateUDFAtStartupButton.Checked);
         Log.DebugFormat("User defined functions generation at startup set to {0}", generateUDFAtStartupButton.Checked);
     }
     catch (ConfigurationErrorsException ex)
     {
         Log.Error("Unable to update configuration.", ex);
     }
 }
Esempio n. 4
0
 private void ActivateOrDeactivateAutoUpdate(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ThisAddIn.SetSetting("AutoCheckForUpdates", "" + autoUpdateButton.Checked);
         Log.DebugFormat("Auto check for update set to {0}", autoUpdateButton.Checked);
     }
     catch (ConfigurationErrorsException ex)
     {
         Log.Error("Unable to update configuration.", ex);
     }
 }
Esempio n. 5
0
        internal Updater()
        {
            pythonPath = ThisAddIn.GetSetting("PathToPython");
            if (!File.Exists(pythonPath))
            {
                throw new Exception(string.Format("Path to Python '{0}' cannot be found.", pythonPath));
            }

            update_script = ThisAddIn.GetSetting("PathToUpdateScript");
            if (!File.Exists(update_script))
            {
                throw new Exception(string.Format("PyxelRest auto update script '{0}' cannot be found.", update_script));
            }

            path_to_up_to_date_configurations = ThisAddIn.GetSetting("PathToUpToDateConfigurations");
        }
Esempio n. 6
0
        private void PyxelRestRibbon_Load(object sender, RibbonUIEventArgs e)
        {
            developerGroup.Label = string.Format("Excel {0} - Python {1}", Globals.ThisAddIn.GetVersion(), Globals.ThisAddIn.GetPyxelRestVersion());

            string autoCheckForUpdates = ThisAddIn.GetSetting("AutoCheckForUpdates");

            autoUpdateButton.Enabled = !string.IsNullOrEmpty(autoCheckForUpdates);
            autoUpdateButton.Checked = "True".Equals(autoCheckForUpdates);
            autoUpdateButton.Click  += ActivateOrDeactivateAutoUpdate;

            generateUDFAtStartupButton.Checked = ThisAddIn.GenerateUDFAtStartup();

            importButton.Click     += ImportUserDefinedFunctions;
            configureButton.Click  += ConfigureServices;
            openFolderButton.Click += OpenPyxelRestFolder;
        }
Esempio n. 7
0
        internal static void UpdateServices()
        {
            try
            {
                string         configurationFilePath = Configuration.GetDefaultConfigFilePath();
                var            configuration         = new Configuration(configurationFilePath);
                List <Service> configuredServices    = configuration.Load();

                var            upToDateConfiguration = new Configuration(ThisAddIn.GetSetting("PathToUpToDateConfigurations"));
                List <Service> upToDateServices      = upToDateConfiguration.Load();

                if (upToDateServices.Count > 0)
                {
                    bool updated = false;

                    foreach (Service service in configuredServices)
                    {
                        Service upToDateService = upToDateServices.Find(s => s.Name.Equals(service.Name));
                        if (upToDateService != null)
                        {
                            service.UpdateFrom(upToDateService);
                            InstallPythonModules(service.PythonModules);
                            updated = true;
                        }
                    }

                    if (updated)
                    {
                        configuration.Save(configurationFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to keep services configuration up to date.", ex);
            }
        }