Try, Except: sqlite3.OperationalError: no such table: - sqlite

I'm having some problems with my flask application which I never had before until today and I haven't changed anything so it's quite confusing
So it my app.py
#app.route('/view.html')
def data():
try:
path = 'app/database.db'
con = sqlite3.connect(path)
cur = con.cursor()
con.row_factory = sqlite3.Row
rows = cur.execute("select * from table").fetchall()
return render_template('layouts/default.html',
content=render_template('pages/view.html',
rows=rows))
except sqlite3.OperationalError:
return render_template('layouts/default.html',
content=render_template('pages/view.html'))
The idea is that if there is no table in the database yet, it will catch the error and just return the view.html with no data but for some reason it does not work anymore
Just realised I completely forgot to add the error, my bad
[2020-02-22 23:56:26,209] ERROR in app: Exception on /favicon.ico [GET]
Traceback (most recent call last):
File " -directory- ", line 316, in index
rows = cur.execute("select * from table")
sqlite3.OperationalError: no such table: table
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File " -directory- /app/views.py", line 337, in index
content=render_template('pages/' + path))
File "/opt/anaconda3/lib/python3.7/site-packages/flask/templating.py", line 138, in render_template
ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "/opt/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 869, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/opt/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "/opt/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/opt/anaconda3/lib/python3.7/site-packages/jinja2/loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/templating.py", line 60, in get_source
return self._get_source_fast(environment, template)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/templating.py", line 89, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: pages/favicon.ico
And just to note, the app runs fine on localhost, it just shows error now when it never did before

Related

Unable to load function install_tensorflow() in r

Hi I have encountered such problem when loading the function install_tensorflow() in r.
I don't know what to do with this error. Any help will be greatly appreciated!
Below is the error message
ERROR: Exception:
Traceback (most recent call last):
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: 'tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
yield
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/http/client.py", line 461, in read
n = self.readinto(b)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/http/client.py", line 505, in readinto
n = self.fp.readinto(b)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/ssl.py", line 1071, in recv_into
return self.read(nbytes, buffer)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/ssl.py", line 929, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 189, in _main
status = self.run(options, args)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 178, in wrapper
return func(self, options, args)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 317, in run
reqs, check_supported_wheels=not options.target_dir
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 122, in resolve
requirements, max_rounds=try_to_avoid_resolution_too_deep,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 82, in from_requirement
if not cands:
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/resolvelib/structs.py", line 124, in bool
return bool(self._sequence)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in bool
return any(self)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 38, in _iter_built
candidate = func()
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 169, in _make_candidate_from_link
name=name, version=version,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 306, in init
version=version,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 144, in init
self.dist = self._prepare()
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 226, in _prepare
dist = self._prepare_distribution()
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 312, in _prepare_distribution
self._ireq, parallel_builds=True,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 457, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 482, in _prepare_linked_requirement
self.download_dir, hashes,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 234, in unpack_url
hashes=hashes,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 108, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/network/download.py", line 163, in call
for chunk in chunks:
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/cli/progress_bars.py", line 159, in iter
for x in it:
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_internal/network/utils.py", line 88, in response_chunks
decode_content=False,
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "/Users/alexsong/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
Error: Error installing package(s): 'tensorflow==2.4'

table graphite.account_profile does not exist

I have installed Graphite on Ubuntu 18.04 using apt-get
I have also installed MySQL, created a database as well as a user in it
I have run graphite-manage migrate auth to migrate the database models
But I get this error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/graphite/composer/views.py", line 35, in composer
profile = getProfile(request)
File "/usr/lib/python2.7/dist-packages/graphite/user_util.py", line 25, in getProfile
return default_profile()
File "/usr/lib/python2.7/dist-packages/graphite/user_util.py", line 44, in default_profile
profile, created = Profile.objects.get_or_create(user=user)
File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 464, in get_or_create
return self.get(**lookup), False
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 374, in get
num = len(clone)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 232, in len
self._fetch_all()
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 53, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
ProgrammingError: (1146, u"Table 'graphite.account_profile' doesn't exist")
Just execute:
graphite-manage migrate --run-syncdb
And graphite-migrate will create account_profile and other tables for you.

How do you use exclude in salt

I'm trying to use the following block in a salt state
exclude:
- id: nopesir
But this is generating the following stack trace.
Traceback (most recent call last):
File "/bin/salt-call", line 11, in <module> salt_call()
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 400, in salt_call
client.run()
File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run
caller.run()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 212, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 749, in apply_
return highstate(**kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 1055, in highstate
orchestration_jid=orchestration_jid)
File "/usr/lib/python2.7/site-packages/salt/state.py", line 3881, in call_highstate
return self.state.call_high(high, orchestration_jid)
File "/usr/lib/python2.7/site-packages/salt/state.py", line 2693, in call_high
high, req_in_errors = self.requisite_in(high)
File "/usr/lib/python2.7/site-packages/salt/state.py", line 1560, in requisite_in
if not state.startswith('__')]:
AttributeError: 'OrderedDict' object has no attribute 'startswith'
I'm trying to follow the example from the documentation but I must be overlooking something.
I'm using version 2018.3.0.

Newrelic plugin nginx-nr-agent not working

I am using Newrelic's nginx-nr-agent but suddenly it crashed giving out the following error and not starting back.
2016-04-12 07:51:07,021 nginx-nr-agent [ERROR]: EXCEPTION: Traceback (most recent call last):
File "/usr/bin/nginx-nr-agent.py", line 431, in newrelic_push
u = urlopen(r, data=json.dumps(payload))
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 401, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 419, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1219, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1034, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 407, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
line = self.fp.readline()
File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
File "/usr/lib/python2.7/ssl.py", line 241, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 160, in read
return self._sslobj.read(len)
File "/usr/lib/pymodules/python2.7/daemon/daemon.py", line 399, in terminate
raise exception
SystemExit: Terminating on signal 15
Any help please?
I got two solution for this from here, one is to remove the pid file /var/run/nginx-nr-agent/nginx-nr-agent.pid and than start/restart it. And second solution is to restart the server.
This plugin is published and supported by Nginx, Inc. If the previous suggestions did not help, contact
newrelic-support#nginx.com.

How can I fix biopython urllib.error.HTTPError 502?

Hi I am using biopython to pull files from NCBI using Entrez. The program works on small files but on larger files I get an error. I would really appreciate some insight or help figuring out what went wrong.
Here is the program:
from Bio import Entrez
Entrez.email = "jbro262#lsu.edu"
search_handle = Entrez.esearch(db="nucleotide",term="Saimiri",usehistory="n")
search_results = Entrez.read(search_handle)
search_handle.close()
gi_list = search_results["IdList"]
count = int(search_results["Count"])
a = open("Numfile.txt", "a+")
a.write("The number of Saimiri files are :")
a.write(str(count))
a.write("\n")
a.close()
webenv = search_results["WebEnv"]
query_key = search_results["QueryKey"]
batch_size = 25
out_handle = open("SaimiriDNA.fasta", "w")
for start in range(0,count,batch_size):
end = min(count, start+batch_size)
print("Going to download record %i to %i" % (start+1, end))
fetch_handle = Entrez.efetch(db="nucleotide", rettype="fasta", retmode="text", retstart=start, retmax=batch_size, webenv=webenv, query_key=query_key)
data=fetch_handle.read()
fetch_handle.close()
out_handle.write(data)
out_handle.close()
Here are the errors:
Traceback (most recent call last):
File "Entrezfiles_Saimiri.py", line 53, in <module>
fetch_handle = Entrez.efetch(db="nucleotide", rettype="fasta", retmode="text", retstart=start, retmax=batch_size, webenv=webenv, query_key=query_key)
File "/usr/local/lib/python3.4/
dist-packages/Bio/Entrez/__init__.py", line 149, in efetch
return _open(cgi, variables, post)
File "/usr/local/lib/python3.4/dist-packages/Bio/Entrez/__init__.py", line 464, in _open
raise exception
File "/usr/local/lib/python3.4/dist-packages/Bio/Entrez/__init__.py", line 462, in _open
handle = _urlopen(cgi)
File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 461, in open
response = meth(req, response)
File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.4/urllib/request.py", line 499, in error
return self._call_chain(*args)
File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/usr/lib/python3.4/urllib/request.py", line 579, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway
Does this mean something is going wrong with my server while the files are downloading?

Resources