Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
ac988740
Commit
ac988740
authored
Aug 02, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling nested @mute decorators.
parent
a2201f96
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
threads.py
routersploit/threads.py
+2
-1
utils.py
routersploit/utils.py
+8
-4
No files found.
routersploit/threads.py
View file @
ac988740
...
@@ -13,6 +13,8 @@ except ImportError:
...
@@ -13,6 +13,8 @@ except ImportError:
data_queue
=
queue
.
Queue
()
data_queue
=
queue
.
Queue
()
printer_queue
=
queue
.
Queue
()
printer_queue
=
queue
.
Queue
()
thread_output_stream
=
WeakKeyDictionary
()
class
DataProducerThread
(
threading
.
Thread
):
class
DataProducerThread
(
threading
.
Thread
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
...
@@ -42,7 +44,6 @@ class PrinterThread(threading.Thread):
...
@@ -42,7 +44,6 @@ class PrinterThread(threading.Thread):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
PrinterThread
,
self
)
.
__init__
()
super
(
PrinterThread
,
self
)
.
__init__
()
self
.
daemon
=
True
self
.
daemon
=
True
self
.
std_out
=
WeakKeyDictionary
()
def
run
(
self
):
def
run
(
self
):
while
True
:
while
True
:
...
...
routersploit/utils.py
View file @
ac988740
...
@@ -18,7 +18,7 @@ from abc import ABCMeta, abstractmethod
...
@@ -18,7 +18,7 @@ from abc import ABCMeta, abstractmethod
import
requests
import
requests
from
.threads
import
printer_queue
from
.threads
import
printer_queue
,
thread_output_stream
from
.exceptions
import
RoutersploitException
from
.exceptions
import
RoutersploitException
from
.
import
modules
as
rsf_modules
from
.
import
modules
as
rsf_modules
...
@@ -164,11 +164,11 @@ def mute(fn):
...
@@ -164,11 +164,11 @@ def mute(fn):
""" Suppress function from printing to sys.stdout """
""" Suppress function from printing to sys.stdout """
@wraps
(
fn
)
@wraps
(
fn
)
def
wrapper
(
self
,
*
args
,
**
kwargs
):
def
wrapper
(
self
,
*
args
,
**
kwargs
):
sys
.
stdout
=
DummyFile
(
)
thread_output_stream
.
setdefault
(
threading
.
current_thread
(),
[])
.
append
(
DummyFile
()
)
try
:
try
:
return
fn
(
self
,
*
args
,
**
kwargs
)
return
fn
(
self
,
*
args
,
**
kwargs
)
finally
:
finally
:
sys
.
stdout
=
sys
.
__stdout__
thread_output_stream
[
threading
.
current_thread
()]
.
pop
()
return
wrapper
return
wrapper
...
@@ -228,10 +228,14 @@ def __cprint(*args, **kwargs):
...
@@ -228,10 +228,14 @@ def __cprint(*args, **kwargs):
return
return
color
=
kwargs
.
get
(
'color'
,
None
)
color
=
kwargs
.
get
(
'color'
,
None
)
file_
=
kwargs
.
get
(
'file'
,
sys
.
stdout
)
sep
=
kwargs
.
get
(
'sep'
,
' '
)
sep
=
kwargs
.
get
(
'sep'
,
' '
)
end
=
kwargs
.
get
(
'end'
,
'
\n
'
)
end
=
kwargs
.
get
(
'end'
,
'
\n
'
)
thread
=
threading
.
current_thread
()
thread
=
threading
.
current_thread
()
try
:
file_
=
thread_output_stream
.
get
(
thread
,
())[
-
1
]
except
IndexError
:
file_
=
kwargs
.
get
(
'file'
,
sys
.
stdout
)
if
color
:
if
color
:
printer_queue
.
put
(
PrintResource
(
content
=
'
\033
[{}m'
.
format
(
colors
[
color
]),
end
=
''
,
file
=
file_
,
sep
=
sep
,
thread
=
thread
))
printer_queue
.
put
(
PrintResource
(
content
=
'
\033
[{}m'
.
format
(
colors
[
color
]),
end
=
''
,
file
=
file_
,
sep
=
sep
,
thread
=
thread
))
printer_queue
.
put
(
PrintResource
(
content
=
args
,
end
=
''
,
file
=
file_
,
sep
=
sep
,
thread
=
thread
))
# TODO printing text that starts from newline
printer_queue
.
put
(
PrintResource
(
content
=
args
,
end
=
''
,
file
=
file_
,
sep
=
sep
,
thread
=
thread
))
# TODO printing text that starts from newline
...
...
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