This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import threading | |
def child(): | |
print "Child id: %d" % os.getpid() | |
while True: | |
print("Child alive") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import threading | |
def child(): | |
print "Child id: %d" % os.getpid() | |
while True: | |
print("Child alive") | |
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def norm_case(filename): | |
filename = os_normcase(filename) | |
if IS_PY3K: | |
return filename | |
enc = sys.getfilesystemencoding() | |
return filename.decode(enc).lower().encode(enc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from _pydev_bundle._pydev_filesystem_encoding import getfilesystemencoding | |
def norm_case(filename): | |
filename = os_normcase(filename) | |
enc = getfilesystemencoding() | |
if IS_PY3K or enc == 'UTF-8': | |
return filename | |
res = filename.decode(enc).lower().encode(enc) | |
print(filename, res, enc) | |
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2 import Environment | |
from jinja2.loaders import FileSystemLoader | |
if __name__ == '__main__': | |
context = {'seq': [2, 3, 4], 'name': 'Armin'} | |
env = Environment(loader=FileSystemLoader('templates')) | |
tmpl = env.get_template('test3.html') | |
answer = tmpl.render(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title>Test 2</title> | |
<body> | |
Hello {{ name }}! | |
{% macro fun() %} | |
{% set res = 9 %} | |
{{ res }} | |
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def str_to_args_windows(args): | |
# see http:#msdn.microsoft.com/en-us/library/a1y7w461.aspx | |
result = [] | |
DEFAULT = 0 | |
ARG = 1 | |
IN_DOUBLE_QUOTE = 2 | |
state = DEFAULT | |
backslashes = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Stack tracer for multi-threaded applications. | |
Usage: | |
import stacktracer | |
stacktracer.start_trace("trace.html",interval=5,auto=True) # Set auto flag to always update file! | |
.... | |
stacktracer.stop_trace() | |
taken from the http://code.activestate.com/recipes/577334-how-to-debug-deadlocked-multi-threaded-programs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# License: EPL | |
import os | |
import sys | |
import traceback | |
try: | |
xrange | |
except: | |
xrange = range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
class Debugger(object): | |
def __init__(self): | |
breakpoints = {} | |
def call_trace(self): | |
frame = sys._getframe(1) | |
print(frame.f_code.co_filename, frame.f_lineno, frame.f_locals) |
OlderNewer