osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Storing the state of script between steps


Good evening.

First of all I would like to apologize for the name of topic. I really didn't know how to name it more correctly.

I mostly develop on Python some automation scripts such as deployment (it's not about fabric and may be not ssh at all), testing something, etc. In this terms I have such abstraction as "step".

Some code:

class IStep(object):
    def run():
        raise NotImplementedError()

And the certain steps:

class DeployStep: ...
class ValidateUSBFlash: ...
class SwitchVersionS: ...

Where I implement run method. 
Then I use some "builder" class which can add steps to internal list and has a method "start" running all step one by one.

And I like this. It's loosely coupled system. It works fine in simple cases. But sometimes some steps have to use the results from previous steps. And now I have problems. Before now I had internal dict in "builder" and named it as "world" and passed it to each run() methods of steps. It worked but I disliked this. 

How would you solve this problem and how would you do it? I understant that it's more architecture specific question, not a python one. 

I bet I wouldn't have asked this if I had worked with some of functional programming languages.