[postr/postr-0-12] Verify when a file does not exist (#576969)
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [postr/postr-0-12] Verify when a file does not exist (#576969)
- Date: Wed, 4 Nov 2009 21:27:58 +0000 (UTC)
commit 4d1f80a49a84e37514362825a791194475e39d92
Author: Germán Póo-Caamaño <gpoo gnome org>
Date: Wed Nov 4 18:24:48 2009 -0300
Verify when a file does not exist (#576969)
When postr is invoked through the shell using a filename as
argument, it does not check if the file exists. Hence, the
program fails.
src/postr.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/postr.py b/src/postr.py
index 5cffc82..08411c1 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -573,7 +573,14 @@ class Postr (UniqueApp):
# TODO: MIME type check
# Check the file size
- filesize = os.path.getsize(filename)
+ try:
+ filesize = os.path.getsize(filename)
+ except os.error:
+ d = ErrorDialog(self.window)
+ d.set_from_string("File at %s does not exist or is currently inaccessible." % filename)
+ d.show_all()
+ return
+
if filesize > 20 * 1024 * 1024:
d = ErrorDialog(self.window)
d.set_from_string("Image %s is too large, images must be no larger than 20MB in size." % filename)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]