mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	cloud-setup-databases: modify try-except-finally for < python 2.4
Make cloud-setup-databases compatible to python 2.4 and before.
Add code Prasanna Santhanam <tsp@apache.org>
Partially revert a6dcd7af4962a584f46d9b7271e2c225618624ed which removed
the fix for CLOUDSTACK-199: Fix how cloud-setup-databases parses
  Patch splits by right most @ in supplied argument to get
  user:password and host substrings.
Less than python <2.4 the following is unsupported and produces a
SyntaxError.
    try:
        ...code ...
    except ValueError:
        ...code ...
    finally:
        ...code ...
Workaround is the following
    try:
        try:
            ...code ...
        except ValueError:
            ...code ...
    finally:
Credits to Prasanna Santhanam <tsp@apache.org>
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
			
			
This commit is contained in:
		
							parent
							
								
									7d15dc1d4d
								
							
						
					
					
						commit
						3663af1434
					
				| @ -500,8 +500,16 @@ for example: | |||||||
|                 self.errorAndExit("There are more than one parameters for user:password@hostname (%s)"%self.args) |                 self.errorAndExit("There are more than one parameters for user:password@hostname (%s)"%self.args) | ||||||
| 
 | 
 | ||||||
|             arg = self.args[0] |             arg = self.args[0] | ||||||
|             stuff = arg.split("@", 1) |             try: | ||||||
|             if len(stuff) == 1: stuff.append("localhost") |                 try: | ||||||
|  |                     splitIndex = arg.rindex('@') | ||||||
|  |                 except ValueError: | ||||||
|  |                     # If it failed to find @, use host=localhost | ||||||
|  |                     splitIndex = len(arg) | ||||||
|  |                     arg += "@localhost" | ||||||
|  |             finally: | ||||||
|  |                 stuff = [arg[:splitIndex], arg[splitIndex+1:]] | ||||||
|  | 
 | ||||||
|             self.user,self.password = parseUserAndPassword(stuff[0]) |             self.user,self.password = parseUserAndPassword(stuff[0]) | ||||||
|             self.host,self.port = parseHostInfo(stuff[1]) |             self.host,self.port = parseHostInfo(stuff[1]) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user