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

Header Structure not working as intended (invalid URL for file) #43

Closed
LorenzNickel opened this issue Aug 15, 2021 · 7 comments
Closed
Labels

Comments

@LorenzNickel
Copy link

Hey,

if I try to open the "Header Structure", the WebView does not open the file properly. It tries to open file://c/Users/Lorenz/AppData/Local/Temp/Sherloq-mcAXVc%5Cstructure.html when instead file:///C:/Users/Lorenz/AppData/Local/Temp/Sherloq-mcAXVc/structure.html should be opened.

image

I'm running the most recent version of sherloq on a Windows Machine.

@GuidoBartoli
Copy link
Owner

Mmmh I admit I tested Header Structure only under Linux, this is clearly a Windows issue. I know how to fix this, already, just give me some days until I come back from holidays and I will notify you.

Thanks for this report.

@TechiBBB
Copy link

Hello,
I recently cloned Sherloq and ran into the same issue when trying on Windows (Windows10, Python 3.10.4).
Actually there were 3 issues:

  1. the exiftool_exe call in utility.py was not optimal and asked for a "Press Enter" event in stdout
  2. there was a broken escape sequence in the path to the structure.html file
  3. the QWebEngineView usage was not loading the structure.html file because of the 'file://' prefix

I fixed the bugs on my side like that:

  1. Rename /pyexiftool/exiftool/win/exiftool(-k).exe to /pyexiftool/exiftool/win/exiftool.exe and modify the exiftool call accordingly in function exiftool.exe() (utility.py). The "Press Enter" request will be gone.
  2. Fix the broken escape sequence in init function from class HeaderWidget (header.py)
  3. Load the structure.html file without the "file://" prefix

This is my fixed code in script header.py:

`
class HeaderWidget(ToolWidget):

def __init__(self, filename, parent=None):
    super(HeaderWidget, self).__init__(parent)
    self.temp_dir = QTemporaryDir()
    if self.temp_dir.isValid():
        temp_file = os.path.join(self.temp_dir.path(), "structure.html")

        p = run([exiftool_exe(), "-htmldump0", filename], stdout=PIPE)
        with open(temp_file, "w") as file:
            file.write(p.stdout.decode("utf-8"))

        web_view = QWebEngineView()
        if sys.platform.startswith("win32"):
            temp_file = self.temp_dir.path() + "//" + "structure.html"      # fixes the broken ESC sequence
            web_view.load(QUrl(temp_file))                                  # load without 'file://' prefix
        else:
            web_view.load(QUrl("file://" + temp_file))

        layout = QVBoxLayout()
        layout.addWidget(web_view)
        self.setLayout(layout)
        self.setMinimumWidth(900)`

Now everthing works as expected without any delay (only Windows, no Linux verification!):
windows_fix

@GuidoBartoli
Copy link
Owner

Many thanks @TechiBBB, tonight I will commit your fix! 👍🏻

GuidoBartoli added a commit that referenced this issue Apr 28, 2022
- Added libraries links in About dialog
- Version bump from alpha to beta
@GuidoBartoli
Copy link
Owner

Does the commit f437b9c fix the bug on Windows?

1 similar comment
@GuidoBartoli
Copy link
Owner

Does the commit f437b9c fix the bug on Windows?

@LorenzNickel
Copy link
Author

Yes, the issue seems to be fixed.
image

The "Press Enter"-issue mentioned by @TechiBBB still remains, but I think it's tracked separately in #22.

However, applying what @TechiBBB wrote also worked for me to resolve #22 here, maybe you could consider doing that somehow:

Rename /pyexiftool/exiftool/win/exiftool(-k).exe to /pyexiftool/exiftool/win/exiftool.exe and modify the exiftool call accordingly in function exiftool.exe() (utility.py). The "Press Enter" request will be gone.

@TechiBBB
Copy link

I can confirm the fix in header.py from my side as well.
Regarding the annoing "Press ENTER" issue, I don't see a possibility to fix that from the source code. It seems to be a by design problem in the precompiled exiftool executable. A solution could be to switch to another exif analysis tool, e.g. this one: https://github.com/ianare/exif-py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants