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

fix template directory doesn't copy into lib add added main #52

Closed
wants to merge 2 commits into from

Conversation

00Kai0
Copy link
Contributor

@00Kai0 00Kai0 commented Feb 11, 2019

Hi @leportella . This question is when normal installed, the template directory and common-credentials.txt don't copy into python's site-packages because pip install will not copy static files if you don't declare correctly into setup.py. I think this can help you. Thinks.

@00Kai0
Copy link
Contributor Author

00Kai0 commented Feb 12, 2019

@leportella Here is the problem after run pip install . and set auth into config file.

    HTTPServerRequest(protocol='http', host='localhost:8000', method='GET', uri='/hub/signup', version='HTTP/1.1', remote_ip='::ffff:127.0.0.1')
    Traceback (most recent call last):
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/tornado/web.py", line 1592, in _execute
        result = yield result
      File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
        raise self._exception
      File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
        result = coro.send(None)
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/nativeauthenticator/handlers.py", line 35, in get
        ask_email=self.authenticator.ask_email_on_signup,
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jupyterhub/handlers/base.py", line 582, in render_template
        template = self.get_template(name)
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jupyterhub/handlers/base.py", line 578, in get_template
        return self.settings['jinja2_env'].get_template(name)
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jinja2/environment.py", line 830, in get_template
        return self._load_template(name, self.make_globals(globals))
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jinja2/environment.py", line 804, in _load_template
        template = self.loader.load(self, name, globals)
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jinja2/loaders.py", line 408, in load
        raise TemplateNotFound(name)
    jinja2.exceptions.TemplateNotFound: signup.html

@00Kai0 00Kai0 force-pushed the fix_template_install branch 3 times, most recently from 8f284e9 to b1f3fb7 Compare February 12, 2019 07:11
1. allow empty email
2. fix password typeerror
3. add length on dialect to support mysql
@00Kai0
Copy link
Contributor Author

00Kai0 commented Feb 12, 2019

Hi @leportella. When I use this authenticator I find some error

 Traceback (most recent call last):
  File "/home/kai/work/embark3_env/nativeauthenticator/nativeauthenticator/nativeauthenticator.py", line 156, in get_or_create_user
    user_info = UserInfo(**infos)
  File "<string>", line 4, in __init__
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/state.py", line 424, in _initialize_instance
    manager.dispatch.init_failure(self, args, kwargs)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
    raise value
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/state.py", line 421, in _initialize_instance
    return manager.original_init(*mixed[1:], **kwargs)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/ext/declarative/base.py", line 748, in _declarative_constructor
    setattr(self, k, kwargs[k])
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/attributes.py", line 229, in __set__
    instance_dict(instance), value, None)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/attributes.py", line 710, in set
    value, old, initiator)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/attributes.py", line 717, in fire_replace_event
    state, value, previous, initiator or self._replace_token)
  File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/sqlalchemy/orm/util.py", line 136, in set_
    return validator(state.obj(), key, value)
  File "/home/kai/work/embark3_env/nativeauthenticator/nativeauthenticator/orm.py", line 40, in validate_email
    address)
AssertionError




 HTTPServerRequest(protocol='http', host='localhost:8000', method='POST', uri='/hub/login?next=', version='HTTP/1.1', remote_ip='::ffff:127.0.0.1')
    Traceback (most recent call last):
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/tornado/web.py", line 1592, in _execute
        result = yield result
      File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
        raise self._exception
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jupyterhub/handlers/login.py", line 82, in post
        user = yield self.login_user(data)
      File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
        raise self._exception
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jupyterhub/handlers/base.py", line 327, in login_user
        authenticated = yield self.authenticate(data)
      File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
        raise self._exception
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/jupyterhub/auth.py", line 221, in get_authenticated_user
        authenticated = yield self.authenticate(handler, data)
      File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
        raise self._exception
      File "/home/kai/work/embark3_env/venv/lib/python3.5/types.py", line 243, in wrapped
        coro = func(*args, **kwargs)
      File "/home/kai/work/embark3_env/nativeauthenticator/nativeauthenticator/nativeauthenticator.py", line 114, in authenticate
        if user.is_authorized and user.is_valid_password(password):
      File "/home/kai/work/embark3_env/nativeauthenticator/nativeauthenticator/orm.py", line 26, in is_valid_password
        encoded_pw = bcrypt.hashpw(password.encode(), self.password)
      File "/home/kai/work/embark3_env/venv/lib/python3.5/site-packages/bcrypt/__init__.py", line 61, in hashpw
        raise TypeError("Unicode-objects must be encoded before hashing")
    TypeError: Unicode-objects must be encoded before hashing


sqlalchemy.exc.CompileError: (in table 'users_info', column 'username'): VARCHAR requires a length on dialect mysql

I think this error is due to use mysql (I use mysql to replace sqlite). String in mysql can not be bytes so I make some change to support mysql.
And validate email will return error if email is None, so I change to reutrn None if email is None.

@leportella
Copy link
Collaborator

Hi @00Kai0 ! Thank you for contributing!
I think we have different issues being solved here and the best approach would be to break them in multiple smaller pull requests. As I saw the fixes here were:

  • Package problems on installation;
  • Fix if password is valid when password is already encoded;
  • Fix validation of email for empty case;
  • Adding a main function on setup.py;

About these...

  • The problem with files I think was solved on PR Fix data packaging on setup.py #53 (tests here worked);
  • The items of password and email problem should be in separate pull requests and need tests;
  • Why there is a need for the main function on setup.py? Many packages I see don't use this (such as FirstUseAuthenticator)

@00Kai0
Copy link
Contributor Author

00Kai0 commented Feb 12, 2019

Hi @leportella . I am happy for your response.
I saw the first question has been sorted.
The second question, I will break them into diffrent PRs.
Third, This is unnecessary. I think this just a code style in python that makes code looks clearly. I see it use in jupyterhub and jupyter notebook

@leportella
Copy link
Collaborator

I am closing this since we have new pull requests to handle this :)

@leportella leportella closed this Feb 13, 2019
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

Successfully merging this pull request may close these issues.

2 participants