def generate_state_machine_graph(fsm, fbasename):
    fname = '%s.dot' % fbasename
    fsm.graph = get_all_possible_transitions(fsm.state_graph)
    dotfile(fname, fsm,'','')
    command = 'dot -Tpng %s > %s.png' % (fname, fbasename)
    print command
    add_to_env_variable('PATH',os.path.dirname(os.path.abspath(__file__)))
    os.system(command)
def main():
    (options, args) = GraphicsOptions.parse_args()
    if not args or len(args) > 2: # args must include one FSM module
        GraphicsOptions.print_help()
        exit()
    else:
        fsm = __import__(args[0])
        fbasename = options.output if options.output else args[0]
        fname = '%s.dot' % fbasename
        fsm.graph = get_all_possible_transitions(fsm.state_graph)
        
        dotfile(fname, fsm, options.transitionLabels, options.noStateTooltip)
        command = 'dot -Tpng %s > %s.png' %(fname,fbasename)
        print command
        add_to_env_variable('PATH',os.path.dirname(os.path.abspath(__file__)))
        os.system(command)
        import Image
        im = Image.open('%s.png'%fbasename)
        im.show()