I have to decode BIN file downloaded from a company server to .txt or JSON File format using protocol buffer/compiler (which I have installed). I am using the following decode command in VS Code terminal for the purpose but do not able to deduce the error. I am an automotive systems engineer with no knowledge of coding language and have to decode the BIN file to complete my graduation thesis, so any help will be great full.
Windows Powershell error:
PS C:\Users\user\Desktop\MyPrograms> C:\protoc-3.14.0-win64\bin\protoc --decode=se.niradynamics.ncs.protobuf.output.RoadLayerTile roadlayertile.proto "< road_roughness_aggregation_23602633.bin >" output.txt
Could not make proto path relative: < road_roughness_aggregation_23602633.bin >: No such file or directory
It's just that it can't find the bin file, you have to search for it with the Windows file manager.
You should not have quotes around the pipe ( < and > ) operations, otherwise instead of redirecting stdin / stdout, you are looking for the literal file with > and < in the path, which isn't a thing that can exist. Take away the double quotes entirely.
To be honest though: using protoc here is very much doing this the hard way. If this was me, I'd run the .proto through either protoc or protogen to get a code model that represents the schema in my language of choice, and deserialize into that, then run that model through any JSON serializer.
Related
I'm trying to use V8 library compiled via vcpkg install v8 but receiving the following error:
Failed to deserialize the V8 snapshot blob. This can mean that the snapshot blob file is corrupted or missing.
I'm testing it on shipped hello-world.cc example:
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
Isolate* isolate = Isolate::New(create_params); // << here is the crash
Isolate::Scope isolate_scope(isolate);
This error is generated in Isolate* isolate = Isolate::New(create_params); because inner variable i_isole doesn't have assigned any snapshot_blog:
if (!i::Snapshot::Initialize(i_isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
if (i_isolate->snapshot_blob() != nullptr) {
FATAL(
"Failed to deserialize the V8 snapshot blob. This can mean that the "
"snapshot blob file is corrupted or missing.");
}
Unfortunately, I'm not able to find any reference to this error. Thanks for any advice.
Updated: I'm trying it on Visual Studio 2019, the same on 32-bit build and 64-bit build too.
Updated: Based on vcpkg.json file, the version is "9.0.257.17". I will try to update it to the latest version if this is not some already fixed bug.
For v8::V8::InitializeExternalStartupData(argv[0]); to work, make sure you have the file snapshot_blob.bin in the same directory as the executable you've compiled. Alternatively, make sure you're passing the correct path instead of argv[0].
I don't know anything about vcpkg install v8; it could be that the library you get that way is compiled without V8_USE_EXTERNAL_STARTUP_DATA, in which case you should turn off external startup data for your build as well. If you don't have a snapshot_blob.bin file at all, that would be an indicator that this is the case.
I want to build an app with javascript which integrates object-detection. For this, I wanna use the ssd_mobilenet_v1_coco model and use it in tensorflow.
However this line of code:
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' \saved_model\saved_model \saved_model\web_model
does not work. It gives me file not found error, but the file is actually there unless I'm very dump and turned back into computer beginner.
OSError: SavedModel file does not exist at: \saved_model\saved_model
Also, I'm not quite sure about the output node names but this is secondary.
Thanks for support, hopefully I'm not totally dump :)
This might be because you are using an absolute path instead of a relative path.
On mac or linux, if you are in the directory that contains the downloaded unzipped model, you would run a command of that type :
tensorflowjs_converter --input_format=tf_saved_model --output_node_names='detection_boxes,detection_classes,detection_scores,num_detections' --saved_model_tags=serve ./ssd_mobilenet_v1_coco/saved_model ./ssd_mobilenet_v1_coco/web_model
From what i can see you are on Windows.
If you are running your command from the directory that contains the saved_model folder, you should run the following command :
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' .\saved_model\saved_model .\saved_model\web_model
i am using Gettext.js library to localize my contents generated from a JS file. Now the situation is, i have to create and write each and every po files manually. I know we can scan php files for gettext strings using PoEdit. So, is it possible to scan JS files for gettext strings using PoEdit?
Achieved this by creating a new parser of python language in PoEdit.
File > Preferences > Parsers > New
Language:
JS
List of extension:
*.js
Parser command:
xgettext --language=Python --force-po -o %o %C %K %F
Item in Keyword List:
-k%k
Item in input files list:
%f
Source code charset:
--from-code=%c
i found this tutorial while searching on this, which helped me to attain the situation Tutorial Here>>
Actually the tutorial is in French and the link is a google translated(to English) one.
Since version xgettext 0.18.3, you can use JavaScript as the language parameter.
This version of xgettext is used in Poedit since at least version 1.6.2.
The xgettext commandline program is used to scan source code and can parse the following languages:
C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, Tcl, Perl, PHP, GCC-source, Glade
Although JavaScript is not listed as a language, I just tried it with a few and Perl actually worked. Try this:
echo " testFunc('foo');" > test.js;
xgettext --keyword=testFunc --output=- test.js --language="perl";
To do this from POEdit, open Preferences > Parsers > Perl add ;*.js to the file extensions list and add --language=Perl after xgettext in the Parser command field. This worked for me and I was able to get new strings from a JS file this way.
Although I don't know how gettext.js works a better approach may be to convert PO files to a native JavaScript file format.
xgettext now supports JavaScript natively, so the command is simply:
xgettext --output=output.pot --language=JavaScript *.js
I have successfully installed Spidermonkey JS engine on my Linux machine ( Ubuntu ).
Basically my goal is to make it execute Ajax (js) scripts and return the result back to my Python script. I'm basically trying to build a good O.O. web scraper. But it's pretty hard for me to get all of this working.
I'm now at the point where when I type JS in my terminal I can start executing Javascript.
I've been Googling and found this little snipet on Stackoverflow :
import urllib2
import spidermonkey
js = spidermonkey.Runtime()
js_ctx = js.new_context()
script = urllib2.urlopen('http://etherhack.co.uk/hashing/whirlpool/js/whirlpool.js').read()
js_ctx.eval_script(script)
js_ctx.eval_script('var s="abc"')
js_ctx.eval_script('print(HexWhirpool(s))')
but it failed to run with the error that module Spidermonkey can not be found.
I'm a bit lost now. Anyone able to help?
I also tried easy_install python-spidermonkey with no luck, for libnspr-dev package is absent.
So, I've built package from source. Instructions from project page (Debian Stretch):
Building
Check out the Python-Spidermonkey module from the SVN repository ( I downloaded it as source archive, direct link )
Unpack, and cd to ./python-spidermonkey/trunk
CPPFLAGS="-Wno-format-security" python setup.py build (these flags for Debian)
Error jsemit.h:508:32: error: expected ‘(’ before ‘)’ token uintN decltype); means that decltype cannot be used as variable (maybe it's a macro or something else), fix it this way:
sed -e 's/decltype/dectyp/' -i.ORIG ./js/src/jsemit.h
sed -e 's/decltype/dectyp/' -i.ORIG ./js/src/jsemit.cpp
Error jsemit.cpp:6490:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘uint8 {aka unsigned char}’ inside { } [-Wnarrowing] means illegal variable conversion, recompile it manually:
cd js/src
g++ -o Linux_All_DBG.OBJ/jsemit.o -c -Wall -Wno-narrowing -Wno-format -MMD -g3 -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DHAVE_VA_COPY -DVA_COPY=va_copy -DPIC -fPIC -DDEBUG -DDEBUG_user -DEDITLINE -ILinux_All_DBG.OBJ jsemit.cpp
Error spidermonkey.c:1:2: error: #error Do not use this file, it is the result of a failed Pyrex compilation. - some trouble with pyrex. There is a patch. Do it this way:
wget -O - https://storage.googleapis.com/google-code-attachments/python-spidermonkey/issue-14/comment-4/cinit.patch | patch -p1 ./spidermonkey.pyx
Installation
su, and python setup.py install as root.
Running
By default, setup script installs libjs.so to /usr/local/lib/, so I did ln -s /usr/local/lib/libjs.so /usr/lib/libjs.so (but you'd better use solution from Seagal82)
Without this step, python keeps complaining about import ImportError: libjs.so: cannot open shared object file: No such file or directory
I also had an error ImportError: cannot import name Runtime after from spidermonkey import Runtime. The reason possibly was in old easy_install data in ~/.local/lib/python2.7/site-packages/spidermonkey/. After removing it, all runs smooth
Recently i got a task need to do something like Web scraping,
and for the javascript part, currently want to try using python-spidermonkey to resolve it and see if this might work for me ...
and i seem to meet situation might alike, after i think i finished install python-spidermonkey, i execute the script above, i got this error:
Traceback (most recent call last):
File "spidermonkeytest.py", line 2, in <module>
import spidermonkey
ImportError: libjs.so: cannot open shared object file: No such file or directory
then after some searching by google...i found the solution probably in the end of here:
http://hi.baidu.com/peizhongyou/item/ec1575c3f0e00e31e80f2e48
i setup these things:
$sudo vi /etc/ld.so.conf.d/libjs.so.conf
fill in this line:
/usr/local/lib/
save & exit, execute ldconfig:
$sudo ldconfig
then i can run the script provided above by #Synbitz Prowduczions
don't know if this is the answer you need, or this still helps?
You need to try libnspr4. If that doesn't work, you can always download it from Mozilla and build the code yourself.
It is not difficult to type ./config && make && make install to build the library yourself after untarring the source. If you build yourself, files will likely be in
/usr/local/{include,lib}
Also just try Googling for "YOUR_OS_NAME install nspr4".
I believe someone wrote a C/C++ header file translator for Python ctypes. Although I can't say much else because I don't use Python.
SpiderMonkey also has its own implementation of ctypes modeled after Python. So technically if you know javascript you could forego using Python altogether since you want to do some ajax with it. You will need to brush up on the NSPR or C runtime sockets to meet the requirements for your projects using only Spidermonkey.
OR a web search for Python +AJAX might turn up exactly what you need.
I am using windows 7 64bit...
I've installed nodejs 0.6.11 by MSI installer, the installation path is "C:\Program Files (x86)\nodejs", it was automatically added to my %PATH% by the installer, I installed doctorjs by steps below:
I copied doctorjs files under "C:\Program Files (x86)\nodejs\doctorjs"
I created jsctags.cmd filled with content copied from https://gist.github.com/1438882
I added following lines in my _vimrc:
let g:tagbar_type_javascript = {
\ 'ctagsbin' : 'C:\Program Files (x86)\nodejs\jsctags.cmd'
\ }
The problem is, when I run jsctags.cmd "{My js folder}", it generates tags file with only content below:
!_TAG_FILE_FORMAT 2 /extended format/
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton#mozilla.com/
!_TAG_PROGRAM_NAME jsctags //
!_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
!_TAG_PROGRAM_VERSION 0.1 //
And when I run :tagbaropen in vim, it shows nothing for current js file..
Please kindly guide me where I did wrong, thank you!
Since you're getting some output, it looks like you have the gist implemented correctly. But maybe your expectation of how to use it at a command line is different than the way it really works?
FYI: jsctags.cmd "{my js folder}" returns an empty tags file on my machine too. I don't think the command interface is very mature yet... so it looks like creating a tagfile of a whole folder is not possible - yet...
Try jsctags.cmd "{file}". This should create a populated tag file.
Also note that tagbar calls jsctags like this: jsctags -f - {file}. This streams the output to stdout. So if you're debugging, try this form of the command.
As another debugging tip, modify your batchfile to output debugging info. ie:
Add lines like this:
echo "%~dp0"\"node.exe" "D:\opt\node\doctorjs\bin\jsctags.js" %* > d:\debug.txt
Looking in d:\debug.txt will let you see what the command looks like as it is called from tagbar.
BTW: The gist you're using was mine... I am wondering if I didn't test this batch file well enough with folders that have spaces in them. Do some tests in both folders with and without spaces to see if there is a difference. If you get more insight into where it works/doesn't, let me know and I can investigate further.
Your issue might be related to the commit of narcissus you've cloned for doctorjs. Go into the narcissus folder in the doctorjs folder and run
git checkout 4ae5aff8b3
This should switch the head to the proper version of the file.