I have issue JSONDecodeError at /profile - django-models

JSONDecodeError at /profile
Expecting value: line 1 column 1 (char 0)
Request Method: POST
Request URL: http://127.0.0.1:8000/profile
Django Version: 3.2.6
Exception Type: JSONDecodeError
Exception Value:
Expecting value: line 1 column 1 (char 0)
Exception Location: C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib\json\decoder.py, line 355, in raw_decode
Python Executable: C:\Users\bismi\AppData\Local\Programs\Python\Python310\python.exe
Python Version: 3.10.6
Python Path:
['C:\Users\bismi\OneDrive\Desktop\connectyfi modftn\connectyfi',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\python310.zip',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\DLLs',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib\site-packages']

Related

Can I dynamically set the condition in an IoT Rule SQL?

in this section of yaml file, I need to update condition in sql statement.
for example, user can reset condition to equal 20 instead of 30.
NotifyTemperatureAlarm:
Type: 'AWS::Serverless::Function'
DependsOn: AlertSNSTopic
Properties:
CodeUri: src/notify_temperature_alarm/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
PutImageEvent:
Type: IoTRule
Properties:
Sql: Select * FROM 'device/temperature/alarms' where value > 30
Policies:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "sns:*"
Resource: "*"
Environment:
Variables:
alert_sns: !Ref AlertSNSTopic
make your condition in parameters section such as
Parameters:
TemperatureThreshold:
Type: Number
Default: '20'
then update NotifyTemperatureAlarm such as
NotifyTemperatureAlarm:
Type: 'AWS::Serverless::Function'
DependsOn: AlertSNSTopic
Properties:
CodeUri: src/notify_temperature_alarm/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
PutImageEvent:
Type: IoTRule
Properties:
Sql: !Sub "SELECT * FROM 'device/temperature/alarms' where value > ${TemperatureThreshold}"
Policies:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "sns:*"
Resource: "*"
Environment:
Variables:
alert_sns: !Ref AlertSNSTopic
to make TemperatureThreshold Adjustable, you can update it from cloudformation such as
client = boto3.client('cloudformation')
response = client.update_stack(
StackName = "your_stack_name",
UsePreviousTemplate = True,
Capabilities = ['CAPABILITY_IAM'],
Parameters=[
{
'ParameterKey': 'TemperatureThreshold',
'ParameterValue': str(new_threshold),
}
]
)

Warning: Invalid stream: "FormatError: Bad FCHECK in flate stream: 120, 239" on PDF response from springboot API after dropzone upload

I'm using dropzone to send files to a springboot api, which processes those files and returns a pdf response, which I want to display on my angular front-end. Everything works fine until time to display the pdf, when it renders a blank pdf (with the correct number of pages) along with the warnings in console:
Warning: Indexing all PDF objects pdf.worker.min.js:1
Warning: Invalid stream: "FormatError: Bad FCHECK in flate stream: 120, 239"
I know that the pdf itself is not corrupt, because when I make a get request to the API to retrieve the stored version of the same pdf, it is not corrupt and renders fine.
I have tried using TextEncoder:
let enc = new TextEncoder();
this.masterPdf = enc.encode(event[1])
using FileReader:
var reader = new FileReader();
  reader.onload = function() {
var arrayBuffer = this.result;
self.masterPdf = new Uint8Array(arrayBuffer);
console.log(self.masterPdf);
self.masterShow = true;
}
var blob = new Blob([event[1]], {type:'application/pdf'});
reader.readAsArrayBuffer(blob);
and using StringToBytes:
let strToByteArr = stringToBytes(event[1]);
this.masterPdf = new Uint8Array(strToByteArr);
event in all of these cases is the response, here it is below (of course the pdf string is actually much longer):
0: File(1237) {upload: {…}, status: "success", accepted: true, processing: true, xhr: XMLHttpRequest, …}
1:"%PDF-1.7↵%����↵1 0 obj↵<</Type/Catalog/Pages 2 0 R/Lang(en-US) /StructTreeRoot 12 0 R/MarkInfo<</Marked true>>/Metadata 32 0 R/ViewerPreferences 33 0 R>>↵endobj↵2 0 obj↵<</Type/Pages/Count 2/Kids[ 3 0 R 9 0 R] >>↵endobj↵3 0 obj↵<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R>>/ExtGState<</GS7 7 0 R/GS8 8 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>↵endobj↵4 0 obj↵<</Filter/FlateDecode/Length 3808>>↵stream
2: ProgressEvent {isTrusted: true, lengthComputable: true, loaded: 99282, total: 99282, type: "load", …}
I did check those particular bytes (120-239) in the valid file returned versus the invalid one, and they are different, but the invalid one just looked like normal numbers.
When requesting a PDF from an API, set the request's response type to 'blob'. The default type is application/json.
Once the file has been received, create a blob using the response's data then use the blob to create a url.
let blob = new Blob([data], {type: 'application/pdf'})
let url = window.URL.createObjectURL(blob)

do_rootfs function failed in yocto project

I am just getting started with the yocto project and trying to build an image for x86 architecture to be emulated using QEMU emulator (running on Ubuntu 16.04 ).I am getting the following error while building the OS image.
ERROR: core-image-sato-1.0-r0 do_rootfs: Error executing a python function in exec_python_func() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:do_rootfs(d)
0003:
File: '/home/rahul/poky/poky/meta/classes/image.bbclass', lineno: 258, function: do_rootfs
0254: progress_reporter.next_stage()
0255:
0256: # generate rootfs
0257: d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
*** 0258: create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
0259:
0260: progress_reporter.finish()
0261:}
0262:do_rootfs[dirs] = "${TOPDIR}"
File: '/home/rahul/poky/poky/meta/lib/oe/rootfs.py', lineno: 1010, function: create_rootfs
1006: env_bkp = os.environ.copy()
1007:
1008: img_type = d.getVar('IMAGE_PKGTYPE')
1009: if img_type == "rpm":
*** 1010: RpmRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
1011: elif img_type == "ipk":
1012: OpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
1013: elif img_type == "deb":
1014: DpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
File: '/home/rahul/poky/poky/meta/lib/oe/rootfs.py', lineno: 201, function: create
0197: if self.progress_reporter:
0198: self.progress_reporter.next_stage()
0199:
0200: # call the package manager dependent create method
*** 0201: self._create()
0202:
0203: sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir')
0204: bb.utils.mkdirhier(sysconfdir)
0205: with open(sysconfdir + "/version", "w+") as ver:
File: '/home/rahul/poky/poky/meta/lib/oe/rootfs.py', lineno: 450, function: _create
0446: rpm_pre_process_cmds = self.d.getVar('RPM_PREPROCESS_COMMANDS')
0447: rpm_post_process_cmds = self.d.getVar('RPM_POSTPROCESS_COMMANDS')
0448:
0449: # update PM index files
*** 0450: self.pm.write_index()
0451:
0452: execute_pre_post_process(self.d, rpm_pre_process_cmds)
0453:
0454: if self.progress_reporter:
File: '/home/rahul/poky/poky/meta/lib/oe/package_manager.py', lineno: 543, function: write_index
0539:
0540: def write_index(self):
0541: lockfilename = self.d.getVar('DEPLOY_DIR_RPM') + "/rpm.lock"
0542: lf = bb.utils.lockfile(lockfilename, False)
*** 0543: RpmIndexer(self.d, self.rpm_repo_dir).write_index()
0544: bb.utils.unlockfile(lf)
0545:
0546: def insert_feeds_uris(self, feed_uris, feed_base_paths, feed_archs):
0547: from urllib.parse import urlparse
File: '/home/rahul/poky/poky/meta/lib/oe/package_manager.py', lineno: 105, function: write_index
0101: else:
0102: signer = None
0103:
0104: createrepo_c = bb.utils.which(os.environ['PATH'], "createrepo_c")
*** 0105: result = create_index("%s --update -q %s" % (createrepo_c, self.deploy_dir))
0106: if result:
0107: bb.fatal(result)
0108:
0109: # Sign repomd
File: '/home/rahul/poky/poky/meta/lib/oe/package_manager.py', lineno: 21, function: create_index
0017:def create_index(arg):
0018: index_cmd = arg
0019:
0020: bb.note("Executing '%s' ..." % index_cmd)
*** 0021: result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
0022: if result:
0023: bb.note(result)
0024:
0025:"""
File: '/usr/lib/python3.5/subprocess.py', lineno: 626, function: check_output
0622: # empty string. That is maintained here for backwards compatibility.
0623: kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
0624:
0625: return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
*** 0626: **kwargs).stdout
0627:
0628:
0629:class CompletedProcess(object):
0630: """A process that has finished running.
File: '/usr/lib/python3.5/subprocess.py', lineno: 708, function: run
0704: raise
0705: retcode = process.poll()
0706: if check and retcode:
0707: raise CalledProcessError(retcode, process.args,
*** 0708: output=stdout, stderr=stderr)
0709: return CompletedProcess(process.args, retcode, stdout, stderr)
0710:
0711:
0712:def list2cmdline(seq):
Exception: subprocess.CalledProcessError: Command '/home/rahul/poky/poky/build/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/recipe-sysroot-native/usr/bin/createrepo_c --update -q /home/rahul/poky/poky/build/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/oe-rootfs-repo' returned non-zero exit status 1
Subprocess output:
Temporary repodata directory /home/rahul/poky/poky/build/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/oe-rootfs-repo/.repodata/ already exists! (Another createrepo process is running?)
ERROR: core-image-sato-1.0-r0 do_rootfs: Function failed: do_rootfs
ERROR: Logfile of failure stored in: /home/rahul/poky/poky/build/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/log.do_rootfs.5019
ERROR: Task (/home/rahul/poky/poky/meta/recipes-sato/images/core-image-sato.bb:do_rootfs) failed with exit code '1'
Build process runs upto almost 90 percent after which this error comes up which terminates the process.What could be the issue ?
I got the same error when my host machine shut down abruptly, but everything worked well after I delete the .repodata folder with sudo rm -r build/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/oe-rootfs-repo/.repodata/ and then build again.
I stopped a build using Ctrl-C and got the python error described in the original question.
The .repodata folder (please see the answer from jmiranda) was empty. So I deleted the oe-rootfs-repo folder and this worked for me.
I get the same issue, but with error "Directory not empty" instead, when building in Docker container. Deleting the destination directory using rm -r, and running the build again, works.
None of these methods worked for me.
I then clean the build using bitbake -c clean mybuildname and then again made the build and it worked flawlessly, i hope it helps someone.

Error 500 CakePHP 3

I've an error 500 that I don't understand. The error was here before I begin to work on this project so it's complicated. When I click on button to open a PDF (with html2pdf), the error 500 appear. I've tried all I've found, but nothings works.
I can't send you code, or maybe few lines.
Output from error log:
2017-07-03 14:04:28 Error: Fatal Error (1): Maximum execution time of
60 seconds exceeded in [C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Error\BaseErrorHandler.php,
line 126] Request URL: /fra/my-leads/view/aekt.pdf Referer URL:
http://localhost:8765/fra/my-leads Trace:
Cake\Error\BaseErrorHandler::handleFatalError() -
CORE\src\Error\BaseErrorHandler.php, line 223
Cake\Error\BaseErrorHandler::Cake\Error{closure}() -
CORE\src\Error\BaseErrorHandler.php, line 105 [main] - [internal],
line ??
2017-07-03 14:04:28 Error: [Cake\Error\FatalErrorException] Maximum
execution time of 60 seconds exceeded Request URL:
/fra/my-leads/view/aekt.pdf Referer URL:
http://localhost:8765/fra/my-leads Stack Trace: 0 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Error\BaseErrorHandler.php(105):
Cake\Error\BaseErrorHandler->handleFatalError(1, 'Maximum executi...',
'C:\Users\JCP 2...', 126) 1 [internal function]:
Cake\Error\BaseErrorHandler->Cake\Error{closure}() 2 {main}
More precision : when I just write "hello" in pdf, I don't have error. It's only when I try to get datas. And when I set this pdf to another view (so without pdf format) it works :/
Log output after increasing execution time
2017-07-04 08:19:08 Error: [Spipu\Html2Pdf\Exception\ImageException]
Unable to get the size of the image
[http://localhost:8765/img/logo.png?1497859287] Request URL:
/fra/my-leads/view/trkkdz.pdf Referer URL:
http://localhost:8765/fra/my-leads
I try to comment the logo and now, it says this :
2017-07-04 08:23:06 Error: [Exception] TCPDF ERROR: Some data has
already been output, can't send PDF file Request URL:
/fra/my-leads/view/trkkdz.pdf Referer URL: ... Stack Trace: 0
C:\Users\JCP
2\Documents\buyers\vendor\tecnickcom\tcpdf\tcpdf.php(7620):
TCPDF->Error('Some data has a...') 1 C:\Users\JCP
2\Documents\buyers\vendor\spipu\html2pdf\src\Html2Pdf.php(506):
TCPDF->Output('MLC_Lead-trkkdz...', 'I') 2 C:\Users\JCP
2\Documents\buyers\src\Template\Layout\pdf\default.ctp(10):
Spipu\Html2Pdf\Html2Pdf->output('MLC_Lead-trkkdz...') 3 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(1010):
include('C:\Users\JCP 2...') 4 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(971):
Cake\View\View->_evaluate('C:\Users\JCP 2...', Array) 5 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(642):
Cake\View\View->_render('C:\Users\JCP 2...') 6 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(600):
Cake\View\View->renderLayout('', 'default') 7 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Controller\Controller.php(623):
Cake\View\View->render(NULL, NULL) 8 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(125):
Cake\Controller\Controller->render() 9 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(93):
Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\MyLeadsController))
10 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(60):
Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest),
Object(Cake\Http\Response)) 11 C:\Users\JCP
2\Documents\buyers\webroot\index.php(37):
Cake\Routing\Dispatcher->dispatch(Object(Cake\Http\ServerRequest),
Object(Cake\Http\Response)) 12 {main}
This means your application is taking more than 60 seconds to run. That is why it is crushing. Add the code below to index.php in webroot directory
<?php
set_time_limit ( 60 * 5 ); // 5 minutes
?>
or in your php.ini :
max_execution_time=300

500 server error while registration with OpenID

I deployed a Q&A site using OSQA. I have a problem with OpenID. When I click on a provider to register new user (i.e. google), osqa redirects me to google to confirm my email address. Then I came back to osqa, it asks for a username and password. In next step I get 500 server error and registration fails. I can register new user with normal registration form and login without any problem.
Here are last lines of /log/django.osqa.log:
/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/core/handlers/base.py TIME: 2013-06-01 00:40:52,772 MSG: base.py:handle_uncaught_exception:209 Internal Server Error: /account/register/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/osqa/osqa-server/forum/views/auth.py", line 159, in external_register
if form1.is_valid():
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 121, in is_valid
return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 112, in _get_errors
self.full_clean()
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 267, in full_clean
self._clean_fields()
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 284, in _clean_fields
value = field.clean(value)
File "/home/osqa/osqa-server/forum/forms/general.py", line 151, in clean
return super(UserRealNameField, self).clean(real_name)
File "/home/osqa/osqa-server/forum/forms/general.py", line 27, in clean
value = value.strip()
AttributeError: 'NoneType' object has no attribute 'strip'
/home/osqa/osqa-server/forum/views/meta.py TIME: 2013-06-01 00:40:52,777 MSG: meta.py:error_handler:200
error executing request:
PATH: /account/register/
USER: <anonymous>
METHOD: POST
POST PARAMETERS:
username: asbol
csrfmiddlewaretoken: 3204ab843f346dd595302ae4910ea26d
email: asbolasbol#gmail.com
bnewaccount: Create Account
next: /
GET PARAMETERS:
None
HTTP HEADERS:
mod_wsgi.listener_port: 80
HTTP_REFERER: http://domain/account/register/
mod_wsgi.listener_host:
SERVER_SOFTWARE: Apache/2.2.22 (Ubuntu)
SCRIPT_NAME:
mod_wsgi.handler_script:
SERVER_SIGNATURE: <address>Apache/2.2.22 (Ubuntu) Server at domain Port 80</address>
REQUEST_METHOD: POST
PATH_INFO: /account/register/
HTTP_ORIGIN: http://domain
SERVER_PROTOCOL: HTTP/1.1
QUERY_STRING:
CONTENT_LENGTH: 221
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
HTTP_CONNECTION: keep-alive
HTTP_COOKIE: __atuvc=1%7C22; greeting_set=True; csrftoken=3204ab843f346dd595302ae4910ea26d; sessionid=c59f00fd45976880b724074376627286
SERVER_NAME: domain
REMOTE_ADDR: 5.63.149.98
mod_wsgi.request_handler: wsgi-script
wsgi.url_scheme: http
PATH_TRANSLATED: /home/osqa/osqa-server/osqa.wsgi/account/register/
SERVER_PORT: 80
wsgi.multiprocess: False
mod_wsgi.input_chunked: 0
SERVER_ADDR: IP
DOCUMENT_ROOT: /home/osqa/osqa-server
mod_wsgi.process_group: OSQA
SCRIPT_FILENAME: /home/osqa/osqa-server/osqa.wsgi
SERVER_ADMIN: admin#domain
wsgi.input: <mod_wsgi.Input object at 0x7f40b05e6870>
HTTP_HOST: domain
wsgi.multithread: True
mod_wsgi.callable_object: application
HTTP_CACHE_CONTROL: max-age=0
REQUEST_URI: /account/register/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
wsgi.version: (1, 1)
GATEWAY_INTERFACE: CGI/1.1
wsgi.run_once: False
wsgi.errors: <mod_wsgi.Log object at 0x7f40b9e83a30>
REMOTE_PORT: 55121
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
mod_wsgi.version: (3, 3)
CONTENT_TYPE: application/x-www-form-urlencoded
mod_wsgi.application_group: domain|
mod_wsgi.script_reloading: 1
wsgi.file_wrapper: <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f40b065aaf8>
CSRF_COOKIE: 3204ab843f346dd595302ae4910ea26d
HTTP_ACCEPT_ENCODING: gzip,deflate,sdch
COOKIES:
__atuvc: 1%7C22
csrftoken: 3204ab843f346dd595302ae4910ea26d
sessionid: c59f00fd45976880b724074376627286
greeting_set: True
EXCEPTION INFO:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/osqa/osqa-server/forum/views/auth.py", line 159, in external_register
if form1.is_valid():
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 121, in is_valid
return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 112, in _get_errors
self.full_clean()
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 267, in full_clean
self._clean_fields()
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/forms/forms.py", line 284, in _clean_fields
value = field.clean(value)
File "/home/osqa/osqa-server/forum/forms/general.py", line 151, in clean
return super(UserRealNameField, self).clean(real_name)
File "/home/osqa/osqa-server/forum/forms/general.py", line 27, in clean
value = value.strip()
AttributeError: 'NoneType' object has no attribute 'strip'
How can I fix the problem?

Resources