Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
vmj-qt
Commits
ea5a86b9
Commit
ea5a86b9
authored
Dec 16, 2016
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved the diverted stdout handler
parent
e1e5ad6a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
blink
bin/blink
+13
-11
__init__.py
blink/__init__.py
+2
-2
No files found.
bin/blink
View file @
ea5a86b9
...
@@ -31,9 +31,9 @@ if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_
...
@@ -31,9 +31,9 @@ if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_
if
frozen
:
if
frozen
:
from
StringIO
import
StringIO
from
StringIO
import
StringIO
class
Fake
Stdout
(
object
):
class
Diverted
Stdout
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_
io
=
StringIO
()
self
.
_
output
=
StringIO
()
self
.
_file
=
None
self
.
_file
=
None
@
property
@
property
...
@@ -41,18 +41,20 @@ if frozen:
...
@@ -41,18 +41,20 @@ if frozen:
return
self
.
_file
return
self
.
_file
@
file
.
setter
@
file
.
setter
def
file
(
self
,
f
):
def
file
(
self
,
path
):
f
.
write
(
self
.
_io
.
getvalue
())
if
self
.
_file
is
not
None
:
self
.
_io
.
close
()
raise
RuntimeError
(
"output file was already set to: {0._file!r}"
.
format
(
self
))
self
.
_file
=
f
f
=
open
(
path
,
'a'
,
0
)
# noinspection PyUnresolvedReferences
f
.
write
(
self
.
_output
.
getvalue
())
self
.
_output
.
close
()
self
.
_output
=
f
self
.
_file
=
path
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
if
self
.
_file
is
not
None
:
return
getattr
(
self
.
_output
,
name
)
return
getattr
(
self
.
_file
,
name
)
else
:
return
getattr
(
self
.
_io
,
name
)
sys
.
stdout
=
sys
.
stderr
=
Fake
Stdout
()
sys
.
stdout
=
sys
.
stderr
=
Diverted
Stdout
()
# Import log last so the created StreamHandler instances have references
# Import log last so the created StreamHandler instances have references
...
...
blink/__init__.py
View file @
ea5a86b9
...
@@ -45,10 +45,10 @@ __all__ = ['Blink']
...
@@ -45,10 +45,10 @@ __all__ = ['Blink']
if
hasattr
(
sys
,
'frozen'
):
if
hasattr
(
sys
,
'frozen'
):
makedirs
(
ApplicationData
.
get
(
'logs'
))
sys
.
stdout
.
file
=
open
(
ApplicationData
.
get
(
'logs/output.log'
),
'a'
,
0
)
import
httplib2
import
httplib2
httplib2
.
CA_CERTS
=
os
.
environ
[
'SSL_CERT_FILE'
]
=
Resources
.
get
(
'tls/cacerts.pem'
)
httplib2
.
CA_CERTS
=
os
.
environ
[
'SSL_CERT_FILE'
]
=
Resources
.
get
(
'tls/cacerts.pem'
)
makedirs
(
ApplicationData
.
get
(
'logs'
))
sys
.
stdout
.
file
=
ApplicationData
.
get
(
'logs/output.log'
)
class
IPAddressMonitor
(
object
):
class
IPAddressMonitor
(
object
):
...
...
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