Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
ca3aee4e
Commit
ca3aee4e
authored
Mar 13, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16 from Qalthos/develop
Allow pyrasite to run on python3
parents
24b39a21
b98a302e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
pyrasite/ipc.py
pyrasite/ipc.py
+1
-1
pyrasite/payloads/dump_stacks.py
pyrasite/payloads/dump_stacks.py
+2
-1
pyrasite/tools/gui.py
pyrasite/tools/gui.py
+17
-10
No files found.
pyrasite/ipc.py
View file @
ca3aee4e
...
@@ -100,7 +100,7 @@ class PyrasiteIPC(object):
...
@@ -100,7 +100,7 @@ class PyrasiteIPC(object):
(
fd
,
filename
)
=
tempfile
.
mkstemp
()
(
fd
,
filename
)
=
tempfile
.
mkstemp
()
tmp
=
os
.
fdopen
(
fd
,
'w'
)
tmp
=
os
.
fdopen
(
fd
,
'w'
)
path
=
dirname
(
abspath
(
join
(
pyrasite
.
__file__
,
'..'
)))
path
=
dirname
(
abspath
(
join
(
pyrasite
.
__file__
,
'..'
)))
payload
=
file
(
join
(
path
,
'pyrasite'
,
'reverse.py'
))
payload
=
open
(
join
(
path
,
'pyrasite'
,
'reverse.py'
))
tmp
.
write
(
'import sys; sys.path.insert(0, "%s")
\
n
'
%
path
)
tmp
.
write
(
'import sys; sys.path.insert(0, "%s")
\
n
'
%
path
)
for
line
in
payload
.
readlines
():
for
line
in
payload
.
readlines
():
...
...
pyrasite/payloads/dump_stacks.py
View file @
ca3aee4e
from
__future__
import
print_function
import
sys
,
traceback
import
sys
,
traceback
for
thread
,
frame
in
sys
.
_current_frames
().
items
():
for
thread
,
frame
in
sys
.
_current_frames
().
items
():
print
(
'Thread 0x%x'
%
thread
)
print
(
'Thread 0x%x'
%
thread
)
traceback
.
print_stack
(
frame
)
traceback
.
print_stack
(
frame
)
print
print
()
pyrasite/tools/gui.py
View file @
ca3aee4e
...
@@ -32,7 +32,10 @@ import threading
...
@@ -32,7 +32,10 @@ import threading
from
os.path
import
join
,
abspath
,
dirname
from
os.path
import
join
,
abspath
,
dirname
from
random
import
randrange
from
random
import
randrange
from
meliae
import
loader
try
:
from
meliae
import
loader
except
:
pass
from
gi.repository
import
GLib
,
GObject
,
Pango
,
Gtk
,
WebKit
from
gi.repository
import
GLib
,
GObject
,
Pango
,
Gtk
,
WebKit
import
pyrasite
import
pyrasite
...
@@ -79,15 +82,16 @@ class Process(pyrasite.PyrasiteIPC, GObject.GObject):
...
@@ -79,15 +82,16 @@ class Process(pyrasite.PyrasiteIPC, GObject.GObject):
@
property
@
property
def
title
(
self
):
def
title
(
self
):
if
not
getattr
(
self
,
'_title'
,
None
):
if
not
getattr
(
self
,
'_title'
,
None
):
self
.
_title
=
run
(
'ps --no-heading -o cmd= -p %d'
%
self
.
pid
)[
1
]
self
.
_title
=
run
(
'ps --no-heading -o cmd= -p %d'
%
self
.
pid
)[
1
]
\
.
decode
(
'utf-8'
)
return
self
.
_title
return
self
.
_title
class
Process
TreeStore
(
Gtk
.
Tree
Store
):
class
Process
ListStore
(
Gtk
.
List
Store
):
"""This TreeStore finds all running python processes."""
"""This TreeStore finds all running python processes."""
def
__init__
(
self
,
*
args
):
def
__init__
(
self
,
*
args
):
Gtk
.
Tree
Store
.
__init__
(
self
,
str
,
Process
,
Pango
.
Style
)
Gtk
.
List
Store
.
__init__
(
self
,
str
,
Process
,
Pango
.
Style
)
for
pid
in
os
.
listdir
(
'/proc'
):
for
pid
in
os
.
listdir
(
'/proc'
):
try
:
try
:
pid
=
int
(
pid
)
pid
=
int
(
pid
)
...
@@ -95,7 +99,7 @@ class ProcessTreeStore(Gtk.TreeStore):
...
@@ -95,7 +99,7 @@ class ProcessTreeStore(Gtk.TreeStore):
try
:
try
:
maps
=
open
(
'/proc/%d/maps'
%
pid
).
read
().
strip
()
maps
=
open
(
'/proc/%d/maps'
%
pid
).
read
().
strip
()
if
'python'
in
maps
:
if
'python'
in
maps
:
self
.
append
(
None
,
(
proc
.
title
.
strip
(),
proc
,
self
.
append
((
proc
.
title
.
strip
(),
proc
,
Pango
.
Style
.
NORMAL
))
Pango
.
Style
.
NORMAL
))
except
IOError
:
except
IOError
:
pass
pass
...
@@ -450,10 +454,10 @@ class PyrasiteWindow(Gtk.Window):
...
@@ -450,10 +454,10 @@ class PyrasiteWindow(Gtk.Window):
def
inject_js
(
self
):
def
inject_js
(
self
):
log
.
debug
(
"Injecting jQuery"
)
log
.
debug
(
"Injecting jQuery"
)
js
=
join
(
dirname
(
abspath
(
__file__
)),
'js'
)
js
=
join
(
dirname
(
abspath
(
__file__
)),
'js'
)
jquery
=
file
(
join
(
js
,
'jquery-1.7.1.min.js'
))
jquery
=
open
(
join
(
js
,
'jquery-1.7.1.min.js'
))
self
.
info_view
.
execute_script
(
jquery
.
read
())
self
.
info_view
.
execute_script
(
jquery
.
read
())
jquery
.
close
()
jquery
.
close
()
sparkline
=
file
(
join
(
js
,
'jquery.sparkline.min.js'
))
sparkline
=
open
(
join
(
js
,
'jquery.sparkline.min.js'
))
self
.
info_view
.
execute_script
(
sparkline
.
read
())
self
.
info_view
.
execute_script
(
sparkline
.
read
())
sparkline
.
close
()
sparkline
.
close
()
...
@@ -606,6 +610,9 @@ class PyrasiteWindow(Gtk.Window):
...
@@ -606,6 +610,9 @@ class PyrasiteWindow(Gtk.Window):
try
:
try
:
objects
=
loader
.
load
(
'/tmp/%d.objects'
%
proc
.
pid
,
objects
=
loader
.
load
(
'/tmp/%d.objects'
%
proc
.
pid
,
show_prog
=
False
)
show_prog
=
False
)
except
NameError
:
log
.
debug
(
"Meliae not available, continuing..."
)
return
except
:
except
:
log
.
debug
(
"Falling back to slower meliae object dump loader"
)
log
.
debug
(
"Falling back to slower meliae object dump loader"
)
objects
=
loader
.
load
(
'/tmp/%d.objects'
%
proc
.
pid
,
objects
=
loader
.
load
(
'/tmp/%d.objects'
%
proc
.
pid
,
...
@@ -638,7 +645,7 @@ class PyrasiteWindow(Gtk.Window):
...
@@ -638,7 +645,7 @@ class PyrasiteWindow(Gtk.Window):
payloads
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
payloads
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
pyrasite
.
__file__
)),
'payloads'
)
pyrasite
.
__file__
)),
'payloads'
)
dump_stacks
=
os
.
path
.
join
(
payloads
,
'dump_stacks.py'
)
dump_stacks
=
os
.
path
.
join
(
payloads
,
'dump_stacks.py'
)
code
=
proc
.
cmd
(
file
(
dump_stacks
).
read
())
code
=
proc
.
cmd
(
open
(
dump_stacks
).
read
())
self
.
update_progress
(
0.6
)
self
.
update_progress
(
0.6
)
self
.
source_buffer
.
set_text
(
''
)
self
.
source_buffer
.
set_text
(
''
)
...
@@ -664,7 +671,7 @@ class PyrasiteWindow(Gtk.Window):
...
@@ -664,7 +671,7 @@ class PyrasiteWindow(Gtk.Window):
store
.
set_value
(
iter
,
2
,
Pango
.
Style
.
NORMAL
)
store
.
set_value
(
iter
,
2
,
Pango
.
Style
.
NORMAL
)
def
create_tree
(
self
):
def
create_tree
(
self
):
tree_store
=
Process
Tree
Store
()
tree_store
=
Process
List
Store
()
tree_view
=
Gtk
.
TreeView
()
tree_view
=
Gtk
.
TreeView
()
self
.
tree_view
=
tree_view
self
.
tree_view
=
tree_view
tree_view
.
set_model
(
tree_store
)
tree_view
.
set_model
(
tree_store
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment