Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: pyRevit CLI Doesn't look for 100% match in extension names when parsing #2367

Closed
5 tasks done
TPJW opened this issue Aug 20, 2024 · 6 comments
Closed
5 tasks done
Labels
Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class] Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem]

Comments

@TPJW
Copy link

TPJW commented Aug 20, 2024

✈ Pre-Flight checks

  • I don't have SentinelOne antivirus installed (see above for the solution)
  • I have searched in the issues (open and closed) but couldn't find a similar issue
  • I have searched in the pyRevit Forum for similar issues
  • I already followed the installation troubleshooting guide thoroughly
  • I am using the latest pyRevit Version

🐞 Describe the bug

When I go to perform extenion-centreic commands in the pyRevit CLI, I notice (when using the --debug suffix) that the CLI is not looking for a 100% match in name when parsing though extensions.

I have create a suite of extensions for the firm I work for, with one general extension for all Revit users, and two other, discipline specific, ones. They are named:

  • TPpyRevitTools
  • TPpyRevitToolsARCH
  • TPpyRevitToolsELEC

I've noticed when using the CLI, for example the command pyrevit extensions info TPpyRevitTools --debug, that the CLI does not look for a 100% match in the name in the extension, resulting the first extension (TPpyRevitTools) matching with all three.

This appears to be causing issues elsewhere, like calling pyrevit extensions will pull the right extension type for the disciple specific extensions, but not the general one (sample output below)

⌨ Error/Debug Message

Below is the output when running the above-mentioned command in the CLI, where the fault is shown at the end when it matches TPpyRevitTools with the two other discipline-specific extensions as well

>>> pyrevit extensions info TPpyRevitTools --debug
info = True
<extension_name> = TPpyRevitTools
extensions = True
Debug: Checking for all: wiki
Debug: Missing: wiki
Debug: Checking for all: blog
Debug: Missing: blog
Debug: Checking for all: docs
Debug: Missing: docs
Debug: Checking for all: source
Debug: Missing: source
Debug: Checking for all: youtube
Debug: Missing: youtube
Debug: Checking for all: support
Debug: Missing: support
Debug: Checking for all: env
Debug: Missing: env
Debug: Checking for all: update
Debug: Missing: update
Debug: Checking for all: clone
Debug: Missing: clone
Debug: Checking for all: clones
Debug: Missing: clones
Debug: Checking for all: attach
Debug: Missing: attach
Debug: Checking for all: detach
Debug: Missing: detach
Debug: Checking for all: attached
Debug: Missing: attached
Debug: Checking for all: switch
Debug: Missing: switch
Debug: Checking for all: extend
Debug: Missing: extend
Debug: Checking for all: extensions
Debug: Checking for all: search
Debug: Missing: search
Debug: Checking for any: info,help
Debug: Matching: info
Debug: Looking up registered extension "TPpyRevitTools"...
Debug: Determining file or remote source "https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json"
Debug: Source is a remote resource "https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json"
Debug: Downloading remote resource "https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json"...
Debug: Downloading "https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json"
Debug: Parsing extension metadata file...
Debug: Registered extension "PyRevitPlus"
Debug: Registered extension "PyRevitMEP"
Debug: Registered extension "pyApex"
Debug: Registered extension "Revitron"
Debug: Registered extension "Revitron UI"
Debug: Registered extension "pyStructure"
Debug: Registered extension "MEPDesign"
Debug: Registered extension "pyTiBa"
Debug: Registered extension "EF-Tools"
Debug: Registered extension "pyChilizer"
Debug: Registered extension "pySSG"
Debug: Registered extension "pyArchitect"
Debug: Try getting config as list "environment:sources"
Debug: Try getting config "environment:sources"
Debug: Config "environment:sources" = "["C:\\pyRevit\\Extensions\\extensions.json"]"
Debug: Normalizing "C:\pyRevit\Extensions\extensions.json"
Debug: Normalized as "C:\pyRevit\Extensions\extensions.json"
Debug: Extension lookup source "C:\pyRevit\Extensions\extensions.json"
Debug: Updating config "environment:sources = ["C:\\pyRevit\\Extensions\\extensions.json"]"
Debug: Saving config file "C:\Users\TPJW\AppData\Roaming\pyRevit\pyRevit_config.ini"
Debug: Determining file or remote source "C:\pyRevit\Extensions\extensions.json"
Debug: Source is a file "C:\pyRevit\Extensions\extensions.json"
Debug: Parsing extension metadata file...
Debug: Registered extension "TPpyRevitTools"
Debug: "TPpyRevitTools" Matched registered extension "TPpyRevitTools"
Debug: Registered extension "TPpyRevitToolsARCH"
Debug: "TPpyRevitTools" Matched registered extension "TPpyRevitToolsARCH"
Debug: Registered extension "TPpyRevitToolsELEC"
Debug: "TPpyRevitTools" Matched registered extension "TPpyRevitToolsELEC"

And below is the output when calling pyrevit extensions, alongside the extensions.json file

TPpyRevitTools | Type: Unknown | Repo: "https://github.com/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitTools.extension"
TPpyRevitToolsARCH | Type: UIExtension | Repo: "https://github.com/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitToolsARCH.extension"
TPpyRevitToolsELEC | Type: UIExtension | Repo: "https://github.com/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitToolsELEC.extension"
P

and here's the associated extensions.json

{
    "extensions": [
        {
            "builtin": "False",
            "type": "extension",
            "rocket_mode_compatible": "False",
            "name": "TPpyRevitTools",
            "description": "General pyRevit Tools",
            "author": "TPJW",
            "author_profile": "",
            "url": "",
            "website": "",
            "image": "",
            "dependencies": []
        },
        {
            "builtin": "False",
            "type": "extension",
            "rocket_mode_compatible": "False",
            "name": "TPpyRevitToolsARCH",
            "description": "Architectural pyRevit Tools",
            "author": "TPJW",
            "author_profile": "",
            "url": "",
            "website": "",
            "image": "",
            "dependencies": []
        },
        {
            "builtin": "False",
            "type": "extension",
            "rocket_mode_compatible": "False",
            "name": "TPpyRevitToolsELEC",
            "description": "Electrical pyRevit Tools",
            "author": "TPJW",
            "author_profile": "",
            "url": "",
            "website": "",
            "image": "",
            "dependencies": []
        }
    ]
}

♻️ To Reproduce

  1. Create an extension
  2. Create additional extensions, each with the same name as the one created in step (1), however each having a unique suffix.
  3. Create an extensions.json file, fill out with the necessary information & add it to extension sources.
  4. Load in extension in pyRevit
  5. Use pyRevit CLI's extensions commands (i.e. info, enable/disable) and see if they work properly for the extension created in step (1)

⏲️ Expected behavior

When parsing though extensions, pyRevit CLI should only register a 100% match and not register if the target name is contained in the name being checked.

🖥️ Hardware and Software Setup (please complete the following information)

==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
main | Deploy: "basepublic" | Branch: "master" | Version: "4.8.16" | Path: "C:\pyRevit\main"
==> Attachments
main | Product: "Autodesk Revit 2023" | Engine: DEFAULT (2711) | Path: "C:\pyRevit\main" | AllUsers
main | Product: "Autodesk Revit 2022" | Engine: DEFAULT (2711) | Path: "C:\pyRevit\main" | AllUsers
main | Product: "2021.1.7" | Engine: DEFAULT (2711) | Path: "C:\pyRevit\main" | AllUsers
main | Product: "2020.2.9" | Engine: DEFAULT (2711) | Path: "C:\pyRevit\main" | AllUsers
==> Installed Extensions
TPpyRevitTools | Type: Unknown | Repo: "https://github.com/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitTools.extension"
TPpyRevitToolsARCH | Type: UIExtension | Repo: "https://github.com/TowerPinkster/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitToolsARCH.extension"
TPpyRevitToolsELEC | Type: UIExtension | Repo: "https://github.com/TowerPinkster/xxx" | Installed: "C:\pyRevit\Extensions\TPpyRevitToolsELEC.extension"
==> Default Extension Search Path
C:\Users\TPJW\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
C:\pyRevit\Extensions
==> Extension Sources - Default
https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
C:\pyRevit\Extensions\extensions.json
==> Installed Revits
Autodesk Revit 2023 | Version: 23.1.50.23 | Build: 20240709_1030(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2023\"
Autodesk Revit 2022 | Version: 22.1.70.9 | Build: 20240704_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2022\"
2021.1.7 | Version: 21.1.70.21 | Build: 20220517_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021\"
2020.2.9 | Version: 20.2.90.12 | Build: 20220517_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020\"
==> Running Revit Instances
Error: Object reference not set to an instance of an object.
Run with "--debug" option to see debug messages

Additional context

Side note/Question: should we still be needing the extensions.json file? I though the bundle.yaml in each of the extensions root was supposed to take care of holding information for each extension to be displayed when running pyrevit extensions as well as in the extension page on the pyRevit toolbar.

@TPJW TPJW added the Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class] label Aug 20, 2024
@jmcouffin jmcouffin added the Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem] label Aug 20, 2024
@sanzoghenzo
Copy link
Contributor

This is by design, since the pyrevit extension info uses regex search:

private static bool CompareExtensionNames(string extName, string searchTerm) {
var extMatcher = new Regex(searchTerm,
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
return extMatcher.IsMatch(extName);
}

To perform an exact search, you should use pyrevit extension info ^TPpyRevitTools$

@TPJW
Copy link
Author

TPJW commented Aug 20, 2024

Huh, well that answers that. Would it be fair to say then that the regex search is why pyrevit extensions info isn't able to pull the
extension type for just TPpyRevitTools?

@sanzoghenzo
Copy link
Contributor

Side note/Question: should we still be needing the extensions.json file?

To my knowledge, this is the main entrypoint for extensions to be discovered (and IIRC for the extensions window to be properly populated), so yes, we still need it.

@sanzoghenzo
Copy link
Contributor

Huh, well that answers that. Would it be fair to say then that the regex search is why pyrevit extensions info isn't able to pull the extension type for just TPpyRevitTools?

have you tried to do the exact match search as stated in my first answer, using the ^ prefix ans $ suffix?

@sanzoghenzo
Copy link
Contributor

FYI, this is the regular expression explained, in which you can see the exact match working https://regex101.com/r/MW4qfM/1

@TPJW
Copy link
Author

TPJW commented Aug 20, 2024

Huh, well that answers that. Would it be fair to say then that the regex search is why pyrevit extensions info isn't able to pull the extension type for just TPpyRevitTools?

have you tried to do the exact match search as stated in my first answer, using the ^ prefix ans $ suffix?

Yep, just ran it and it found it fine

>>>PS C:\Users\TPJW> pyrevit extensions info TPpyRevitTools
>>>PS C:\Users\TPJW> pyrevit extensions info ^TPpyRevitTools$
Name: "TPpyRevitTools" | Type: "UIExtension" | Repo: "https://github.com/xxx"

The reason I had brought that up was me wondering if it may be causing adverse effects for other functions/implementations where I can't pass it the name with regex, like in the extensions window, but at a glance it seems to get the details just fine. If something comes up I'll reopen the issue, but consider it all good for now. Thanks!
image

@TPJW TPJW closed this as completed Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class] Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem]
Projects
None yet
Development

No branches or pull requests

3 participants