w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Python traceback, show line where error occurred even if not showing complete traceback
You can do something like this: import sys import traceback def a(): try: return b(); except: _, _, tb = sys.exc_info() print traceback.format_list(traceback.extract_tb(tb)[-1:])[-1] Or format the string yourself as you like: import sys import traceback def a(): try: return b(); except: _, _, tb = sys.exc_info() filename, lineno, funname, line = traceback.extract_tb(tb)[-1] print '{}:{}, in {} {}'.format(filename, lineno, funname, line) sys.exc_info() This function returns a tuple of three values that give information about the exception that is currently being handled (...) If no exception is being handled anywhere on the stack, a tuple containing three None values is returned. Otherwise, the val

Categories : Python

How to show result of python script in a console when running from ST editor?
SublimeREPL for is a plugin for SublimeText It does not open a cmd instance but can provide you a REPL, where You can provide input, which you usually cannot give on default console. Installation Install Package Control. http://wbond.net/sublime_packages/package_control Install SublimeREPL Preferences | Package Control | Package Control: Install Package Choose SublimeREPL Restart SublimeText2 Configure SublimeREPL (default settings in Preferences | Package Settings | SublimeREPL | Settings - Default should be modified in Preferences | Package Settings |SublimeREPL | Settings - User, this way they will survive package upgrades! Note from the documentation: ctrl+, , f means: press Ctrl and Comma, release all, press F. The keybinding above is used to Evaluate in REPL If Sublim

Categories : Python

Textarea of TinyMCE(Rich text editor lib) doesn't show anything
Oh I found problem is because missing plugin. following code from TinyMCE website, last plugin moxiemanager is not in package free download that why above code can't show anything. plugins: [ "advlist autolink lists link image charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars code fullscreen", "insertdatetime media nonbreaking save table contextmenu directionality", "emoticons template paste textcolor moxiemanager" ], for solve problem is just remove moxiemanager. Thanks everyone.

Categories : Javascript

python script see traceback when running as background
I use something like this. It will dump the exception which caused termination to your syslog, which you can see by examining /var/log/syslog after your script has stopped. import traceback import syslog def syslog_trace(trace): '''Log a python stack trace to syslog''' log_lines = trace.split(' ') for line in log_lines: if len(line): syslog.syslog(line) def main(): # Your actual program here if __name__ == '__main__': try: main() except: syslog_trace(traceback.format_exc())

Categories : Python

python - show variables during traceback
You could also take a look at Python's builtin function locals(). This will probably work for simple cases, although I'm not sure how robust of a solution it will be. Generally speaking, going from object -> variable name isn't possible in python. import json dos = 2 def foo(): uno = 1 tres = 3 try: json.loads(uno) except: print locals() foo() >>> {'uno': 1, 'tres': 3}

Categories : Python

In Sublime Text, Gedit or any Other editor, how to select and replace everything inside Tags?
If you don't mind regexes, the regex that matches the opening is /[caption[^]]*]/ http://rubular.com/r/eRRxYIsVCG remember to specify case insensitivity if you're going to have caption and CAPTION, etc. if you just want to do this on the command line you can use sed(1) sed 's/[caption[^]]*]/<div class=\"sss\">/g' file.html which sends it to stdin, which you can pipe to whatever file you want. if you want to modify the file in-place you can add the -i switch to sed.

Categories : Regex

Sublime Text 2 Python.sublime-package
Remove existing /User/Python.sublime-package and try manually unzip Python.sublime-package (change it's extension to .zip) to Package folder /Packages/Python. Package folder can be revealed via Preferences->Browse Packages... command.

Categories : Python

Dnn text editor doesn't change form a basic text box to Rich text box
What version of DNN are you using? If you're using DNN7 you will want to make sure you are using the RadEditor controller, not FCK which it appears to be. DNN7 doesn't work with the FCK Editor.

Categories : Asp Net

How to configure python interpretor in sublime text 2 to make it function as IDLE python shell
Go to your Packages folder by selecting Preferences -> Browse Packages.... Go to the User folder and create a SublimeREPL folder containing a config folder containing a Python folder. Then, within that final folder save the following as Main.sublime-menu: [ { "id": "tools", "children": [{ "caption": "SublimeREPL", "mnemonic": "r", "id": "SublimeREPL", "children": [ {"caption": "Python", "id": "Python", "children":[ {"command": "repl_open", "caption": "Python", "id": "repl_python3", "mnemonic": "p", "args": { "type": "subpro

Categories : Python

Using Sublime Text 3 as a Python IDE with 3.3.2?
Set your "cmd" to the following: "cmd": ["/Library/Framework/Python.framework/Versions/3.3/bin/python3", "-u", "$file"], and it should work. Probably the reason your path addition didn't work was because it was missing the beginning /.

Categories : Python

Sublime Text 2 edited file-changes does not show when refreshing browser in Maven project
In order for the changes to take place you have to right-click the file in Eclipse explorer tab and choose "refresh" in order for the (static) changes to be reloaded to Apache. For dynamic changes you'll need to restart apache or use a plugin such as JRebel.

Categories : Eclipse

Sublime Text 2 python SublimeREPL
CtrlShiftP is the keyboard shortcut for the Command Palette, which is what you want. You can also open it via Tools -> Command Palette.... CtrlP is Goto Anything, and has nothing to do with Package Control or installing things. Don't use it. Open the Command Palette by whichever way suits you best, menu or keyboard shortcut. Once there, type PCI and Package Control: Install will be highlighted. Hit Enter, and a dropdown of the full list of available packages should appear. Now, type "sublimerepl" and it should show up. Click on it or hit Enter and you should see a message at the bottom of the window that SublimeREPL is installing. Once it's done, restart ST2 (for good luck) and it should be available in the Tools menu down at the bottom. Please read the full documentation to familiari

Categories : Python

Sublime Text 2. Autocomplete python `from`
Have you checked out SublimeCodeIntel? It's available through Package Control, and has this functionality. The initial indexing of your packages may take some time, but once it's all set (you may need to restart Sublime once or twice to get everything loaded) it works like a charm.

Categories : Python

Python settings in Sublime Text 2
First make sure that you saved the file with .py extension and then try to run again. You also need to check that the Python in your .sublime-build is correct. For this look at %APPDATA%Sublime Text 2PythonPython.sublime-build file. This file should have something like this: { "cmd": ["C:\python27\python.exe", "-u", "$file"], "file_regex": "^[ ]*File "(...*?)", line ([0-9]*)", "selector": "source.python" } This is equivalent to doing the following on the command line, check that you can do: python -u C:your_pathyour_script.py If this doesn't work from the command line it also wont from sublime.

Categories : Python

Setting python path for sublimerepl from sublime text?
Is it possible you're changing the wrong line of code in /Packages/SublimeREPL/config/Python/Main.sublime-menu? If you wish to run REPL on the current file, {"command": "repl_open", "caption": "Python - RUN current file", "id": "repl_python_run", "mnemonic": "d", "args": { "type": "subprocess", "encoding": "utf8", "cmd": ["C:\Users\Andy\Documents\_Main\M-Stick Backups\08.07.13\Computing\Python Portable\Portable Python 2.7.3.1\App\python.exe", "-u", "$file_basename"], "cwd": "$file_path", "syntax": "Packages/Python/Python.tmLanguage", "external_id": "python", "extend_env": {"PYTHONIOENCODING": "utf-8"} } is what the modified section should look like. (It appears you might be modifying the command which opens the interpreter in interactive mode as oppos

Categories : Python

Sublime Text not working with Python hidden pyc file
For future: I didnt name a file re.py recently, But month ago, And then combined the two dir were combined and one had a hidden re.pyc file in the long list of files. Deleted the re.pyc, problem solved.

Categories : Python

How to configure Sublime text 2 to use my installed python libraries
Seems to be a year late but for this kind of problem, I think you just test by running on a "untitled" file (which means you didn't save it under .py file). You have to save it then run it. The point is sublime text will call the cmd, call python in command line and pass the python script file name to it. If you don't save the file, it's like calling python.exe to run on nothing.

Categories : Python

Call C# assembly from Python (in sublime text plugin)
If you're trying to add language support to sublime text by using the C# code to process the editor contents and send back meta-data (syntax highlighting info, autocomplete options, etc.) then a standard approach would be to wrap the C# code in a separate server process and talk to it over sockets in python. If on the other hand you're looking to directly modify sublime text's behaviour than this approach won't do much for you. Some examples of the server approach for extending language support in other editors would be, the VimClojure plugin which talks to a separate java process to add clojure support to vim, or ENSIME which connects to a server written in scala to add scala support to emacs.

Categories : C#

Start Sublime 3 from terminal, when default is Sublime Text 2
When you run sublime, your computer should run a bash file at /usr/bin/sublime (running which sublime as Mike Li suggested will confirm the location. Open that up and edit it for Sublime Text 3. The contents of that file should be: #!/bin/bash /usr/lib/sublime-text-2/sublime_text --class=sublime-text-2 "$@" Edit it as so: (On my computer the executable is called subime_text_3 instead of subime_text. Verifiy by opening /usr/lib/sublime-text-3.) #!/bin/bash /usr/lib/sublime-text-3/sublime_text_3 --class=sublime-text-3 "$@" Point it to the location of Sublime Text 3 on your system. Edit Build 2221 (using the ppa) changed the installation directory from /usr/lib/sublime-text-2 to /opt/sublime_text_2

Categories : Linux

Huge discrepancy between Python time.clock() and Sublime Text 2 timing
This is exactly what you should expect. As the docs say: On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name… POSIX says that the C function: … shall return the implementation's best approximation to the processor time used by the process since the beginning of an implementation-defined era related only to the process invocation. In other words, this is processor time, not wall-clock time. If your processor is doing anything else (like, say, running other programs), or waiting around doing nothing while your program blocks on I/O, it isn't counted. Actually, it's even worse than that—such time ma

Categories : Python

how to install sublime text indent xml in sublime 3
The location is system dependent, but are located at: OS X: ~/Library/Application Support/Sublime Text 3/Packages/ Windows: %APPDATA%/Sublime Text 3/Packages/ Linux: ~/.config/sublime-text-3/Packages/

Categories : Xml

Why does traceback.format_exception require a traceback parameter instead of using ex.__traceback__?
The traceback module is from before the current exception hierarchy existed. Note that none of the functions make explicit mention of an exception object; they all refer to type, value and traceback. In modern Python, the value is always an exception object, and the other arguments are redundant, but back in ancient versions of Python, exception types could be strings. In that case, you'd raise the exception like raise some_module.exception_string, some_arbitrary_object and some_arbitrary_object would be used as the exception value instead of being passed to the exception constructor to create the exception value. You wouldn't have an exception object that you could inspect for the type and traceback, so you'd have to pass all 3 pieces of information around separately. See the Python 2

Categories : Python

Rich Text Editor (YUI Simple Text Editor used) not sending data to next page
The saveHTML() method you used does not seem to save the value to the textarea element. And because the browser doesn't care about YUI Editor and just submits what is there already in the textarea (which is null), it submits the input as null.. You should set the value of the textarea to the editor value so the browser will submit that value instead of null.. Which can be achieved using this little line: document.getElementsById("msgpost").value = html; See this working JsFiddle I made for you. However you had HTML syntax errors too. The onSubmit attribute should be on the form element not the submit button. And listening to the event is not practical when you can simply call a function when the form submits.. (See the JsFiddle)

Categories : Javascript

eclipse example template with an editor or multi-page editor not running due to following errors
Those are NOT ERRORS. Do not overreact. As it said, it's looking for the environmental variable HOME to have been set, but you can just go fill in information that it would guess from that in the Git preferences. These messages do not appear in newer versions of eGit. And just because you opened a Runtime Workbench does not mean your editor will be automatically opened. If it's not opening when you try to open one of its supported fie types, open a question with the stack traces of its failures.

Categories : Java

Code from ICCV7- AVR displays garbled in text editor?
Probably because your code file is stored in unix format, which uses " " as return at the end of each line. But notepad in windows uses " " as return. So in notepad, all the code may display in a single line. PS: try to tag your Q with other tags. 'icc' here means Intel C++ Compiler.

Categories : Misc

SPSS Python without the awful Code Editor
As suggested ;) May be you can ask to the author's notepad++ python plugin ? Hope this could help

Categories : Python

How to change Visual Studio's (or any other text/code editor) caret size?
The cursor will be bigger as long as it is taller, and it is taller as long as the font size is bigger. So an alternative is to change the font size: Select Options from the Tools menu and in Environment folder, select Fonts and Colors. In Show settings for, select Text Editor. Change the font, size, display item, foreground and background colors.

Categories : Visual Studio

Ace editor doesn't format the data inside the editor div
Ace doesn't support formatting the code, you can either use beautify.js or browsers built-in json formatter var val = editor.session.getValue() var o = JSON.parse(val) // may throw if json is malformed val = JSON.stringify(o, null, 4) // 4 is the indent size editor.session.setValue(val)

Categories : Javascript

Out of sync Python source code from Enthought Canopy Editor?
The np module is not available of the globals surrounding the execution of your code. Make sure you import numpy as np into the module and it will work fine. This is not a Canopy issue but only a scope resolution problem.

Categories : Python

codemirror selected text css does not work (div background color doesn't show in text area)
By making every div in the page position: relative by default, you're going to cause unwanted side effects. In this case, it probably messed up the z-index ordering and thus prevented the divs used to draw the selection being on top of the background. Just do not use blanket rules like that if you want to be able to use widgets like CodeMirror on your page.

Categories : Javascript

Where does Python gets its traceback information from?
You were on the right track. When parsing the code tree, it just runs through PyEval_FrameEx multiple times. In the end, it will call format_exc_check_arg() to format the error, which for me happens at line 2100 in the ceval.c of the Python version 3.3.2 source. format_exc_check_arg() deduces the offensive 'object' (prnt) and calls PyErr_Format in errors.c to properly format the exception string (the exception type and its corresponding string, NAME_ERROR_MSG, were already passed to format_exc_check_arg() from this line 2100. I used simply this code for testing: prnt('Line1') and then run it through a debug build of Python 3.3 I had around. The surrounding code in PyEval_FrameEx is TARGET(LOAD_NAME) w = GETITEM(names, oparg); if ((v = f->f_locals) == NULL) {

Categories : Python

How can I remove library code calls from pytest traceback?
There is a hack: a function defining the local variable __tracebackhide__ will not be shown. Example: def some_support_code(x, y): __tracebackhide__ = True assert x == y

Categories : Python

Any way to save a traceback object in Python
okay so you can use traceback.print_exception(type, value, traceback[, limit[, file]]) and save it in a text or json or you can refer to docs if you find it helpful please mark it correct or upvote thanx..:)

Categories : Python

Python traceback to print stack at the end of class
I guessed it correct - Python TypeError : need more than 0 values to unpack is because of the statement rows, columns = os.popen('stty size', 'r').read().split() The issue here is, the above statement will calculate the buffer size and you are not allowing the script to access the screen buffer by redirecting your output to some file and that too running in background using nohup command. Here is the sample code I have tried -- import os rows, columns = os.popen('stty size', 'r').read().split() print rows print columns There are four different way I ran this script - Output1 [root@localhost]# python test.py 44 168 Output2 [root@localhost]# python test.py > /tmp/out.log [root@localhost]# [root@localhost]# cat /tmp/out.log 44 168 Output3 [root@localhost]# python test.py

Categories : Python

Text view doesn't show any text
This part of your code : txtView.setText(stringHandler.getString()); should be put after the thread finished. thread.run(); <------ Start running thread in background TextView txtView = (TextView)this.findViewById(R.id.textView1); txtView.setText(stringHandler.getString()); // the textView was set without knowing whether the Thread is finished or not. // thus, textView is shown as empty, because stringHandler.getString() still has empty string My suggestion is that you implement it inside an asyncTask, so that you can set the text within onPostExecute() Good luck ^^ EDIT : here's some example AsyncTask private class StringSet extends AsyncTask <Void,Void,Void> { @Override protected void doInBackground(Void... params) { try {

Categories : Android

Mirroring with Ace Editor. How to Remove Text of Mirrored Editor
You can use mirror class from https://github.com/ajaxorg/ace/blob/master/lib/ace/worker/mirror.js

Categories : Javascript

How to set the terminal title to show the current running command while it's running and to show it in brackets once it's finished?
You can (ab)use PS1 by putting the same escape sequence in so that every time the prompt is printed, the title gets updated. export PS1="33]2;[$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//g')]07$PS1" The final PS1 just keeps your old prompt for the actual command line. I don't actually use this, but it should work.

Categories : Linux

How can I use awk or grep to capture an entire Python traceback in a log file?
Here's an AWK script I tried whipping together. awk '{a[NR]=$0}; /KevinCustomError/ {for(i=0; a[NR-i] !~ /Traceback/; i++) {} i++; while(i-- >= 0) {print a[NR-i]}}' logfile Or, in file form. {a[NR] = $0}; { if ($0 ~ /KevinCustomError/) { for (i = 0; a[NR-i] !~ /Traceback/; i++) {} i++ while (i-- >= 0) { print a[NR-i]; } } } Used like: awk -f logscript.awk logfile. Not too familiar with AWK, so any criticism is welcome. Basically, it keeps track of all lines read so far, and just searches backwards to find a "Traceback" token (which you can replace if you'd like), and then prints everything in between (in the correct order).

Categories : Python

Python 3.3:cx_freeze & pyserial: cannot import traceback module
The first two lines are a bug that will be fixed in the next version of cx_Freeze. If you stick an import re in your script, you'll see the correct error message. The last line is your real problem - that means it didn't find the serial module when you froze it. Check where pyserial is installed on your computer.

Categories : Python

Errors in SQLAlchemy's transactions do not return proper traceback (Python 2.7)
The error you're seeing is not (at least directly) caused by SQLAlchemy, but instead is caused by the combination of SQLAlchemy, IPython, and the way you are trying to use transaction. It will go away if you follow the recommended usage of these tools. Disclaimer: The below is not the recommended way to use the scoped session and ZopeTransactionExtension in Pyramids, but I wanted to stick as closely to your provided code as possible. Put this in a file and run it from a virtualenv with SQLAlchemy installed and you will see the correct error message from SQLAlchemy: from sqlalchemy import types from sqlalchemy import create_engine from sqlalchemy.schema import Column from zope.sqlalchemy import ZopeTransactionExtension from sqlalchemy.ext.declarative import declarative_base from sqlal

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.