コード例 #1
0
        public override bool AfterInstall(Package package, RhinoInfo[] RhinoList, RMA.RhiExec.Engine.InstallerUser InstallAsUser)
        {
            ClearPluginInfo();

              m_package = package;
              if (m_package == null)
            return false;

              string PackageFolder = package.PackagePath;
              ReportProgress("PythonPackage.Install() starting for Package at '" + PackageFolder + "'", LogLevel.Info);

              // Find all the *_cmd.py files (in top directory only, not subdirectories) and register them with IronPython
              if (!Plugin.IsValid())
              {
            ReportProgress("Package Description:\n" + Describe(), LogLevel.Info);
            ReportProgress("Package failed to initialize properly: " + PackageFolder, LogLevel.Error);
            return false;
              }

              string[] commands = Plugin.Commands;

              if (commands.Length == 0)
              {
            ReportProgress("No files named *_cmd.py found in " + PackageFolder, LogLevel.Error);
            return false;
              }

              // HKEY_CURRENT_USER\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList
              RegistryKey RegCmd_32 = Registry.CurrentUser.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList");
              if (RegCmd_32 == null)
            ReportProgress(@"Unable to write to HKCU\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList", LogLevel.Error);

              RegistryKey RegCmd_64 = Registry.CurrentUser.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0x64\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList");
              if (RegCmd_64 == null)
            ReportProgress(@"Unable to write to HKCU\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList", LogLevel.Error);

              foreach (string cmd in commands)
              {
            // Register this command in IronPython:
            if (RegCmd_32 != null) // 32-bit
              RegCmd_32.SetValue(cmd, "66;" + cmd, RegistryValueKind.String);
            if (RegCmd_64 != null) // 64-bit
              RegCmd_64.SetValue(cmd, "66;" + cmd, RegistryValueKind.String);

            ReportProgress("Registering command: " + cmd, LogLevel.Info);
              }

              return true;
        }
コード例 #2
0
        public override bool ContainsRecognizedPayload(Package package)
        {
            PackageFileKey key = package.FindSingleFile(PackageManifestName);
              if (key != null)
              {
            string manifestFullPath = package.GetFullPath(key);
            if (File.Exists(manifestFullPath))
            {
              return LoadManifest(Path.GetDirectoryName(manifestFullPath));
            }
            ReportProgress(string.Format("Recognized payload as {0} Package", m_content_type.ToString()), LogLevel.Info);
            return true;
              }

              ReportProgress(string.Format("Package not recognized as {0} Package", m_content_type.ToString()), LogLevel.Info);
              return false;
        }
コード例 #3
0
        public override bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser)
        {
            // Delete the entire Localization folder if it exists in the Roaming profile.
              // It will be replaced by a Template Files folder, and most localization stuff will move to the local profile.
              //try
              //{
              //  string oldPath = Path.Combine(InstallerEngine.CurrentUserRoamingProfileRoot, @"Localization");
              //  if (Directory.Exists(oldPath))
              //  {
              //    Directory.Delete(oldPath, true);
              //  }
              //}
              //finally
              //{
              //}

              return true;
        }
コード例 #4
0
 public override bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser)
 {
     string oldDir = Path.Combine(InstallerEngine.CurrentUserRoamingProfileRoot, @"Localization\HelpMedia");
       if (Directory.Exists(oldDir))
       {
     try
     {
       Directory.Delete(oldDir, true);
     }
     // ReSharper disable EmptyGeneralCatchClause
     catch
     // ReSharper restore EmptyGeneralCatchClause
     {
       // We don't care if it fails; it'll clean up more next time.
     }
       }
       return true;
 }
コード例 #5
0
 public override bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser)
 {
     // Delete tutorials from roaming profile, if they exist.
       string RoamingProfileTutorialFolder = InstallerEngine.InstallRoot(PackageInstallRoot.CurrentUserRoamingProfile);
       RoamingProfileTutorialFolder = Path.Combine(RoamingProfileTutorialFolder, "Tutorials");
       if (Directory.Exists(RoamingProfileTutorialFolder))
       {
     try
     {
       Directory.Delete(RoamingProfileTutorialFolder, true);
     }
     // ReSharper disable EmptyGeneralCatchClause
     catch
     // ReSharper restore EmptyGeneralCatchClause
     {
       // We don't care if the delete doesn't succeed.
     }
       }
       return true;
 }
コード例 #6
0
ファイル: Package.Installer.UI.cs プロジェクト: Crae/rhiexec
        public override bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser)
        {
            if (Directory.Exists(package.DestinationFolder))
              {
            string[] files = Directory.GetFiles(package.DestinationFolder, "*.tb");
            foreach (string file in files)
            {
              try
              {
            File.Delete(file);
              }
              catch (System.UnauthorizedAccessException)
              {
            // Fixes http://dev.mcneel.com/bugtrack/?q=68713
            // Unable to delete .tb file; we'll try again next time.
              }
            }
              }

              return true;
        }
コード例 #7
0
        public override bool Initialize(Package package)
        {
            PackageFileKey key = package.FindSingleFile(PackageManifestName);
              string manifest_path = package.GetFullPath(key);

              if (!LoadManifest(Path.GetDirectoryName(manifest_path)))
              {
            ReportProgress("Initialize() failed for package at " + package.PackagePath, LogLevel.Debug);
            return false;
              }

              return true;
        }
コード例 #8
0
        public override bool AfterInstall(Package package, RhinoInfo[] RhinoList, InstallerUser InstallAsUser)
        {
            string packagePath = package.PackagePath;
              m_user = InstallAsUser;
              bool bSuccess = true;

              // find newest plug-in compatible with each Rhino on the system, and then register it.
              ReportProgress("PluginPackage.Install starting for package at '" + packagePath + "'", LogLevel.Info);

              foreach (RhinoInfo rhino in RhinoList)
              {
            PluginInfo plugin_to_install = null;
            foreach (PackageFileKey plugin_key in ListRhpFiles(package))
            {
              PluginInfo plugin;
              if (!m_plugin_lookup.TryGetValue(plugin_key, out plugin))
              {
            // Rather than throwing an exception, log this warning, and continue on.
            // fixes http://dev.mcneel.com/bugtrack/?q=105121
            ReportProgress("m_plugin_list doesn't contain PluginInfo for " + plugin_key.Key, LogLevel.Warning);
            continue;
              }

              // Set the path to the RHP file based on
              // where the package says it currently lives
              plugin.PluginPath = package.GetFullPath(plugin_key);

              if (plugin.IsCompatible(rhino))
              {
            if (plugin.CompareTo(plugin_to_install) > 0)
              plugin_to_install = plugin;
              }
            }

            if (plugin_to_install == null)
              continue;

            if (!RegisterPlugin(plugin_to_install, rhino))
              bSuccess = false;
              }

              ReportProgress("PluginPackage.Install ending", LogLevel.Info);

              return bSuccess;
        }
コード例 #9
0
        public override RMA.RhiExec.Engine.PackageInstallState GetInstallState(Package package)
        {
            // See what version this package contains.
              PythonPluginInfo ppi = new PythonPluginInfo();
              if (!ppi.Initialize(package))
            throw new PackageNotCompatibleException(package.PackagePath);

              // Is this installed for All Users?
              ReportProgress("Getting InstallState for " + this.PackagePath, LogLevel.Debug);

              // Is plug-in installed for all users?
              ReportProgress("Checking install state for current user", LogLevel.Debug);
              string folder = InstallerEngine.InstallRoot(this.InstallRoot);

              // AllUsersInstallFolder returns ...\plug-in name\version
              // we want to look in just ...\plug-in name
              folder = Path.GetDirectoryName(folder);

              Version InstalledVersion = GetNewestVersionOfInstalledPackage(folder);
              return CompareVersions(this.PackageVersion, InstalledVersion);
        }
コード例 #10
0
 /// <summary>
 /// Called by the InstallerEngine to determine if this Package
 /// is currently installed on the user's system, and if the
 /// installed version is older, the same as, or newer than
 /// the one in this Package.
 /// </summary>
 public abstract PackageInstallState GetInstallState(Package package);
コード例 #11
0
 /// <summary>
 /// Called by the InstallerEngine to finalize the installation 
 /// </summary>
 /// <returns></returns>
 public virtual bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser)
 {
     return true;
 }
コード例 #12
0
ファイル: InstallerEngine.cs プロジェクト: Crae/rhiexec
        /// <summary>
        /// Init is called to initialize the package for installation.
        /// No installation is done, only inspection of the package contents.
        /// 
        /// 1) Extract .rhi package into temp folder
        /// 2) Select appropriate PackageInstaller
        /// 3) Initialize PackageInstaller
        /// 4) Determine if Package is already installed
        /// 5) Detect Rhino installations
        /// 6) Is package compatible with any Rhino installations?
        /// 7) If all above succeeds, Init succeeded.
        ///
        /// All logic for inspection and initialization should be in
        /// the Package code; not the Engine (the Engine should know
        /// nothing about installing a specific package).
        /// </summary>
        /// <param name="InstallerFilePath"></param>
        static void Init(string PackagePath)
        {
            ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "INIT START: " + m_state.InstallerFilePath);

              if (!File.Exists(PackagePath))
              {
            ReportProgress(LogLevel.Error, InstallerPhase.InitializationFailed, "Installer Package not Found: '" + PackagePath + "'");
            return;
              }

              m_package = new Package(PackagePath);
              m_state.TemporaryFolder = CreateTempFolder();
              m_package.DestinationFolder = m_state.TemporaryFolder;

              if (m_init_thread.CancellationPending) return;

              // 2) Select appropriate PackageInstaller
              ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Selecting PackageInstaller");
              for (int i=0; i<m_package_installers.Count; i++)
              {
            if (m_package_installers[i].ContainsRecognizedPayload(m_package))
            {
              m_selected_installer_index = i;
              break;
            }
              }
              if (m_init_thread.CancellationPending) return;

              // No appropriate PackageInstaller found
              if (SelectedInstaller == null)
              {
            ReportProgress(LogLevel.Info, InstallerPhase.InitializationFailed, "Initialization Failed - Appropriate Package Installer Not Found");
            return;
              }

              // 3) Initialize PackageInstaller
              ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Initializing PackageInstaller");
              SelectedInstaller.Initialize(m_package);
              if (m_init_thread.CancellationPending) return;

              // 4) Determine if Package is already installed
              PackageInstallState install_state = SelectedInstaller.GetInstallState(m_package);
              if (install_state >= PackageInstallState.SameVersionInstalledCurrentUser)
              {
            ReportProgress(LogLevel.Info, InstallerPhase.AlreadyInstalled, "Initialization Complete");
            return;
              }

              // 5) Detect Rhino installations
              ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Detecting Rhino");
              DetectInstalledRhino();
              if (m_init_thread.CancellationPending) return;

              // 6) Is package compatible with any Rhino installations?
              foreach (RhinoInfo rhino in m_state.RhinoList)
              {
            if (SelectedInstaller.IsCompatible(rhino))
            {
              ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Found Compatible Rhino");
              m_state.CompatibleRhinoIsInstalled = RhinoInstallState.Found;
              break;
            }
            if (m_init_thread.CancellationPending) return;
              }

              if (m_state.CompatibleRhinoIsInstalled == RhinoInstallState.Found)
            ReportProgress(LogLevel.Info, InstallerPhase.Initialized, "Initialization Complete");
              else
            ReportProgress(LogLevel.Info, InstallerPhase.InspctPkgNotCompatible, "Initialization Failed - This package is not compatible with any of the Rhino installations on this computer.");
        }
コード例 #13
0
 private void ReadCommandsFromPackage(Package package)
 {
     Regex rxcmd = new Regex(".*_cmd.py", RegexOptions.IgnoreCase);
       Collection<PackageFileKey> command_files = package.FindFiles(rxcmd);
       List<string> filenames = new List<string>();
       foreach (PackageFileKey key in command_files)
     filenames.Add(key.Key);
       GetCommandList(filenames);
 }
コード例 #14
0
        public bool Initialize(Package package)
        {
            if (package == null)
              {
            InstallerEngine.ReportProgress(LogLevel.Error, "PythonPluginInfo::Initialize called with null package");
            return false;
              }
              PackageFileKey plugin_py_key = package.FindSingleFile("__plugin__.py");
              string plugin_py = package.GetFullPath(plugin_py_key);
              if (plugin_py == null)
            return false;

              if (!LoadPluginPyFile(plugin_py))
            return false;

              ReadCommandsFromPackage(package);

              InstallerEngine.ReportProgress(LogLevel.Info, "PythonPluginInfo::Initialize failed");
              return this.IsValid();
        }
コード例 #15
0
        public override bool Initialize(Package package)
        {
            ClearPluginInfo();
              m_package = package;

              if (Plugin.IsValid())
              {
            ReportProgress("Package Description:\n" + Describe(), LogLevel.Info);
            return true;
              }
              else
              {
            ReportProgress("Package Description:\n" + Describe(), LogLevel.Info);
            ReportProgress("Package failed to initialize properly: " + package.PackagePath, LogLevel.Error);
            return false;
              }
        }
コード例 #16
0
        public override bool ContainsRecognizedPayload(Package package)
        {
            Collection<PackageFileKey> rhp_files = ListRhpFiles(package);
              if (rhp_files.Count > 0)
            return true;

              return false;
        }
コード例 #17
0
        public override RMA.RhiExec.Engine.PackageInstallState GetInstallState(Package package)
        {
            PackageManifest manifestInstalled = new PackageManifest(m_content_type);
              if (!LoadManifest(this.InstallFolder(InstallerEngine.InstallRoot(this.InstallRoot)), m_content_type, out manifestInstalled))
            return PackageInstallState.NotInstalled;

              PackageManifest manifestNew = new PackageManifest(m_content_type);
              if (!LoadManifest(PackagePath, m_content_type, out manifestNew))
            throw new ManifestFileNotFoundException(PackagePath);

              if (manifestInstalled.VersionNumber > manifestNew.VersionNumber)
            return PackageInstallState.NewerVersionInstalledCurrentUser;
              else if (manifestInstalled.VersionNumber == manifestNew.VersionNumber)
            return PackageInstallState.SameVersionInstalledCurrentUser;
              else if (manifestInstalled.VersionNumber < manifestNew.VersionNumber)
            return PackageInstallState.OlderVersionInstalledCurrentUser;
              else
            return PackageInstallState.NotInstalled;
        }
コード例 #18
0
        public override PackageInstallState GetInstallState(Package package)
        {
            PackageInstallState accumulated_state = PackageInstallState.NotInstalled;

              foreach (PluginInfo pii in m_plugin_lookup.Values)
              {
            pii.InstallState = GetPluginInstallState(pii);
            if (pii.InstallState > accumulated_state)
              accumulated_state = pii.InstallState;

            pii.WriteXml();
              }

              return accumulated_state;
        }
コード例 #19
0
 public override RMA.RhiExec.Engine.PackageInstallState GetInstallState(Package package)
 {
     return GetPackageInstallState(this.m_manifest.VersionNumber);
 }
コード例 #20
0
        public override bool Initialize(Package package)
        {
            m_package = package;
              // See if at least one compatible Rhino is installed.

              Guid last_plugin_id = Guid.Empty;
              Collection<PackageFileKey> rhp_files = ListRhpFiles(package);

              bool foundOneValidRhino = false;

              foreach (PackageFileKey rhp in rhp_files)
              {
            string rhp_full_path = package.GetFullPath(rhp);
            InstallerPhase rc = ExecutePluginInspector(rhp_full_path);

            if (rc != InstallerPhase.Success)
              continue;

            foundOneValidRhino = true;
            PluginInfo pii = new PluginInfo();
            pii.PluginPath = rhp_full_path;
            pii.ReadXml();
            m_plugin_lookup.Add(rhp, pii);

            if (last_plugin_id != Guid.Empty && pii.ID != last_plugin_id)
            {
              ReportProgress("Plug-in GUID mismatch: " + pii.ID + " != " + last_plugin_id, LogLevel.Error);
              throw new GuidMismatchException("All plug-ins in an installer must have the same GUID. Two different GUIDs were found.");
            }

            last_plugin_id = pii.ID;
              }

              if (!foundOneValidRhino)
              {
            ReportProgress("Plug-in inspection failed", LogLevel.Error);
            throw new PackageNotCompatibleException(package.PackagePath);
              }

              m_id = last_plugin_id;
              return true;
        }
コード例 #21
0
 /// <summary>
 /// InstallerEngine will extract the contents of .rhi file into
 /// PackageFolder and then allow each Package-derived
 /// class to inspect the directory for recognized payload.
 /// 
 /// This scan should be fast, and should work on all platforms.
 /// 
 /// For example, scanning the direcotry tree for recognized file
 /// types is probably sufficient.
 /// </summary>
 /// <param name="PackageFolder"></param>
 /// <returns>true if PackageFolder contains payload that can be installed by this Package instance.</returns>
 public abstract bool ContainsRecognizedPayload(Package package);
コード例 #22
0
 private static Collection<PackageFileKey> ListRhpFiles(Package package)
 {
     Regex rx = new Regex(".*rhp$", RegexOptions.IgnoreCase);
       Collection<PackageFileKey> files = package.FindFiles(rx);
       ReportProgress(string.Format(CultureInfo.InvariantCulture, "Found {0} plug-ins", files.Count), LogLevel.Info);
       return files;
 }
コード例 #23
0
 /// <summary>
 /// Called by the InstallerEngine to do the full initialization
 /// of the Package. This will only be called if ContainsRecognizedPayload()
 /// returned true.
 /// 
 /// All data needed by the Install() function should be computed and saved
 /// as __~~[filename]~~__.tmp files in PackageFolder.
 /// 
 /// Note that the PackageFolder is still a temporary location at this point,
 /// so no installation or registration should happen at this point.
 /// </summary>
 /// <param name="PackageFolder">Full path to the package to be initialized.</param>
 /// <returns>true if initalization succeeds; false otherwise</returns>
 public abstract bool Initialize(Package package);
コード例 #24
0
        public override bool ContainsRecognizedPayload(Package package)
        {
            if (package.ContainsFileNamed("__plugin__.py"))
              {
            ReportProgress("Recognized payload as Python plugin", LogLevel.Info);
            return true;
              }

              ReportProgress("Package not recognized as Python plugin", LogLevel.Info);
              return false;
        }