mirror of
				https://github.com/lubuntu-team/metrics.git
				synced 2025-10-31 05:54:03 +00:00 
			
		
		
		
	Add a CLI argument for the location of the DB.
This commit is contained in:
		
							parent
							
								
									b8fbd5ef6c
								
							
						
					
					
						commit
						9068136a8e
					
				
							
								
								
									
										13
									
								
								metrics
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								metrics
									
									
									
									
									
								
							| @ -15,13 +15,14 @@ | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
| 
 | ||||
| import argparse | ||||
| import sqlite3 | ||||
| from modules.jenkins import JenkinsModule | ||||
| 
 | ||||
| ENABLED_MODULES = [JenkinsModule] | ||||
| 
 | ||||
| 
 | ||||
| def sqlite_run(command, db=":memory:", return_output=False): | ||||
| def sqlite_run(command, db, return_output=False): | ||||
|     """Run the given SQLite command on our db | ||||
| 
 | ||||
|     command must be a command that SQLite can run | ||||
| @ -51,9 +52,17 @@ def main(module): | ||||
|     run.append(module.sqlite_setup()) | ||||
|     run.append(module.sqlite_add()) | ||||
|     run.append(module.sqlite_time_range(days=10)) | ||||
|     print(sqlite_run(run, return_output=True)) | ||||
| 
 | ||||
|     # Use --db-location to pass to sqlite | ||||
|     print(sqlite_run(run, db=args.db_location, return_output=True)) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     # Parse CLI arguments | ||||
|     parser = argparse.ArgumentParser() | ||||
|     parser.add_argument("--db-location", type=str, default=":memory:", | ||||
|             help="Specify the location for the SQLite database") | ||||
|     args = parser.parse_args() | ||||
| 
 | ||||
|     for module in ENABLED_MODULES: | ||||
|         main(module) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user