Browse code

- Change all "exit()" calls to "sys.exit()" and allow for python 2.4

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

Michal Ludvig authored on 2007/02/07 12:06:38
Showing 1 changed files
... ...
@@ -118,8 +118,8 @@ def cmd_object_put(args):
118 118
 		error("be a S3 URI specifying just the bucket name")
119 119
 		error("WITHOUT object name!")
120 120
 		error("Alternatively use --force argument and the specified")
121
-		error("object name will be prefixed to all stored filanames.")
122
-		exit(1)
121
+		error("object name will be prefixed to all stored filenames.")
122
+		sys.exit(1)
123 123
 
124 124
 	for file in files:
125 125
 		uri_arg_final = str(uri)
... ...
@@ -201,7 +201,7 @@ def run_configure(config_file):
201 201
 	
202 202
 	except IOError, e:
203 203
 		error("Writing config file failed: %s: %s" % (config_file, e.strerror))
204
-		exit(1)
204
+		sys.exit(1)
205 205
 
206 206
 commands = {}
207 207
 commands_list = [
... ...
@@ -238,9 +238,9 @@ class MyHelpFormatter(IndentedHelpFormatter):
238 238
 			return ""
239 239
 
240 240
 if __name__ == '__main__':
241
-	if float("%d.%d" %(sys.version_info[0], sys.version_info[1])) < 2.5:
242
-		sys.stderr.write("ERROR: Python 2.5 or higher required, sorry.\n")
243
-		exit(1)
241
+	if float("%d.%d" %(sys.version_info[0], sys.version_info[1])) < 2.4:
242
+		sys.stderr.write("ERROR: Python 2.4 or higher required, sorry.\n")
243
+		sys.exit(1)
244 244
 
245 245
 	## Populate "commands" from "commands_list"
246 246
 	for cmd in commands_list:
... ...
@@ -288,7 +288,7 @@ if __name__ == '__main__':
288 288
 			error("%s: %s"  % (options.config, e.strerror))
289 289
 			error("Configuration file not available.")
290 290
 			error("Consider using --configure parameter to create one.")
291
-			exit(1)
291
+			sys.exit(1)
292 292
 
293 293
 	## And again some logging level adjustments
294 294
 	## according to configfile and command line parameters
... ...
@@ -308,15 +308,15 @@ if __name__ == '__main__':
308 308
 
309 309
 	if options.dump_config:
310 310
 		cfg.dump_config(sys.stdout)
311
-		exit(0)
311
+		sys.exit(0)
312 312
 
313 313
 	if options.run_configure:
314 314
 		run_configure(options.config)
315
-		exit(0)
315
+		sys.exit(0)
316 316
 
317 317
 	if len(args) < 1:
318 318
 		error("Missing command. Please run with --help for more information.")
319
-		exit(1)
319
+		sys.exit(1)
320 320
 
321 321
 	command = args.pop(0)
322 322
 	try:
... ...
@@ -327,11 +327,11 @@ if __name__ == '__main__':
327 327
 		cmd_func = commands[command]["func"]
328 328
 	except KeyError, e:
329 329
 		error("Invalid command: %s" % e)
330
-		exit(1)
330
+		sys.exit(1)
331 331
 
332 332
 	if len(args) < commands[command]["argc"]:
333 333
 		error("Not enough paramters for command '%s'" % command)
334
-		exit(1)
334
+		sys.exit(1)
335 335
 
336 336
 	try:
337 337
 		cmd_func(args)