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

Adaptation for windows (fork) #381

Closed
scwall opened this issue Nov 4, 2020 · 7 comments
Closed

Adaptation for windows (fork) #381

scwall opened this issue Nov 4, 2020 · 7 comments

Comments

@scwall
Copy link

scwall commented Nov 4, 2020

Hello,
Currently working on openedx for deployment for a clients, the project has been deployed by my "project manager" on the server for different universities with the help of tutor.
Working on windows I couldn't use tutor in the current state. I created a fork and made some adaptations to make it work on windows.
I don't know if I used the most adequate methods to modify the project (I'm a junior dev :) ). I wanted to share my fork with you if you are interested in adding it to the initial project.

https://github.com/scwall/tutor

Thank's you in advance

@regisb
Copy link
Contributor

regisb commented Nov 7, 2020

@scwall Thanks for this! This is tremendously useful. Not bad for a "junior dev" ;)

I am planning on backporting your changes to Tutor. I just need a few clarifications:

  • What is the value os.getuid() and getpass.getuser() on Windows? What is the output of id -u?
  • The pcrypt library does not seem to be very actively maintained, and I'm not keen on introducing yet another dependency. Especially as we already have pycryptodome bundled with Tutor. Can you please confirm that the following piece of code works on Windows:
from Crypto.Protocol.KDF import bcrypt, bcrypt_check
text = "passw0rd"
bcrypt(text.encode(), 12).decode()
# Correct password
bcrypt_check(text.encode(), encrypted.encode())
print("correct")
# Incorrect password
try:
    bcrypt_check("incorrect".encode(), encrypted.encode())
except ValueError:
    print("incorrect")

EDIT: for future reference, here are the commits that should be backported to tutor:

regisb added a commit that referenced this issue Nov 11, 2020
This is more portable, as described here:
#381
regisb added a commit that referenced this issue Nov 11, 2020
regisb added a commit that referenced this issue Nov 11, 2020
This should make tutor portable on Windows. Well, if the `id -u` command
is supported at least...

See: #381
@scwall
Copy link
Author

scwall commented Nov 12, 2020

Hello sorry for the response time I had to switch to another project and I wasn't available :). I was running the tests now but I see this has already been done, I'll try to be more reactive next time. @regisb

@regisb
Copy link
Contributor

regisb commented Nov 12, 2020

No worries. Can you confirm that the newest release works for Windows?
If yes, it would be truly awesome if you could contribute some docs on how to get Tutor to work on Windows.

@scwall
Copy link
Author

scwall commented Nov 12, 2020

Pas de soucis. Pouvez-vous confirmer que la version la plus récente fonctionne pour Windows?
Si oui, ce serait vraiment génial si vous pouviez contribuer quelques documents sur la façon d’obtenir Tutor de travailler sur Windows.

No worries I look at it immediately I post quickly

@scwall
Copy link
Author

scwall commented Nov 12, 2020

Error in windows os.getuid() not available in windows 10

return os.getuid()
AttributeError: module 'os' has no attribute 'getuid'

And for install setup for develop

Traceback (most recent call last):
  File "C:\Scripts\tutor-script.py", line 10, in <module>
    from importlib.metadata import distribution
ModuleNotFoundError: No module named 'importlib.metadata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Scripts\tutor-script.py", line 13, in <module>
    from importlib_metadata import distribution
ModuleNotFoundError: No module named 'importlib_metadata'

During handling of the above exception, another exception occurred:

pkg_resources.DistributionNotFound: The 'requests' distribution was not found and is required by kubernetes
(venv) PS C:\Python\tutor-original> python setup.py develop

I look at the end of the day if it is necessary to make tests with some small corrections that I can make, I had also proceeded to a change on windows which obliges to force the writing of the file in UTF8 in tutor/env.py but otherwise he tries to write it in the rotten windows charsets 😝

if platform == "win32":
     with open(path, open_mode,encoding='utf8') as of:
         of.write(content)
 else:
     with open(path, open_mode) as of:
         of.write(content)

@regisb

@scwall
Copy link
Author

scwall commented Nov 13, 2020

@regisb
I posted a pull requests with the modifications for this one to work under windows 10,

the user doesn't matter under windows 10 I just sent back the win32 information if needed otherwise it's enough to retrieve the user with the other command sent, the use of the command you had put for windows sends an error

#385

it will just be necessary to add the hostnames in the hosts file of windows manually :
C:WINDOWS/system32/drivers/etc/hosts
and added :
127.0.0.1 local.overhang.io # tutor
127.0.0.1 studio.local.overhang.io # tutor
I found the bookstore :
https://github.com/qszhuan/hostsman
That allows easy addition of hostname in the configuration files I can look at to set it up, but it requires a raise of the console as administrator, I can look at how to recover under python if the console is as administrator or not

@regisb
Copy link
Contributor

regisb commented Nov 30, 2020

I guess I can close this?

@regisb regisb closed this as completed Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants