Ejemplo n.º 1
0
 def __init__(self, **machine_configs):
     self.board = None
     self.machine = GraphMachine(model=self, **machine_configs)
     self.history = []
     self.user1 = None
     self.user2 = None
     self.undouser = None
Ejemplo n.º 2
0
 def __init__(self,
              states=[],
              transitions=[],
              initial='',
              title="",
              graph=False):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self.my_owner = None
     self._force_kill = threading.Event()
     self._exit_code = 0
     self._states = states
     self._transitions = transitions
     if not graph:
         self._Fsm = Machine(model=self,
                             states=states,
                             transitions=transitions,
                             initial=initial)
     else:
         self._Fsm = GraphMachine(model=self,
                                  states=states,
                                  transitions=transitions,
                                  initial=initial,
                                  title=title,
                                  show_conditions=True)
Ejemplo n.º 3
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.account = ""
     self.nickname = ""
     self.newPassword = ""
     self.viewPos = 0
     self.privateViewPos = 0
Ejemplo n.º 4
0
    def __init__(self, name):
        self.name = name

        # initialize the state machine
        self.machine = GraphMachine(model=self, states=self.states, initial="sleeping")

        # add transitions
        self.machine.add_transition(
            trigger="wake_up", source="sleeping", dest="waiting"
        )
        self.machine.add_transition(
            trigger="start", source="waiting", dest="running", before="display_message"
        )
        self.machine.add_transition(
            trigger="interrupt", source="*", dest="terminated", after="display_warning"
        )
        self.machine.add_transition(
            trigger="random_trigger",
            source="*",
            dest="terminated",
            conditions=["is_valid"],
        )

        # create image of the state machine (requires GraphViz and pygraphviz)
        self.graph.draw("my_state_diagram.png", prog="dot")
Ejemplo n.º 5
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.user = User()
     self.bus_info = BusInfo()
     self.train_info = TrainInfo()
     self.hsr_info = HsrInfo()
     self.prev = None
Ejemplo n.º 6
0
    def __init__(self, name):
        self.name = name

        # initialize the state machine
        self.machine = GraphMachine(model=self,
                                    states=self.states,
                                    initial='sleeping')

        # add transitions
        self.machine.add_transition(trigger='wake_up',
                                    source='sleeping',
                                    dest='waiting')
        self.machine.add_transition(trigger='start',
                                    source='waiting',
                                    dest='running',
                                    before='display_message')
        self.machine.add_transition(trigger='interrupt',
                                    source='*',
                                    dest='terminated',
                                    after='display_warning')
        self.machine.add_transition(trigger='random_trigger',
                                    source='*',
                                    dest='terminated',
                                    conditions=['is_valid'])

        # create image of the state machine (requires GraphViz and pygraphviz)
        self.graph.draw('my_state_diagram.png', prog='dot')
Ejemplo n.º 7
0
    def __init__(self,
                 states=[],
                 transitions=[],
                 initial='',
                 graph=False,
                 title=''):
        AbstractBehaviour.__init__(self)
        threading.Thread.__init__(self)
        self.setDaemon(False)
        self.my_owner = None
        self._force_kill = threading.Event()
        self.name = self.__class__.__name__
        self._exit_code = 0
        self._states = states
        self._transitions = transitions
        if not graph:
            self._fsm = Machine(model=self,
                                states=states,
                                transitions=transitions,
                                initial=initial)
        else:
            self._fsm = GraphMachine(model=self,
                                     states=states,
                                     transitions=transitions,
                                     initial=initial,
                                     title='title',
                                     show_conditions=True)

        logging.info('Behavior -FSM.{}- created successfully!'.format(
            self.__class__.__name__))
        self.fsmActive = True
Ejemplo n.º 8
0
 def __init__(self):
     self.machine = GraphMachine(
         model=self,
         states=['user', 'state1', 'state2', 'state3', "state4"],
         transitions=[{
             'trigger': 'advance',
             'source': 'user',
             'dest': 'state1',
             'conditions': 'is_going_to_state1'
         }, {
             'trigger': 'advance',
             'source': 'user',
             'dest': 'state2',
             'conditions': 'is_going_to_state2'
         }, {
             'trigger': 'advance',
             'source': 'user',
             'dest': 'state3',
             'conditions': 'is_going_to_state3'
         }, {
             'trigger': 'advance',
             'source': 'state3',
             'dest': 'state4',
             'conditions': 'is_going_to_state4'
         }, {
             'trigger': 'go_back',
             'source': ['state1', 'state2', 'state4'],
             'dest': 'user'
         }],
         initial='user',
         auto_transitions=False,
         show_conditions=True)
Ejemplo n.º 9
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.start_location = ""
     self.end_location = ""
     self.highway_id = -1
     self.direction = ""
     self.highway_info = []
Ejemplo n.º 10
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(
         model = self,
         **machine_configs
     )
     self.total = 0
     self.temp = 0
Ejemplo n.º 11
0
    def __init__(self, **machine_configs):
        self.machine = GraphMachine(
            model = self,
            **machine_configs
        )

        global url, chose
        url = ''
        chose = 1
Ejemplo n.º 12
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(
         model = self,
         **machine_configs
     )
     self.image = 0
     self.peace_con = 0 
     self.destroy_con = 0
     self.second = 0
Ejemplo n.º 13
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.maxnum = 6
     self.joke_num = 0
     self.thing = ""
     self.people = ""
     self.benefit = ""
     self.victim = ""
     self.spot = ""
     self.stage = 0
Ejemplo n.º 14
0
 def build_state_graph(cls, filename):
     "Build a graphc representation of the state machine and store in 'filename'.png"
     model = type('model', (object, ), {})()
     GraphMachine(model=model,
                  states=cls.STATES,
                  title=cls.__name__,
                  transitions=cls.CORE_TRANSITIONS,
                  queued=True,
                  initial=cls.INITIAL_STATE)
     model.get_graph().draw(filename, prog='dot')  # pylint: disable=no-member
Ejemplo n.º 15
0
 def __init__(self):
     self.machine = GraphMachine(
         model=self,
         states=[
             'Init', 'Welcome', 'Transfer', 'Style', 'Image', 'Finish',
             'About', 'Example'
         ],
         transitions=[{
             'trigger': 'advance',
             'source': 'Init',
             'dest': 'Welcome',
             'conditions': 'is_going_to_Welcome'
         }, {
             'trigger': 'advance',
             'source': 'Welcome',
             'dest': 'Transfer',
             'conditions': 'is_going_to_Transfer'
         }, {
             'trigger': 'advance',
             'source': 'Transfer',
             'dest': 'Style',
             'conditions': 'is_going_to_Style'
         }, {
             'trigger': 'advance',
             'source': 'Style',
             'dest': 'Image',
             'conditions': 'is_going_to_Image'
         }, {
             'trigger': 'advance',
             'source': 'Image',
             'dest': 'Finish'
         }, {
             'trigger': 'advance',
             'source': 'Welcome',
             'dest': 'About',
             'conditions': 'is_going_to_About'
         }, {
             'trigger': 'advance',
             'source': 'Welcome',
             'dest': 'Example',
             'conditions': 'is_going_to_Example'
         }, {
             'trigger': 'go_back',
             'source': ['Finish', 'About', 'Example'],
             'dest': 'Init'
         }],
         initial='Init',
         auto_transitions=False,
         show_conditions=True,
     )
     self.style_path = ''
     self.selected = -1
     self.styles = ['la_muse', 'rain_princess', 'scream', 'udnie', 'wave']
     self.input_path = '/var/www/NeuralTransferBot/content/input.jpg'
     self.output_path = '/var/www/NeuralTransferBot/output/out.jpg'
Ejemplo n.º 16
0
 def __init__(self, line_bot_api, initial_state='user', *, root_path):
     self.config_path_base = root_path if root_path else ''
     self.load_config()
     self.machine = GraphMachine(
         model=self,
         states=DengueBotMachine.states,
         transitions=DengueBotMachine.dengue_transitions,
         initial=initial_state,
         auto_transitions=False,
         show_conditions=True)
     self.line_bot_api = line_bot_api
Ejemplo n.º 17
0
def create_graph():
    smile_ = Smile()
    m = GraphMachine(smile_, 
                    states=states, 
                    transitions=transitions, 
                    send_event=True, 
                    show_auto_transitions=False,
                    show_conditions=True,
                    show_state_attributes=True,
                    initial='start')
    m.get_graph().draw('state_diagram_3.png', prog='dot')
Ejemplo n.º 18
0
def main(debug, graph, output):
    calculator = Calculator()
    if graph:
        machine = GraphMachine(model=calculator,
                               states=Calculator.states,
                               transitions=Calculator.transitions,
                               use_pygraphviz=False)
        machine.get_graph().draw(output, prog='dot')
    else:  # default debug
        import pdb
        pdb.set_trace()
Ejemplo n.º 19
0
    def __init__(self, **machine_configs):
        self.machine = GraphMachine(model=self, **machine_configs)

        with codecs.open('data.json', 'r', 'utf-8') as file:
            file.text = file.read()
        self.data = json.loads(file.text)
        self.type = ['title', 'quantity', 'subtitle']
        self.if_first_in = 1
        self.if_see_menu = 0
        self.if_ordered = 0
        self.tmp_order = []
Ejemplo n.º 20
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.a = 0
     self.b1 = 0
     self.b2 = 0
     self.b3 = 0
     self.b4 = 0
     self.b5 = 0
     self.b6 = 0
     self.b7 = 0
     self.b8 = 0
Ejemplo n.º 21
0
    def __init__(self, **machine_configs):
        self.machine = GraphMachine(model=self, **machine_configs)
        area_num = 1
        r = requests.get('http://www.atmovies.com.tw/showtime/a06/')
        content = r.content
        soup = BeautifulSoup(content, 'html.parser')

        for opt in soup.findAll('option', value=re.compile(r'^/showtime/t0')):
            thearter_num[area_num - 1] = str(opt.get('value'))
            thearter_name[area_num - 1] = opt.text
            area_num = area_num + 1
Ejemplo n.º 22
0
 def __init__(self, **machine_configs):
     self.num = 0
     self.riddle_num = 0
     self.ans = ("hi")
     self.delete_num = 0
     self.new_music_name = ""
     self.new_music_composer = ""
     self.new_music_link = ""
     self.music_delete_num = ""
     self.modify_num = 0
     self.machine = GraphMachine(model=self, **machine_configs)
Ejemplo n.º 23
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.chrome_options = webdriver.ChromeOptions()
     self.chrome_options.binary_location = os.environ.get(
         "GOOGLE_CHROME_BIN")
     self.chrome_options.add_argument("--headless")
     self.chrome_options.add_argument("--disable-dev-shm-usage")
     self.chrome_options.add_argument("--no-sandbox")
     self.url = ""
     self.prev = ""
     self.next = ""
Ejemplo n.º 24
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.session_requests = requests.session()
     # Initialize the flag
     self.comic_not_found = False
     self.episode_not_found = False
     self.end_of_page = False
     self.animate_not_found = False
     self.yt_not_found = False
     self.yt_loop = False
     self.animate_loop = False
     self.comic_select_not_found = False
Ejemplo n.º 25
0
    def __init__(self, **machine_configs):

        self.machine = GraphMachine(model=self, **machine_configs)
        self.current_counter = 0
        self.coming_counter = 1
        self.horror_counter = 3
        self.romance_counter = 3
        self.comedy_counter = 3
        self.fight_counter = 3
        self.school_counter = 3
        self.terror_counter = 3
        self.movie = Movie()
Ejemplo n.º 26
0
 def __init__(self,
              states,
              transitions,
              draw_file="/tmp/state_machine.png",
              draw_prog="dot",
              initial=None):
     if initial is None:
         initial = states[0]
     self._machine = GraphMachine(model=self,
                                  states=states,
                                  transitions=transitions,
                                  initial=initial,
                                  ignore_invalid_triggers=True)
     if draw_file:
         self._machine.get_graph().draw(draw_file, prog=draw_prog)
Ejemplo n.º 27
0
 def __init__(self, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.timer = datetime.timedelta(hours=0, minutes=0, seconds=0)
     self.number = {"now": 0, "target": 0}
     self.clock = {
         "set": False,
         "time": datetime.timedelta(minutes=0, seconds=0),
         "start": datetime.datetime.now()
     }
     self.threadPool = []
     self.clockPool = []
     self.setNameFlag = -1
     self.index = 0
     self.beforeState = "none"
     self.isFromCenter = 0
     self.DB = DB()
Ejemplo n.º 28
0
    def __init__(self):
        configs = json.load(open(f'./config.json'))
        # print(configs)

        self.base_url = configs['base_url']
        self.gmap = GoogleMaps(configs['googlemap_api_key'])
        self.db = Firestorage(configs['firebase_url'])

        self.machine = GraphMachine(
            model=self,
            states=["user", "postback", "nearby", "favorlist", "graph"],
            transitions=[
                {
                    "trigger": "advance",
                    "source": "user",
                    "dest": "postback",
                    "conditions": "is_going_to_postback",
                },
                {
                    "trigger": "advance",
                    "source": "user",
                    "dest": "nearby",
                    "conditions": "is_going_to_nearby",
                },
                {
                    "trigger": "advance",
                    "source": "user",
                    "dest": "favorlist",
                    "conditions": "is_going_to_favorlist",
                },
                {
                    "trigger": "advance",
                    "source": "user",
                    "dest": "graph",
                    "conditions": "is_going_to_graph",
                },
                {
                    "trigger": "go_back",
                    "source": ["postback", "nearby", "favorlist", "graph"],
                    "dest": "user"
                },
            ],
            initial="user",
            auto_transitions=False,
            show_conditions=True,
        )
Ejemplo n.º 29
0
 def __init__(self, driver, **machine_configs):
     self.machine = GraphMachine(model=self, **machine_configs)
     self.driver = driver
     self.stay = False
     self.in_pixiv = False
     self.in_artist = False
     self.last_state = "initial"
     self.correct_picture_url = []
     self.icon_url = []
     self.correct_title_name = []
     self.container = []
     self.title_page = []
     self.artist_name = []
     self.artist_page = []
     self.re_scraw = True
     self.correct = 0
     self.appear_list = []
     self.download_url = []
    def draw(self, path, title="State Machine"):
        fsm = TransitionsFsmModel(self.__final)
        from transitions.extensions import GraphMachine

        machine = GraphMachine(
            model=fsm,
            states=self.__states,
            initial=self.__initial,
            transitions=self.__transitions,
            send_event=True,
            finalize_event=self.__transition_complete_callback,
            title=title,
            use_pygraphviz=True,
            show_conditions=True,
            show_state_attributes=True,
        )
        fsm.init(machine)
        fsm.get_graph().draw(path, prog="dot")
        return fsm