Base class structure for application
This commit is contained in:
		
							
								
								
									
										78
									
								
								trunk/opal.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								trunk/opal.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | |||||||
|  | #!/usr/bin/env python | ||||||
|  | #! coding: utf-8 | ||||||
|  |  | ||||||
|  | import subprocess | ||||||
|  |  | ||||||
|  | #------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | class LocalServer: | ||||||
|  |     """ | ||||||
|  |     """ | ||||||
|  |     def __init__(self): | ||||||
|  |         self.max_run = 2 | ||||||
|  |         self.cur_run = 0 | ||||||
|  |  | ||||||
|  |         self.task_queue = [] | ||||||
|  |  | ||||||
|  |     def GetTaskDescriptionList(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def GetTaskCount(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def GetTask(self, index): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def AddTask(self, *args): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | #------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | class TaskDescription: | ||||||
|  |     """ | ||||||
|  |     Description of the task. Task runs on server. | ||||||
|  |     """ | ||||||
|  |     def __init__(self, server, tid, data): | ||||||
|  |         self.server = server | ||||||
|  |         self.tid = tid | ||||||
|  |         self.data = data | ||||||
|  |  | ||||||
|  | #------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | class ObjectDescription: | ||||||
|  |     def __init__(self, taskdescr, label, data): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | class ObjectDefinition: | ||||||
|  |     def __init__(self, taskdescr, label, data): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | class Parameter: | ||||||
|  |     def __init__(self, paramdescr): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | #------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | class Task: | ||||||
|  |     def __init__(self, server): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def Start(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def Stop(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def Pause(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     def Status(self): | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | #------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | def main(): | ||||||
|  |     pass | ||||||
|  |  | ||||||
|  | if __name__ == '__main__': | ||||||
|  |     main() | ||||||
							
								
								
									
										1
									
								
								trunk/tasks.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								trunk/tasks.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | tasks/task.py | ||||||
| @@ -1,32 +1,56 @@ | |||||||
| { | { | ||||||
|     "title": "Example task", |     "title": "Example task", | ||||||
|  |     "author": "Anton Vakhrushev", | ||||||
|  |  | ||||||
|     "meta": { |     "silent": false, | ||||||
|         "silent": true, |      | ||||||
|     } |     "models": { | ||||||
|  |      | ||||||
|     "models": [ |         "simpleexample": { | ||||||
|         { |          | ||||||
|             "title": "Example model", |             "title": "Simple example model", | ||||||
|  |  | ||||||
|             "data": { |             "data": { | ||||||
|  |              | ||||||
|                 "x": { |                 "x": { | ||||||
|                     "type":     "int", |                     "type":     "int", | ||||||
|                     "default":  10 |                     "default":  10 | ||||||
|  |                 }, | ||||||
|  |                  | ||||||
|  |                 "u": { | ||||||
|  |                     "type":     "double", | ||||||
|  |                     "default":  3.14 | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  |  | ||||||
|             "methods": [ |             "methods": { | ||||||
|                 { |              | ||||||
|                     "title": "default", |                 "default": { | ||||||
|  |                     "title": "Default method", | ||||||
|                     "data": { |                     "data": { | ||||||
|                         "u": { |                         "p": { | ||||||
|                             "type":     "int", |                             "type":     "int", | ||||||
|                             "default":  20 |                             "default":  20 | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             ] |             }, | ||||||
|  |              | ||||||
|  |             "result": { | ||||||
|  |                  | ||||||
|  |                 "data": { | ||||||
|  |                     "sum": "int" | ||||||
|  |                 }, | ||||||
|  |                  | ||||||
|  |                 "table": { | ||||||
|  |                     "head": [ | ||||||
|  |                         { "x" : "int" }, | ||||||
|  |                         { "u" : "double" } | ||||||
|  |                     ] | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     ] |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,18 +5,18 @@ import json | |||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|  |  | ||||||
|     if len(sys.argv) != 2: | ##    if len(sys.argv) != 2: | ||||||
|         print 'Error!' | ##        print 'Error!' | ||||||
|         return | ##        return | ||||||
|  | ## | ||||||
|  | ##    if sys.argv[1] == '-i': | ||||||
|  |     with open('task.js') as f: | ||||||
|  |         d = json.load(f) | ||||||
|  |         print json.dumps(d, indent = 2) | ||||||
|  |  | ||||||
|     if sys.argv[1] == '-i': | ##    elif sys.argv[1] == '-r': | ||||||
|         with open('task.js') as f: | ##        data = raw_input() | ||||||
|             d = json.load(f) | ##        data = json.loads(data) | ||||||
|             print json.dumps(d) |  | ||||||
|  |  | ||||||
|     elif sys.argv[1] == '-r': |  | ||||||
|         data = raw_input() |  | ||||||
|         data = json.loads(data) |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
		Reference in New Issue
	
	Block a user