Skip to content

Commit

Permalink
Merge pull request #2 from stephenworsley/py3-patch
Browse files Browse the repository at this point in the history
Update for python 3
  • Loading branch information
bjlittle authored Sep 17, 2019
2 parents 00ca6a5 + 045cfd5 commit 9b621b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions kapture/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def main(command_args):
time.sleep(interval)
i += 1
finally:
print 'Killing'
print('Killing')
process.kill()


def usage():
print 'usage: python -m kapture -h'
print('usage: python -m kapture -h')
print(' python -m kapture [-l LOG]'
' (-c command | -m module-name | script) [args]')
exit()
Expand Down
8 changes: 5 additions & 3 deletions kapture/blockview.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def parse_code(log, nlines=10):

def read_log(log_path):
my_locals = {}
execfile(log_path, globals(), my_locals)
with open(log_path) as log_file:
log = log_file.read()
exec(log, globals(), my_locals)
return my_locals['log']


Expand Down Expand Up @@ -117,8 +119,8 @@ def _label(self, all_patches):

def _onclick(self, event, debug=False):
if debug:
print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (
event.button, event.x, event.y, event.xdata, event.ydata)
print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (
event.button, event.x, event.y, event.xdata, event.ydata))

#pop-up style
props = dict(boxstyle='square', facecolor='white')
Expand Down
14 changes: 10 additions & 4 deletions kapture/wrap_user.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import linecache
import os.path
import pdb
Expand All @@ -16,16 +18,20 @@
class IntPdb(pdb.Pdb):
def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None):
pdb.Pdb.__init__(self, completekey, stdin, stdout, skip)
self.nosigint = True
self.allow_kbdint = False
signal.signal(signal.SIGINT, self.sigint_handler)

def sigint_handler(self, signum, frame):
if self.allow_kbdint:
raise KeyboardInterrupt
print >>self.stdout, "\nProgram interrupted. (Use 'cont' to resume)."
self.message("\nProgram interrupted. (Use 'cont' to resume).")
self.set_step()
self.set_trace(frame)

def message(self, msg):
print(msg, file=self.stdout)

def logging_sigint_handler(self, signum, frame):
stack, i = self.get_stack(sys._getframe().f_back, None)
#print >>self.stdout, "------\n", stack, "------\n"
Expand Down Expand Up @@ -169,7 +175,7 @@ def tb_log():


def usage():
print 'usage: wrap_user.py -h'
print('usage: wrap_user.py -h')
print(' wrap_user.py [-l LOG] (-c command | -m module-name | script)'
' [args]')
exit()
Expand All @@ -193,8 +199,8 @@ def usage():
usage()
command = sys.argv[2]
sys.argv = ['-c'] + sys.argv[3:]
exec command in {'__doc__': None, '__name__': '__main__',
'__package__': None}
exec(command, {'__doc__': None, '__name__': '__main__',
'__package__': None})
elif sys.argv[1] == '-m':
if len(sys.argv) < 3:
usage()
Expand Down

0 comments on commit 9b621b9

Please sign in to comment.