예제 #1
0
    def convert_wf_file_for_p2_5(origin_file_path, target_file_path):
        """
    This method requires Python >= 2.6.
    It converts a workflow file created using Python >= 2.6 to workflow file
    usable in Python 2.5.
    """
        if sys.version_info[:2] < (2, 6):
            raise Exception("convert_wf_file_for_p2_5 requires Python >= 2.6.")

        try:
            o_file = open(origin_file_path, "r")
            dict_from_json = json.load(o_file)
            workflow = Workflow.from_dict(dict_from_json)
            o_file.close()
            t_file = open(target_file_path, "w")
            pickle.dump(workflow, t_file)
            t_file.close()
        except Exception, e:
            SerializationError("%s: %s" % (type(e), e))
예제 #2
0
    Raises *SerializationError*
    """

        if sys.version_info[:2] >= (2, 6):
            try:
                file = open(file_path, "r")
            except Exception, e:
                raise SerializationError("%s: %s" % (type(e), e))

            workflow = None
            try:
                dict_from_json = json.load(file)
            except ValueError, e:
                pass
            else:
                workflow = Workflow.from_dict(dict_from_json)

            if not workflow:
                file.close()
                file = open(file_path, "r")
                try:
                    workflow = pickle.load(file)
                except Exception, e:
                    raise SerializationError("%s: %s" % (type(e), e))

            try:
                file.close()
            except Exception, e:
                raise SerializationError("%s: %s" % (type(e), e))

        else: