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
80330711
Commit
80330711
authored
Feb 11, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup a proper logger
parent
762525a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
pyrasite/main.py
pyrasite/main.py
+6
-3
pyrasite/tools/gui.py
pyrasite/tools/gui.py
+9
-8
No files found.
pyrasite/main.py
View file @
80330711
...
...
@@ -19,6 +19,7 @@ import os, sys
import
argparse
from
inject
import
CodeInjector
from
utils
import
setup_logger
def
main
():
parser
=
argparse
.
ArgumentParser
(
...
...
@@ -40,19 +41,21 @@ def main():
args
=
parser
.
parse_args
()
log
=
setup_logger
()
try
:
pid
=
int
(
args
.
pid
)
except
ValueError
:
print
"Error: The first argument must be a pid"
log
.
error
(
"Error: The first argument must be a pid"
)
sys
.
exit
(
2
)
filename
=
args
.
filename
if
filename
:
if
not
os
.
path
.
exists
(
filename
):
print
"Error: Invalid path or file doesn't exist"
log
.
error
(
"Error: Invalid path or file doesn't exist"
)
sys
.
exit
(
3
)
else
:
print
"Error: The second argument must be a filename"
log
.
error
(
"Error: The second argument must be a filename"
)
sys
.
exit
(
4
)
injector
=
CodeInjector
(
pid
,
verbose
=
args
.
verbose
,
gdb_prefix
=
args
.
gdb_prefix
)
...
...
pyrasite/tools/gui.py
View file @
80330711
...
...
@@ -20,6 +20,7 @@ import os
import
sys
import
time
import
psutil
import
logging
import
keyword
import
tokenize
...
...
@@ -57,7 +58,7 @@ class Process(GObject.GObject):
return
self
.
ipc
.
cmd
(
cmd
,
*
args
,
**
kw
)
def
close
(
self
):
print
"Closing %r"
%
self
log
.
debug
(
"Closing %r"
%
self
)
self
.
ipc
.
close
()
def
__repr__
(
self
):
...
...
@@ -257,16 +258,15 @@ class PyrasiteWindow(Gtk.Window):
def
switch_page
(
self
,
notebook
,
page
,
pagenum
):
name
=
self
.
notebook
.
get_tab_label
(
self
.
notebook
.
get_nth_page
(
pagenum
))
if
name
.
get_text
()
==
'Shell'
:
# FIXME:
self
.
shell_prompt
.
grab_focus
()
def
run_shell_command
(
self
,
widget
):
cmd
=
self
.
shell_prompt
.
get_text
()
end
=
self
.
shell_buffer
.
get_end_iter
()
self
.
shell_buffer
.
insert
(
end
,
'
\
n
>>> %s
\
n
'
%
cmd
)
print
"run_shell_command(%r)"
%
cmd
log
.
debug
(
"run_shell_command(%r)"
%
cmd
)
output
=
self
.
proc
.
cmd
(
cmd
)
print
repr
(
output
)
log
.
debug
(
repr
(
output
)
)
self
.
shell_buffer
.
insert
(
end
,
output
)
self
.
shell_prompt
.
set_text
(
''
)
...
...
@@ -283,7 +283,7 @@ class PyrasiteWindow(Gtk.Window):
self
.
obj_buffer
.
set_text
(
value
)
def
obj_row_activated_cb
(
self
,
*
args
,
**
kw
):
print
"obj_row_activated_cb(%s, %s)"
%
(
args
,
kw
)
log
.
debug
(
"obj_row_activated_cb(%s, %s)"
%
(
args
,
kw
)
)
def
generate_description
(
self
,
proc
,
title
):
d
=
''
...
...
@@ -607,7 +607,7 @@ class PyrasiteWindow(Gtk.Window):
def
close
(
self
):
self
.
progress
.
show
()
self
.
update_progress
(
None
,
"Shutting down"
)
print
"Closing %r"
%
self
log
.
debug
(
"Closing %r"
%
self
)
for
process
in
self
.
processes
.
values
():
self
.
update_progress
(
None
)
process
.
close
()
...
...
@@ -633,7 +633,8 @@ def main():
if
__name__
==
'__main__'
:
print
"Loading Pyrasite..."
main
()
setup_logger
(
verbose
=
'-v'
in
sys
.
argv
)
log
.
info
(
"Loading Pyrasite..."
)
sys
.
exit
(
main
())
# vim: tabstop=4 shiftwidth=4 expandtab
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