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

Create script commands for flask ( updated ) #203

Closed
wants to merge 1 commit into from
Closed

Create script commands for flask ( updated ) #203

wants to merge 1 commit into from

Conversation

LordGameleo
Copy link
Contributor

Reference to old PR : 196

Description

Added a python script manage.py which can be used to do perform multiple commands using arguments given while running it.

Fixes #78

Type of Change:

  • Code
  • Quality Assurance
  • User Interface
  • Outreach

Code/Quality Assurance Only

  • This change requires a documentation update (software upgrade on readme file)
  • It adds easy access to make superuser (first user admin), running server, testing whole app or specific parts all through command-line.

How Has This Been Tested?

'''python -m unittest dicover tests'''

  • Tested it by using these features manually

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Code/Quality Assurance Only

  • My changes generate no new warnings
  • Existing unit tests pass locally with my changes

@LordGameleo
Copy link
Contributor Author

@isabelcosta Please Review.

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

Thank you so much @LordGameleo for your contribution!
I haven't got the chance to test this locally yet, but once I get the chance, I'll give you a proper review.

Copy link
Contributor

@ramitsawhney27 ramitsawhney27 left a comment

Choose a reason for hiding this comment

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

Environments variables are a must, not user based input, in automatic deployment, in any case.

@LordGameleo
Copy link
Contributor Author

I will do it then.

@LordGameleo
Copy link
Contributor Author

LordGameleo commented Mar 23, 2019

@ramitsawhney27 @isabelcosta please review

@isabelcosta
Copy link
Member

@LordGameleo this is not forgotten, I just have been a bit busy these days. When I get some time to take a look at this I'll review it again

@LordGameleo
Copy link
Contributor Author

@isabelcosta Is there any progress here?

@isabelcosta
Copy link
Member

@LordGameleo Not yet on my end :/ I'll try to take a look at this by next week. But from what I've seen you've made the changes requested. I just need to run this and test it. thank you for your patience

@isabelcosta
Copy link
Member

@LordGameleo I'm sorry for the delay in my test & review of your work! I really appreciate the time you devoted to solve this issue.

I got the chance to run your PR and got the following error:

root@3c91c530faf2:/dockerBuild# python manage.py createsuperuser
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/_collections.py", line 999, in __call__
    return self.registry[key]
KeyError: 140693765838656

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 102, in <module>
    build(sys.argv)
  File "manage.py", line 37, in build
    create_superuser()
  File "manage.py", line 76, in create_superuser
    if UserModel.is_empty():
  File "/dockerBuild/app/database/models/user.py", line 138, in is_empty
    return cls.query.first() is None
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 514, in __get__
    return type.query_class(mapper, session=self.sa.session())
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 74, in __call__
    return self.registry()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/_collections.py", line 1001, in __call__
    return self.registry.setdefault(key, self.createfunc())
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2950, in __call__
    return self.class_(**local_kw)
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 143, in __init__
    bind = options.pop('bind', None) or db.engine
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 877, in engine
    return self.get_engine()
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 896, in get_engine
    return connector.get_engine()
  File "/usr/local/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 559, in get_engine
    self._engine = rv = sqlalchemy.create_engine(info, **options)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py", line 424, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 57, in create
    entrypoint = u._get_entrypoint()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/url.py", line 156, in _get_entrypoint
    cls = registry.load(name)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 221, in load
    (self.group, name))
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:None
root@3c91c530faf2:/dockerBuild# ^C

This can be because the db was not created yet as it is on run.py file

@LordGameleo are you still interested in working on this? if yes, let me know what you think about this, if you rather leave this for another contributor, let me know and I can re assign this to other contributor :)

@isabelcosta
Copy link
Member

I will close this issue as this has no updates. Thank you @LordGameleo for all of your contributions here!

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.

Create script commands for flask
4 participants