101 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			101 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
| # -*- coding: utf-8 -*-
 | |
| 
 | |
| from functions import CamadeusFunctions
 | |
| from config_at import Config
 | |
| from environments import ENVIRONMENTS
 | |
| import sys, getopt
 | |
| 
 | |
| def main():
 | |
|     
 | |
|     def _usage():
 | |
|         print 'cam.py <environment> [create|setup|rollout|update] [<module_name>]'
 | |
|         sys.exit(3)
 | |
|     
 | |
|     argv = sys.argv[1:]
 | |
|     if not len(argv) == 2:
 | |
|         if len(argv) == 3 and argv[1] == 'update': # 'update' requires additional param 'module_name'
 | |
|             pass
 | |
|         else:
 | |
|             _usage()
 | |
|         
 | |
|     cmd = argv[1]
 | |
|     config = Config()
 | |
|     
 | |
|     env = ENVIRONMENTS.get(argv[0],False)
 | |
|     if not env:
 | |
|         _usage()
 | |
|     
 | |
|     instance = CamadeusFunctions(env, config)
 | |
| 
 | |
|     methods = False
 | |
|     
 | |
|     if cmd == 'test':
 | |
|         methods = [
 | |
|             'login',
 | |
|         ]
 | |
|     
 | |
|     if cmd == 'create':
 | |
|         methods = [
 | |
|             'create_db',
 | |
|             'login',
 | |
|             'install_module_sale',
 | |
|             'setup_accounting',
 | |
|             'setup_accounting2',
 | |
|             'set_admin_rights',            
 | |
|         ]
 | |
|     
 | |
|     if cmd == 'setup':
 | |
|         methods = [
 | |
|             'login',
 | |
|             'uninstall_chat',
 | |
|             'install_modules',
 | |
|             'base_config',
 | |
|             'sale_config',
 | |
|             'set_date_format', 
 | |
|             'set_company', 
 | |
|             'set_taxes',    
 | |
|             'set_uom',    
 | |
|             'set_steuerzuordnung',               
 | |
|         ]
 | |
| 
 | |
|     if cmd == 'rollout':
 | |
|         methods = [
 | |
|             'login',
 | |
|             'set_dokumentennummern',        
 | |
|         ]      
 | |
|     
 | |
|     if cmd == 'update':
 | |
|         instance.config.module_name = argv[2]
 | |
|         methods = [
 | |
|             'login',
 | |
|             'update_module',        
 | |
|         ] 
 | |
| 
 | |
|     if cmd == 'update_modules':
 | |
|         methods = [
 | |
|             'login',
 | |
|             'update_modules',     
 | |
|         ]  
 | |
| 
 | |
|     if cmd == 'update_all':
 | |
|         methods = [
 | |
|             'login',
 | |
|             'update_all',        
 | |
|         ]       
 | |
| 
 | |
|     if not methods:
 | |
|         _usage()
 | |
|         
 | |
|     print env
 | |
|                  
 | |
|     for method in methods:      
 | |
|         res = getattr(instance, method)()
 | |
|         print "%s: %s" % (res and "OK     " or "ERROR  ", getattr(instance, method).__doc__)
 | |
|         if not res:
 | |
|             return False
 | |
|     
 | |
|     print "\nAbgeschlossen."
 | |
|     
 | |
| if __name__ == "__main__":
 | |
|     main()    
 |