Debugging suspended at 'mobdebug.start():1' (couldn't activate the file) - zerobrane

I am trying to use Remote Debugging of ZeroBrane to debug my application.
I don't want users add any extra codes to their scripts. So when a user click the debug button, at the C side, first, I set the path and call the mobdebug lib, then I try to execute the user code:
luaL_dostring(L, "package.path = package.path .. ';./scripts/lualibs/mobdebug/?.lua;./scripts/lualibs/?.lua'");
luaL_dostring(L, "package.cpath = package.cpath .. ';./scripts/bin/clibs/?.dll'");
luaL_dostring(L, "mobdebug = require('mobdebug').start()");
luaL_dofile(L, FileName);
It works fine for the official lua 5.1 intepreter. The debugger stops at line 1 of the source file. But if I switch to luajit, the zerobrane prompts "Debugging suspended at 'mobdebug.start():1' (couldn't activate the file).". Then I click "step over", the script file can be activated and the debugger stops at line 1.
Is there any way to skip the error message and directly activate the source file when using luajit?

You may want to set debugger.runonstart = true to continue execution without stopping at the first line (documentation), but you will need to use breakpoints or Project | Break to suspend the execution when the debugging is started.

Related

PyCharm Selenium not openening Chrome, "Process finished with exit code 0" [duplicate]

I am new to PyCharm and I have 'Process finished with exit code 0' instead of getting (683, 11) as a result (please see attachment), could you guys help me out please? Much appreciate it!
That is good news! It means that there is no error with your code. You have run it right through and there is nothing wrong with it. Pycharm returns 0 when it has found no errors (plus any output you give it) and returns 1 as well as an error message when it encounters errors.
Editors and scripts do not behave like the interactive terminal, when you run a function it does not automatically show the the result. You need to actually tell it to do it yourself.
Generally you just print the results.
If you use print(data.shape) it should return what you expect with the success message Process finished with exit code 0.
exit code 0 means you code run with no error.
Let's give a error code for example(clearly in the below image): in below code, the variable lst is an empty list,
but we get the 5 member in it(which not exists), so the program throws IndexError, and exit 1 which means there is error with the code.
You can also define exit code for analysis, for example:
ERROR_USERNAME, ERROR_PASSWORD, RIGHT_CODE = 683, 11, 0
right_name, right_password = 'xy', 'xy'
name, password = 'xy', 'wrong_password'
if name != right_name:
exit(ERROR_USERNAME)
if password != right_password:
exit(ERROR_PASSWORD)
exit(RIGHT_CODE)
I would recommend you to read up onexit codes.
exit 0 means no error.
exit 1 means there is some error in your code.
This is not pyCharm or python specific. This is a very common practice in most of the programming languages. Where exit 0 means the successful execution of the program and a non zero exit code indicates an error.
Almost all the program(C++/python/java..) return 0 if it runs successful.That isn't specific to pycharm or python.
In program there is no need to invoke exit function explicitly when it runs success it invoke exit(0) by default, invoke exit(not_zero_num) when runs failed.
You can also invoke exit function with different code(num) for analysis.
You can also see https://en.wikipedia.org/wiki/Exit_(system_call) for more details.
What worked for me when this happened was to go to
Run --> Edit Configurations --> Execution --> check the box Run with
Python Console (which was unchecked).
This means that the compilation was successful (no errors). PyCharm and command prompt (Windows OS), terminal (Ubuntu) don't work the same way. PyCharm is an editor and if you want to print something, you explicitly have to write the print statement:
print(whatever_you_want_to_print)
In your case,
print(data.shape)
I think there's no problem in your code and you could find your print results (and other outputs) in the tab 5: Debug rather than 4: Run.
I just ran into this, but couldn't even run a simple print('hello world') function.
Turns out Comodo's Firewall was stopping the script from printing. This is a pretty easy fix by deleting Python out of the Settings > Advanced > Script Analysis portion of Comodo.
Good Luck
I had same problem with yours. And I finally solve it
I see you are trying to run code "Kaggle - BreastCancer.py"
but your pycharm try to run "Breast.py" instead of your code.
(I think Breast.py only contains functions so pycharm can run without showing any result)
Check on tab [Run] which code you are trying to run.
Your starting the program's run from a different file than you have open there. In Run (alt+shift+F10), set the python file you would like to run or debug.

how to automatically break the lua program at the error line

I use my own interpreter to run the lua program and debug with zerobrane. If the interpreter encounters an error, how to let the debugger break at the error line?
There is no mechanism in Lua that allows to catch run-time errors. There was a call to debug.traceback function in Lua 5.1, but it's no longer called in Lua 5.2+. If you have your own error handling, you can call require("mobdebug").pause(), which will request ZeroBrane Studio debugger to stop on the next executable Lua line, which will allow you at least to see the stack trace and the location of the error, but this is probably all you can do. You can also try to assign debug.traceback to the function that calls pause, but, again, this will only work in Lua 5.1.
For example, try running the following script from the IDE:
require("mobdebug").start()
debug.traceback = function(...)
print("traceback", ...)
require("mobdebug").pause()
end
a()
print("done") -- it will never get here
If you save it into on-error.lua file and run, you should see the execution stopped on line 5 (after the pause()) call with the following message:
traceback on-error.lua:6: attempt to call global 'a' (a nil value) 2

How can I stop sourcing a (t)csh script on a certain condition without exiting the shell?

I have to source a tcsh script to modify environment variables.
Some tests are to be done and if any fails the sourcing shall stop without exiting the shell. I do not want to run the script as a subprocess because I would need to modify env variables in the parent process which a subprocess cannot do. This is similar but different to this question where the author actually can run the script as a subprocess.
The usual workaround is to create an alias which runs a script (csh/bash/perl/python/...) which writes a tempfile with all the env var settings and at the end sources & deletes that tempfile. Here's more info for those interested (demoing a solution for bash). For my very simple and short stuff I'm doing that additional alias is not wanted.
So my workaround is to provoke a syntax error which stops any source execution. Here's an example:
test $ADMIN_USER = `filetest -U: $SOME_FILE` || "Error: Admin user must own admin file"
The shortcircuit || causes the error text to be ignored in case of goodness. On a test failure the error text is interpreted as a command, not found, the source stops and produces a reasonable error message:
Error: Admin user must own admin file: Command not found.
Is there any nicer way in doing this? Some csh/tcsh built-in that I've overlooked?
Thanks to a discussion with the user shellter I just verified my assumption that
test $ADMIN_USER = `filetest -U: $SOME_FILE` || \
echo "Error: Admin user must own admin file" && \
exit
would actually quit the enclosing interactive shell. But it does not.
So the answer to my above question actually is:
Just use a normal exit and the source will stop sourcing the script while keeping the calling interactive shell running.

query about dev c++-running programs

Can anybody tell me how I can paste text input into the Dev-C++ console (command line shell) while running a program in Dev-C++?
Also is there any other simple IDE which allows users to work with a single source file w/o creating a project?
af far as i can remember dev-cpp start a windows commadline window when a consol application is started. so if you have somethig like
cout << "enter a char: ";
cin >> c;
in your code, the consol window will be wating for input.
an to your second question: Yes and No
Yes: you can use g++.exe (witch comes with dev-cpp) and notepade.exe (witch comses with windows)
and compile your source using commad g++.exe source.cpp and run you application by typing a.exe in a console window witch you have to open yourself and navigate to the directory where source.cpp is located.
No: (g++.exe + notepade.exe) == IDE
Note that you have to extend the PATH envirenment variable to be able to use g++.exe without fullpath to it

How do I get Vim's project plugin to load the in.vim on external buffer change?

I'm using the project plugin in Vim. For each project I'm working on, I have set up an own in.vim/out.vim where the project-specific stuff gets set.
For example, I set a shiftwidth of 2 in the in.vim, whereas in my .vimrc, I set it to 4. When I'm opening a file from the project tree, everything is fine: the sw is 2. Now, I compile the sources (Visual Studio) and get some compiler errors/warnings. Switch to Visual Studio, fix the errors, back to Vim then.
My editor did realize that I changed the file outside the editor and asks me to reload the file. After confirming the reload, the sw is set to 4.
Obviously, this is because the .vimrc is getting read on buffer reload and overwrites my setting of the shiftwidth stored in the in.vim configuration file.
My question is: is there any way to bring the project plugin (or vim itself) to load the in.vim upon buffer refresh?
Solution
The answer of ZyX pointed me to a handling that works for me:
In the in.vim, set a global variable to the path of in.vim:
let g:invimpath = "D:/project/vimstuff/in.vim"
In the .vimrc, try to load this specified file when FileChangedShellPost occurs:
autocmd FileChangedShellPost * if exists("g:invimpath") | exe 'source ' . g:invimpath | endif
Credits go to ZyX to point me to this path.
Yes, it is, with FileChangedShellPost autocommand, but I suggest you first add the following just before the beginning of your vimrc (but after scriptencoding statement, if it is present):
if exists("s:vimrc_loaded")
finish
endif
let s:vimrc_loaded=1