示例#1
0
 async def on_start(self):
     self.agent.presence.set_presence(state=PresenceState(
         available=True, show=PresenceShow.DND))  # DND = sinterrupt
     if V.kernel_calendar_type == 1:
         cd = self.agent.get("currentDev")
         self.agent.presence.set_presence(status="dev" + str(cd).zfill(2))
         self.agent.set("currentDev", (cd + 1) % len(V.devs))
示例#2
0
 def set_available(self, show=None):
     """
     Sets the agent availability to True.
     :param show: the show state of the presence (optional)
     :type show: :class:`aioxmpp.PresenceShow`
     """
     show = self.state.show if show is None else show
     self.set_presence(PresenceState(available=True, show=show))
示例#3
0
def test_set_presence_unavailable():
    artifact = MockedConnectedArtifactFactory()

    future = artifact.start(auto_register=False)
    future.result()

    artifact.presence.set_presence(state=PresenceState(available=False))

    assert not artifact.presence.is_available()
示例#4
0
def test_set_presence_unavailable():
    agent = make_presence_connected_agent()

    future = agent.start(auto_register=False)
    future.result()

    agent.presence.set_presence(state=PresenceState(available=False))

    assert not agent.presence.is_available()
示例#5
0
def test_set_presence_unavailable():
    agent = MockedPresenceAgentFactory()

    future = agent.start(auto_register=False)
    future.result()

    agent.presence.set_presence(state=PresenceState(available=False))

    assert not agent.presence.is_available()
示例#6
0
    def set_available(self, show=PresenceShow.NONE):
        """
        Sets the agent availability to True.

        Args:
          show (aioxmpp.PresenceShow, optional): the show state of the presence (Default value = PresenceShow.NONE)

        """
        show = self.state.show if show is PresenceShow.NONE else show
        self.set_presence(PresenceState(available=True, show=show))
示例#7
0
def test_set_presence():
    agent = make_presence_connected_agent()

    agent.presence.set_presence(state=PresenceState(True, PresenceShow.PLAIN),
                                status="Lunch",
                                priority=2)

    assert agent.presence.is_available()
    assert agent.presence.state.show == PresenceShow.PLAIN
    assert agent.presence.status == {None: "Lunch"}
    assert agent.presence.priority == 2
示例#8
0
def test_set_presence():
    agent = make_presence_connected_agent()

    future = agent.start(auto_register=False)
    future.result()

    agent.presence.set_presence(state=PresenceState(True, PresenceShow.PLAIN),
                                status="Lunch",
                                priority=2)

    assert agent.presence.is_available()
    assert agent.presence.state.show == PresenceShow.PLAIN
    assert agent.presence.status == {None: "Lunch"}
    assert agent.presence.priority == 2
示例#9
0
def test_set_presence():
    artifact = MockedConnectedArtifactFactory()

    future = artifact.start(auto_register=False)
    future.result()

    artifact.presence.set_presence(state=PresenceState(True,
                                                       PresenceShow.PLAIN),
                                   status="Lunch",
                                   priority=2)

    assert artifact.presence.is_available()
    assert artifact.presence.state.show == PresenceShow.PLAIN
    assert artifact.presence.status == {None: "Lunch"}
    assert artifact.presence.priority == 2
示例#10
0
    def __init__(self,
                 available=None,
                 show=None,
                 status={},
                 priority=0,
                 *args,
                 **kwargs):
        super().__init__(*args, **kwargs)
        self.aiothread.connect = Mock()
        self.aiothread.conn_coro = Mock()
        self.aiothread.conn_coro.__aexit__ = CoroutineMock()

        show = show if show is not None else PresenceShow.NONE
        available = available if available is not None else False
        state = PresenceState(available, show)
        self.presence.presenceserver.set_presence(state, status, priority)
示例#11
0
文件: chords.py 项目: acordovap/amg
 async def run(self):
     contacts = self.presence.get_contacts()
     for i in range(CFG.no_songs):
         cntct = contacts[aioxmpp.JID.fromstr("s_" + str(i) + CFG.XMPP_SERVER)]["presence"]
         if cntct.show == PresenceShow.CHAT and cntct.status.any() == "chords":
             self.agent.presence.set_presence(state=PresenceState(available=True, show=PresenceShow.CHAT))
             msg = Message(to="s_" + str(i) + CFG.XMPP_SERVER)     # Instantiate the message
             msg.set_metadata("performative", "chords")  # Set the "notes" FIPA performative
             cl = getattr(chords, self.agent.name.split("_")[2].upper())(self.agent.name.split("_")[1].capitalize())
             inv = self.agent.get("inversion")
             if inv != None:
                 cl2 = getattr(chords, inv+"_inversion")(cl)
                 self.agent.set("inversion", None)
                 msg.body = ','.join(cl2)                    # Set the message content
             else:
                 msg.body = ','.join(cl)                    # Set the message content
             await self.send(msg)
             await asyncio.sleep(random.randint(1, 10)/1000)
示例#12
0
 async def run(self):
     contacts = self.presence.get_contacts()
     for i in range(CFG.no_songs):
         cntct = contacts[aioxmpp.JID.fromstr(
             "s_" + str(i) + CFG.XMPP_SERVER)]["presence"]
         if cntct.show == PresenceShow.CHAT and cntct.status.any(
         ) == "notes":
             self.agent.presence.set_presence(state=PresenceState(
                 available=True, show=PresenceShow.CHAT))
             fn = self.agent.get("full_note")
             if fn[1] != None and fn[2] != None:
                 msg = Message(
                     to="s_" + str(i) +
                     CFG.XMPP_SERVER)  # Instantiate the message
                 msg.set_metadata(
                     "performative",
                     "notes")  # Set the "notes" FIPA performative
                 msg.body = fn[0] + "-" + str(fn[1]) + "," + str(
                     fn[2])  # Set the message content
                 await self.send(msg)
                 # se podría implementar un fllush de la nota, se tendría que o salir del for o enviar a todas las songs
                 await asyncio.sleep(random.randint(1, 10) / 1000)
示例#13
0
文件: songs.py 项目: acordovap/amg
    async def run(self):
        while await self.receive():  # flush messages
            pass

        c = Composition()
        c.set_author("amg")
        c.set_title(CFG.OUTPUT_PREFIX + self.agent.name)
        c.add_track(self.agent.get("melody_track"))
        c.add_track(self.agent.get("accompaniment_track"))
        # fluidsynth.init("4U-Yamaha C5 Grand-v1.5.sf2", "alsa")
        # fluidsynth.play_Composition(c)
        midi_file_out.write_Composition(
            CFG.OUTPUT_FOLDER + CFG.OUTPUT_PREFIX + self.agent.name + ".mid",
            c, CFG.SONG_TEMPO)
        l = lilypond.from_Composition(c)
        extra = "  \\score { \\new PianoStaff << \\set PianoStaff.instrumentName = #\"Piano  \" \\new Staff = \"upper\" \\upper \\new Staff = \"lower\" \\lower  >> \\layout { }  }"
        l2 = l.replace("{ {", "upper = {x {x", 1).replace(
            "{ {", "lower = { {", 1).replace("{x {x", "{ {", 1) + extra
        # print("<lilipond-"+CFG.OUTPUT_FOLDER+CFG.OUTPUT_PREFIX+self.agent.name+">\n"+l2)
        lilypond.to_pdf(
            l2, CFG.OUTPUT_FOLDER + CFG.OUTPUT_PREFIX + self.agent.name)
        self.agent.presence.set_presence(
            state=PresenceState(available=True, show=PresenceShow.AWAY))
        self.set_next_state(S_FINISHED)
示例#14
0
 def set_unavailable(self):
     """
     Sets the agent availability to False.
     """
     show = PresenceShow.NONE
     self.set_presence(PresenceState(available=False, show=show))
示例#15
0
 def mock_presence(self):
     show = self.show if self.show is not None else PresenceShow.NONE
     available = self.available if self.available is not None else False
     state = PresenceState(available, show)
     self.presence.presenceserver.set_presence(state, self.status, self.priority)
示例#16
0
文件: songs.py 项目: acordovap/amg
 async def on_start(self):
     self.agent.presence.set_presence(
         state=PresenceState(available=True, show=PresenceShow.CHAT))
     self.agent.presence.set_presence(status="chords")
示例#17
0
文件: songs.py 项目: acordovap/amg
 async def on_start(self):
     self.agent.presence.set_presence(
         state=PresenceState(available=True, show=PresenceShow.AWAY))
示例#18
0
def test_set_presence_unavailable():
    agent = make_presence_connected_agent()

    agent.presence.set_presence(state=PresenceState(available=False))

    assert not agent.presence.is_available()