mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	Make use of FDroidException in the main fdroid script
This should improve the output shown when exceptions are found
This commit is contained in:
		
							parent
							
								
									d9d5f30d7b
								
							
						
					
					
						commit
						73142c740b
					
				
					 2 changed files with 14 additions and 5 deletions
				
			
		
							
								
								
									
										13
									
								
								fdroid
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								fdroid
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -21,6 +21,8 @@
 | 
			
		|||
import sys
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from fdroidserver.common import FDroidException
 | 
			
		||||
 | 
			
		||||
commands = {
 | 
			
		||||
    "build": "Build a package from source",
 | 
			
		||||
    "init": "Quickly start a new repository",
 | 
			
		||||
| 
						 | 
				
			
			@ -83,14 +85,21 @@ def main():
 | 
			
		|||
 | 
			
		||||
    del sys.argv[1]
 | 
			
		||||
    mod = __import__('fdroidserver.' + command, None, None, [command])
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        mod.main()
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
    # These are ours, contain a proper message and are "expected"
 | 
			
		||||
    except FDroidException, e:
 | 
			
		||||
        if verbose:
 | 
			
		||||
            raise
 | 
			
		||||
        else:
 | 
			
		||||
            print str(e)
 | 
			
		||||
            logging.critical(str(e))
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    # These should only be unexpected crashes due to bugs in the code
 | 
			
		||||
    # str(e) often doesn't contain a reason, so just show the backtrace
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
        logging.critical("Unknown exception found!")
 | 
			
		||||
        raise
 | 
			
		||||
    sys.exit(0)
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue