#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  1 21:16:01 2017

@author: lukanen
"""

class BaseTask(object):
    
    def __init__(self):
        self.node_interface = None
        
        self.file_name = None
        self.function_name = None
        
        self.arguements = ()
        self.return_value = None
        
        self.cluster_trace = []
        self.finished = False
        
    def convert_obj_to_dictionary(self, obj):
        if (obj!=None):
            return obj.convert_to_dictionary()
        return None
    
    def convert_to_dictionary(self):
        dictionary = {
                'node_interface': self.convert_obj_to_dictionary(self.node_interface),
                'file_name': self.file_name,
                'function_name': self.function_name,
                'arguements': self.arguements,
                'return_value': self.return_value,
                'cluster_trace': [self.convert_obj_to_dictionary(node) for node in self.cluster_trace],
                'self.finished': self.finished
                }
        return dictionary
    
@@ -101,16 +101,60 @@
 anen%0A%22%22%22
+%0Aimport NodeInterface%0Aimport pickleFunctions
 %0A%0Aclass 
@@ -1139,12 +1139,1237 @@
 tionary%0A    
+%0A    def create_from_dictionary(self, dictionary):%0A        if ('node_interface' in dictionary):%0A            self.node_interface = NodeInterface.NodeInterface()%0A            self.node_interface.create_from_dictionary(dictionary%5B'node_interface'%5D)%0A        else:%0A            self.node_interface = None%0A            %0A        self.file_name = dictionary%5B'file_name'%5D if 'file_name' in dictionary else ''%0A        self.function_name = dictionary%5B'function_name'%5D if 'function_name' in dictionary else ''%0A        %0A        self.arguements = pickleFunctions.unPickle(dictionary%5B'arguements'%5D.encode('latin1')) if 'arguements' in dictionary else ()%0A        self.return_value = pickleFunctions.unPickle(dictionary%5B'return_value'%5D.encode('latin1')) if 'return_value' in dictionary else ''%0A        %0A        if ('cluster_trace' in dictionary):%0A            for node_dict in dictionary%5B'cluster_trace'%5D:%0A                node = NodeInterface.NodeInterface()%0A                node.create_from_dictionary(node_dict)%0A                self.cluster_trace.append(node)%0A        else:%0A            self.cluster_trace = %5B%5D%0A            %0A        self.finished = dictionary%5B'finished'%5D if 'finished' in dictionary else False%0A        %0A        %0A        %0A        

create tasks from dictionary