Python: Catching Traceback.

For PyQT Development, i have noticed that when or if the application i am working on is crashing i never see the traceback. Using Pycharm IDE i can only get it to display the traceback if i run my app in Debug Mode, which is not always what i want for various reasons. So, after some googling around and experimenting, i have learned a way to properly display and also log (may be even to a file) the crash-reports as the happen.

Here is how to get this setup.

Assuming you are working with MVC type model (can be even super simple), in your ‘main’ module that fires off all other packages, you must defined a custom function, that will be used to handle the logging. Here is how i have it in a simple case:

import logging
import traceback
import sys

def crash_report(exctype, value, tb):
 """Custom Crash-Handler"""
 logger = logging.getLogger('myapp.crash_report')
 logger.critical("\n--- Logging error ---\n"
 "Message: My-App has experienced an unrecoverable error.\n"
 "Traceback: (Most recent call last)"

Now, we need to override default python function, and give it our new function to use instead, we can simply do it like so:

sys.excepthook = crash_report

You only need to do it once, at the top level, and every time your application goes through some hard times, you will know why.

we can test it like this:

test = "mememe"
num = int(test)

Some code sample for 2d-point

import cv2
import numpy as np
from PIL import Image, ImageDraw

class Point2D(object):
	def __init__(self, x=0., y=0.):
		self.x = x
		self.y = y

	def x(self):
		return self._x

	def x(self, value):
		self._x = value

	def y(self):
		return self._y

	def y(self, value):
		self._y = value

	def __str__(self):
		return '(X:{}, Y:{})'.format(self.x, self.y)

	def __repr__(self):
		return 'Point({}, {})'.format(self.x, self.y)

	def slope(self, target):
		#k = y2-y1/x2-x1
			return (target.y - self.y) / (target.x - self.x)
		except ZeroDivisionError:
			return None

	def y_segment(self, target):
		k = self.slope(target)
		return self.y - k * self.x

	def line_function(self, target):

		k = self.slope(target)
		b = self.y_segment(target)
		if k:
			# y = k*x+b
			def fn(x):
				return k * x + b

			# if k=None -> k is infinity
			def fn(x):

p1 = Point2D(1., -18.9)
p2 = Point2D(1., -17.)
p3 = Point2D(1., -13.)
fn_x = p1.line_function(p2)

if p3.y == fn_x(p3.x):
	print('Belongs to line')


I love working with PyCharm IDE. One time few of my friends had suggested this IDE for work, and after getting used the configuration and setup i now cannot imagine working with something else…. However, for long time i had been having hard time setting up a production environment on my machines, due to long and exhausting process of conflagration… Until recently when on one of the tech-art forums i came about one post, linking to a wonderful plugin developed by Chris Cunningham. Thank you!

MayaCharm – is a great plugin for PyCharm IDE.

Python and VENV

When working with virtual env for python, some modules may not be found. I had ran into a problem where i was using a simple UI created using standard TkInter module, but when i tested my script on various python versions it gave me an error, reporting that Tcl was not properly installed. A solution for this was to update the  “activate”or”Activate.bat” for windows file and add “set "TCL_LIBRARY=PATH_TO_TCL" " located in the original install of the python version i was using.

Similar workflow should be used to help set additional pointer to other missing components.

referencing from Stackoverflow

Windows 10 + Cortana search problem

This new laptop i have is showing off its great potential for mobile work, including heavy 3D!

Now, i had ran into one problem with Windows10, which is super annoying…. When you press the” Windows button” and type the name of the program you want to run, search does not show any results. After a few minutes of google, i found solution on the

Simple POWERSHELL command:

Get-AppXPackage -Name Microsoft.Windows.Cortana | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}


Logarithmic spiral – 3DS MaxScript

Okay, so i remember getting deeper into this spiral RnD, and had been working on understanding different types of spirals.

Here is a result of my RnD that i did a while ago, using MaxScript:

--Basic start point,
pCenter = Dummy()
pCenter.scale = point3 0.05 0.05 0.05
pCenter.pos = point3 0 0 0
centerX = pCenter.position.x
centerY = pCenter.position.y
centerZ = pcenter.position.z

Thank you:

HINT: convert to and from

radians = degrees * (pi/180)

degrees = radians * (180/pi)


--initial vars from formula:r = ae^{b*theta}\,
a = 0.0  -- controls the starting angle
b = 0.1  -- controls how tightly the spiral is wound.
t = 0.0  -- this is start angle

theta = t * (pi/180)

across = atan(1/b)
end = 180.0 -- specify max degrees

for theta = 0 to end do 
	r = pow e (b*theta)
	r *=0.01
	print r
	x = centerX + cos(theta) * r
	y = centerY + sin(theta) * r
	pt = Dummy()
	pt.scale = point3 0.1 0.1 0.1
	pt.pos = point3 x y centerZ