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

Windows support for Lydia docker #60

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@ sudo chmod u+x lydia
sudo mv lydia /usr/local/bin/
```


This will install an alias to the inline Docker image execution
in your system PATH. Instead of `/usr/local/bin/`
you may use another path which is still in the `PATH` variable.

On Windows, make a `.bat` file:
```
docker run --name lydia -v"%cd%":/home/default whitemech/lydia lydia %*
```
And add it to your PATH variables.d
gallorob marked this conversation as resolved.
Show resolved Hide resolved


## Quickstart

Now you are ready to go:
Expand Down
2 changes: 1 addition & 1 deletion logaut/backends/lydia/_lydia_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

def call_lydia(*args) -> str:
"""Call the Lydia CLI tool with the arguments provided."""
command = ["lydia", *args]
command = ["lydia" if sys.platform == "win32" else "lydia.bat", *args]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to avoid the .bat extension on Windows, and still make the script foundable by the OS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would simplify the code as it would not need the if condition.

Copy link
Member

@marcofavorito marcofavorito Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, sys not imported! Please address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the sys import and corrected the check.
Regarding the file extension, Windows executes by default .bats, .coms and .exes. These extension are in the PATHEXT environment variable. The proposed solution requires the least configuration by the user and introduces just one if condition, which I believe is a good tradeoff.

Copy link
Member

@marcofavorito marcofavorito Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Thanks!

try:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = result.stdout.decode()
Expand Down