Unable to create superuser on google app engine - django

I am working on a django project and have used django nonrel to deploy on google app engine.
However when I try to create a super user using the command "manage.py remote create superuser", I get the following error,
Please let me know if anyone knows the reason for this
Username: newuser
Traceback (most recent call last):
File "C:\SVN GAE\development\legaltracker\manage.py", line 26, in <module>
execute_manager(settings)
File "C:\SVN GAE\development\legaltracker\django\core\management\__init__.py",
line 438, in execute_manager
utility.execute()
File "C:\SVN GAE\development\legaltracker\django\core\management\__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\SVN GAE\development\legaltracker\djangoappengine\management\commands\
remote.py", line 15, in run_from_argv
execute_from_command_line(argv)
File "C:\SVN GAE\development\legaltracker\django\core\management\__init__.py",
line 429, in execute_from_command_line
utility.execute()
File "C:\SVN GAE\development\legaltracker\django\core\management\__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\SVN GAE\development\legaltracker\django\core\management\base.py", lin
e 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\SVN GAE\development\legaltracker\django\core\management\base.py", lin
e 218, in execute
output = self.handle(*args, **options)
File "C:\SVN GAE\development\legaltracker\django\contrib\auth\management\comma
nds\createsuperuser.py", line 97, in handle
User.objects.get(username=username)
File "C:\SVN GAE\development\legaltracker\django\db\models\manager.py", line 1
32, in get
return self.get_query_set().get(*args, **kwargs)
File "C:\SVN GAE\development\legaltracker\django\db\models\query.py", line 336
, in get
num = len(clone)
File "C:\SVN GAE\development\legaltracker\django\db\models\query.py", line 81,
in __len__
self._result_cache = list(self.iterator())
File "C:\SVN GAE\development\legaltracker\django\db\models\query.py", line 269
, in iterator
for row in compiler.results_iter():
File "C:\SVN GAE\development\legaltracker\djangotoolbox\db\basecompiler.py", l
ine 219, in results_iter
for entity in self.build_query(fields).fetch(low_mark, high_mark):
File "C:\SVN GAE\development\legaltracker\djangoappengine\db\compiler.py", lin
e 95, in fetch
results = query.Run(**kw)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore.
py", line 1138, in Run
return self._Run(**kwargs)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore.
py", line 1167, in _Run
datastore_pb.QueryResult(), rpc)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore.
py", line 186, in _MakeSyncCall
rpc.check_success()
File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_s
tub_map.py", line 474, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_r
pc.py", line 149, in _WaitImpl
self.request, self.response)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\remote_api
\remote_api_stub.py", line 223, in MakeSyncCall
handler(request, response)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\remote_api
\remote_api_stub.py", line 232, in _Dynamic_RunQuery
'datastore_v3', 'RunQuery', query, query_result)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\remote_api
\remote_api_stub.py", line 155, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\remote_api
\remote_api_stub.py", line 167, in _MakeRealSyncCall
encoded_response = self._server.Send(self._path, encoded_request)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\appengin
e_rpc.py", line 346, in Send
f = self.opener.open(req)
File "C:\Python25\lib\urllib2.py", line 387, in open
response = meth(req, response)
File "C:\Python25\lib\urllib2.py", line 498, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python25\lib\urllib2.py", line 425, in error
return self._call_chain(*args)
File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 302: Found

Im not very familiar with django nonrel but HTTP code 302 is not really an error but indicates that the client should try under a different URL. Unfortunately the error message does not show which URL is redirected to. I see this happens on the local development server - I suggest you check the logfile of the development webserver.

Related

django-elasticsearch-dsl with AWS elasticsearch

I'm trying to use AWS ElasticBeanStalk to deploy a Django app using django-elasticsearch-dsl and I need to run ./manage.py search_index --rebuild the first time I load it. So within my container commands I've got:
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild"
The problem is it is waiting for a n/Y to the question Are you sure you want to delete the 'hjsm-local' indexes? [n/Y]:
How do I rebuild my indecies?
UPDATE
When I use
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild -f"
I get this error
Traceback (most recent call last):
File "./src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 134, in handle
self._rebuild(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 114, in _rebuild
self._create(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 84, in _create
index.create()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 102, in create
self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 110, in create
params=params, body=body)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
self._raise_error(response.status, raw_data)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: <exception str() failed>
(ElasticBeanstalk::ExternalInvocationError)
As per the source code, include the -f parameter in your command to force the acceptance of the prompt.

Using django-elasticsearch-dsl with AWS ElasticSearch - raise HTTP_EXCEPTIONS.get(status_code, TransportError)

I'm trying to convert up a Django application using django-elasticsearch-dsl and a elasticsearch server to using AWS ElasticSearch which I am deploying using ElsaticBeanStalk
When I use
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild -f"
I get this error
Creating index 'hjsm-local'
Traceback (most recent call last):
File "./src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 134, in handle
self._rebuild(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 114, in _rebuild
self._create(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 84, in _create
index.create()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 102, in create
self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 110, in create
params=params, body=body)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
self._raise_error(response.status, raw_data)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: <exception str() failed>
(ElasticBeanstalk::ExternalInvocationError)
I do not understand what this is telling me - can anyone advise?
UPDATE
I think I am getting an HTTP 406 error, but I do not understand why. If I run locally using localhost:9200 rather than my aws eleasticsearch server, it works fine.
The issue was it needed ElasticSearch 2.4. I have to setup a server with this running and when I connected through it worked!

ImportError: No module named modilabs.utils.subprocess_timeout

I use KoboToolbox and run KOBOCAT but it give the following Errors when I run manage.py.It works perfect on the port but it shows A server error occurred. Please contact the administrator. And it shows that it cannot import ProcessTimeout.
Here is the the Error log:
Traceback (most recent call last):
File "manage.py", line 21, in
execute_from_command_line(sys.argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/init.py", line 399, in execute_from_command_line
utility.execute()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/init.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/base.py", line 82, in run_from_argv
return super(CeleryCommand, self).run_from_argv(argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.dict)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/base.py", line 75, in execute
super(CeleryCommand, self).execute(*args, **options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 25, in handle
worker.run(**options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/bin/worker.py", line 212, in run
state_db=self.node_format(state_db, hostname), **kwargs
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/worker/init.py", line 95, in init
self.app.loader.init_worker()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/loaders/base.py", line 128, in init_worker
self.import_default_modules()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 141, in import_default_modules
self.autodiscover()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 144, in autodiscover
self.task_modules.update(mod.name for mod in autodiscover() or ())
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 179, in autodiscover
for app in settings.INSTALLED_APPS])
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 203, in find_related_module
return importlib.import_module('{0}.{1}'.format(app, related_name))
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/sakib/d2WebApp/kobocat/onadata/apps/viewer/tasks.py", line 14, in
from onadata.libs.utils.logger_tools import mongo_sync_status, report_exception
File "/home/sakib/d2WebApp/kobocat/onadata/libs/utils/logger_tools.py", line 28, in
from modilabs.utils.subprocess_timeout import ProcessTimedOut
ImportError: No module named modilabs.utils.subprocess_timeout

python-selenium on aws lambda throws error when switch_back_to.default_content and try to select element

python-selenium using phantomjs used to open an iFrame inside the page, then after switching back to the default content(driver.switch_to.default_content()) does not work.
The following is a pseudo code snippet to explain the scenario.
frame = WebDriverWait(driver, wait_time).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe.class_name")))
......
driver.switch_to.default_content()
print('Switched back to default content')
# Error occurs when line below is interpreted
driver.find_element_by_css_selector("div[title^='Test %s']" %(array_of_content[1]))
Following error occurs:-
Traceback (most recent call last):
File "/var/task/main.py", line 217, in test_method
driver.find_element_by_css_selector("div[title^='Test %s']" %(array_of_content[1]))
File "/var/task/selenium/webdriver/support/wait.py", line 71, in until
value = method(self._driver)
File "/var/task/selenium/webdriver/support/expected_conditions.py", line 213, in __call__
element = visibility_of_element_located(self.locator)(driver)
File "/var/task/selenium/webdriver/support/expected_conditions.py", line 78, in __call__
return _element_if_visible(_find_element(driver, self.locator))
File "/var/task/selenium/webdriver/support/expected_conditions.py", line 307, in _find_element
return driver.find_element(*by)
File "/var/task/selenium/webdriver/remote/webdriver.py", line 752, in find_element
'value': value})['value']
File "/var/task/selenium/webdriver/remote/webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
File "/var/task/selenium/webdriver/remote/remote_connection.py", line 401, in execute
return self._request(command_info[0], url, body=data)
File "/var/task/selenium/webdriver/remote/remote_connection.py", line 471, in _request
resp = opener.open(request, timeout=self._timeout)
File "/usr/lib64/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib64/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 1229, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib64/python2.7/urllib2.py", line 1202, in do_open
r = h.getresponse(buffering=True)
File "/var/task/raven/breadcrumbs.py", line 328, in getresponse
rv = real_getresponse(self, *args, **kwargs)
File "/usr/lib64/python2.7/httplib.py", line 1132, in getresponse
response.begin()
File "/usr/lib64/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.7/httplib.py", line 417, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''
Any ideas, what is happening.
As I am able to see the same error, even if I write driver.save_screenshot('test.png').
But it is not throwing any error on local machines, also tried to use AMI instance to replicate if something is there in concern Amazon Linux.

'NoneType' object is unsubscriptable during war file creation in Django-Jython

I am trying to generate a war file on my local machine, so as to deploy the Django application on the web server. I am using Django-Jython for the same purpose. I am using a MySQL database and have set the CLASSPATH variable as mentioned in the documentation. The name of my Django project is "gui" and it resides in C:\
I run the following command :
C:\gui> jython C:\gui\manage.py war --include-java-libs=C:\mysql-connector-java-5.1.16-bin.jar
And I get the following error :
Traceback (most recent call last): File "C:\gui\manage.py", line
10, in execute_from_command_line(sys.argv)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\core\management__init__.py",
line 443, in execute_from_command_line utility.execute()
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\core\management__init__.py",
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\core\management\base.py",
line 196, in run_from_argv
self.execute(*args, **options.dict)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\core\management\base.py",
line 217, in execute
translation.activate('en-us')
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\core\management\base.py",
line 217, in execute
translation.activate('en-us')
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\utils\translation__init__.py",
line 105, in activate
return _trans.activate(language)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\utils\translation\trans_real.py",
line 194, in activate
_active.value = translation(language)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\utils\translation\trans_real.py",
line 183, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File
"C:\jython2.5.3\Lib\site-packages\django-1.4.3-py2.5.egg\django\utils\translation\trans_real.py",
line 161, in _fetch
apppath = os.path.join(os.path.dirname(app.file), 'locale')
File "C:\jython2.5.3\Lib\ntpath.py", line 207, in dirname
return split(p)[0] File "C:\jython2.5.3\Lib\ntpath.py", line 164, in split
d, p = splitdrive(p) File "C:\jython2.5.3\Lib\ntpath.py", line 119, in splitdrive
if p[1:2] == ':': TypeError: 'NoneType' object is unsubscriptable