forked from Trygve/otime
		
	La til dumping og lasting i event_mgr
This commit is contained in:
		
							parent
							
								
									16a29f7e5d
								
							
						
					
					
						commit
						aee7271cf8
					
				
							
								
								
									
										41
									
								
								event_mgr.py
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								event_mgr.py
									
									
									
									
									
								
							| @ -1,8 +1,10 @@ | |||||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||||
| import otime | import otime | ||||||
| import mtr_log_extractor as mle | #import mtr_log_extractor as mle | ||||||
| import json | import json | ||||||
|  | import pickle | ||||||
| import asyncio | import asyncio | ||||||
|  | import argparse | ||||||
| from difflib import Differ | from difflib import Differ | ||||||
| from watchgod import awatch | from watchgod import awatch | ||||||
| from config import config | from config import config | ||||||
| @ -12,13 +14,40 @@ from rich.console import Console | |||||||
| from rich.columns import Columns | from rich.columns import Columns | ||||||
| from rich.table import Table | from rich.table import Table | ||||||
| 
 | 
 | ||||||
| def start(): | def save(obj): | ||||||
|  |     f = open(config['otime_file'], "wb") | ||||||
|  |     pickle.dump(obj,f) | ||||||
|  |     f.close() | ||||||
|  | 
 | ||||||
|  | def start_parse(): | ||||||
|  |     parser = argparse.ArgumentParser(description='Event manager') | ||||||
|  |     subparsers = parser.add_subparsers(dest='command') | ||||||
|  |     open_event = subparsers.add_parser('continue', help='Open pickle') | ||||||
|  |     open_event.add_argument('--file', help='.otime file') | ||||||
|  | 
 | ||||||
|  |     args = parser.parse_args() | ||||||
|  | 
 | ||||||
|  |     if args.command == 'continue': | ||||||
|  |         print('Later ' + args.file) | ||||||
|  |     else: | ||||||
|  |         print('Starter fra scratch') | ||||||
|  |         start_event() | ||||||
|  | def start_event(): | ||||||
|     global event |     global event | ||||||
|     event = otime.event(0, config['event_name']) |     event = otime.event(0, config['event_name']) | ||||||
|     event.import_ttime_cnf('/home/trygve/Documents/sprintcup040330/sprintcup040330.cnf') |     event.import_ttime_cnf('/home/trygve/Dokumenter/sprintcup040330/sprintcup040330.cnf') | ||||||
|     event.import_ttime_db(config['db_file']) |     event.import_ttime_db(config['db_file']) | ||||||
|     event.import_mtr_file('/home/trygve/Documents/sprintcup040330/sprintcup040330.log') |     event.import_mtr_file('/home/trygve/Dokumenter/sprintcup040330/sprintcup040330.log') | ||||||
|     event.match_runners_cards() |     event.match_runners_cards() | ||||||
|  |     save(event) | ||||||
|  |     global db_file | ||||||
|  |     global db_file_u | ||||||
|  |     db_file = open(config['db_file'], 'r', encoding='latin_1').read().splitlines() | ||||||
|  | def load_event(ot_file): | ||||||
|  |     global event | ||||||
|  |     f = open(ot_file, "r") | ||||||
|  |     event = pickle.load(f) | ||||||
|  |     f.close() | ||||||
|     global db_file |     global db_file | ||||||
|     global db_file_u |     global db_file_u | ||||||
|     db_file = open(config['db_file'], 'r', encoding='latin_1').read().splitlines() |     db_file = open(config['db_file'], 'r', encoding='latin_1').read().splitlines() | ||||||
| @ -82,7 +111,5 @@ async def main(): | |||||||
| 
 | 
 | ||||||
| db_file_u = None | db_file_u = None | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     print(dir(mle)) |     start_parse() | ||||||
|     print('🤔') |  | ||||||
|     start() |  | ||||||
|     asyncio.run(main()) |     asyncio.run(main()) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user