summaryrefslogtreecommitdiff
path: root/lib/utils/io.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-05-01 20:37:51 -0400
committerLex Neva <github.com@lexneva.name>2018-05-01 20:37:51 -0400
commit1b31806423c8fec4040fed6d1009db016860b763 (patch)
tree71ccac169471e76685a7fa0b9910f64555dc73a7 /lib/utils/io.py
parent5b7f14d092456a941dbd189e61ed38d9b16d388b (diff)
rename inkstitch/ to lib/
You can't have a module and a package named the same thing. PyInstaller wants to import the main script as if it were a module, and this doesn't work unless there's no directory of the same name with a __init__.py in it.
Diffstat (limited to 'lib/utils/io.py')
-rw-r--r--lib/utils/io.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/utils/io.py b/lib/utils/io.py
new file mode 100644
index 00000000..e87b9881
--- /dev/null
+++ b/lib/utils/io.py
@@ -0,0 +1,17 @@
+import os
+import sys
+from cStringIO import StringIO
+
+def save_stderr():
+ # GTK likes to spam stderr, which inkscape will show in a dialog.
+ null = open(os.devnull, 'w')
+ sys.stderr_dup = os.dup(sys.stderr.fileno())
+ os.dup2(null.fileno(), 2)
+ sys.stderr_backup = sys.stderr
+ sys.stderr = StringIO()
+
+
+def restore_stderr():
+ os.dup2(sys.stderr_dup, 2)
+ sys.stderr_backup.write(sys.stderr.getvalue())
+ sys.stderr = sys.stderr_backup