Browse code

* s3cmd: Wrapped all execution in a try/except block to catch all exceptions and ask for a report.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@196 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2008/06/23 12:47:01
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+2008-06-23  Michal Ludvig  <michal@logix.cz>
2
+
3
+	* s3cmd: Wrapped all execution in a try/except block
4
+	  to catch all exceptions and ask for a report.
5
+
1 6
 2008-06-18  Michal Ludvig  <michal@logix.cz>
2 7
 
3 8
 	* S3/PkgInfo.py: Version 0.9.8-rc3
... ...
@@ -13,20 +13,13 @@ import re
13 13
 import errno
14 14
 import pwd, grp
15 15
 import glob
16
+import traceback
16 17
 
17 18
 from copy import copy
18 19
 from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
19 20
 from logging import debug, info, warning, error
20 21
 from distutils.spawn import find_executable
21 22
 
22
-## Our modules
23
-from S3 import PkgInfo
24
-from S3.S3 import *
25
-from S3.Config import Config
26
-from S3.S3Uri import *
27
-from S3 import Utils
28
-from S3.Exceptions import *
29
-
30 23
 def output(message):
31 24
 	print message
32 25
 
... ...
@@ -855,7 +848,7 @@ class MyHelpFormatter(IndentedHelpFormatter):
855 855
 		else:
856 856
 			return ""
857 857
 
858
-if __name__ == '__main__':
858
+def main():
859 859
 	if float("%d.%d" %(sys.version_info[0], sys.version_info[1])) < 2.4:
860 860
 		sys.stderr.write("ERROR: Python 2.4 or higher required, sorry.\n")
861 861
 		sys.exit(1)
... ...
@@ -1025,5 +1018,35 @@ if __name__ == '__main__':
1025 1025
 		error("Parameter problem: " + str(e))
1026 1026
 		sys.exit(1)
1027 1027
 
1028
-	sys.exit(0)
1029
-
1028
+if __name__ == '__main__':
1029
+	try:
1030
+		## Our modules
1031
+		## Keep them in try/except block to 
1032
+		## detect any syntax errors in there
1033
+		from S3 import PkgInfo
1034
+		from S3.S3 import *
1035
+		from S3.Config import Config
1036
+		from S3.S3Uri import *
1037
+		from S3 import Utils
1038
+		from S3.Exceptions import *
1039
+
1040
+		main()
1041
+		sys.exit(0)
1042
+	except Exception, e:
1043
+		sys.stderr.write("""
1044
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1045
+    An unexpected error has occurred.
1046
+  Please report the following lines to:
1047
+  s3tools-general@lists.sourceforge.net
1048
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1049
+
1050
+""")
1051
+		sys.stderr.write(traceback.format_exc(sys.exc_info())+"\n")
1052
+		sys.stderr.write("""
1053
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1054
+    An unexpected error has occurred.
1055
+    Please report the above lines to:
1056
+  s3tools-general@lists.sourceforge.net
1057
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1058
+""")
1059
+		sys.exit(1)