Ejemplo n.º 1
0
 def layout(self, c):
   return T.html()[
     T.head()[
       T.title()["MetaP2P Control Panel (%s)"%(self.server.uuid.hex)],
       T.link_to_css("/public/css/master.css"),
       T.link_to_javascript("/public/js/master.js"),
       T.meta({'http-equiv': "content-type", 'content': "text/html; charset=utf-8"})
     ],
     T.body()[
       T.div(id="heading")[
         T.span(_class="title")["MetaP2P Control Panel"],
         map(lambda element: [T.span(_class="sep")[">"],
           T.span(_class="place")[element]], self.path)
       ],
       T.div(id="navigation")[
         T.ul()[
           T.li()[T.link_to(url_for('peers'))["Peers"]],
           T.li()[T.link_to(url_for('peers_broadcast'))["Broadcast"]]
         ]
       ],
       T.div(id="content")[
         c
       ]
     ]
   ]
Ejemplo n.º 2
0
  def show(self, peer_uri):
    import urllib
    
    self.path=["Peers", peer_uri]

    peer = self.__find_peer(peer_uri)
    if not peer:
      return T.h1("Not Found")
    
    messages = list()

    for m_id in peer.queue:
      message = peer.queue[m_id]

      if message.completed:
        messages.append(
          T.div()[
            T.h4()[message.id],
            T.pre(style="background-color: #dedede; border: 1px dotted #999; width: 50%;")[
              message.message
            ]
          ]
        )
      else:
        messages.append(
          T.div()[
            T.h4()[message.id],
            T.pre(style="background-color: #dedede; border: 1px dotted #999; width: 50%;")[
              "not complete"
            ]
          ]
        )
    
    return [
      T.h1()[peer_uri],
      T.p()["This is a paragraph"],
      T.p()["messages received:"],
      T.div()[messages]
    ]
Ejemplo n.º 3
0
  def index(self):
    self.path=["Peers"]

    peerlist = list()
    
    peerlist.append(T.div(_class="row heading")[
      T.span(_class="name")["host"],
      T.span(_class="transmit")["tX (out)"],
      T.span(_class="receive")["rX (in)"],
      T.div(_class="clear")
      ])
    
    for peer in self.server.peers:
      if peer.connected:
        if peer.session.uuid:
          uuid = peer.session.uuid
        else:
          uuid = "<none>"

        peerlist.append(T.div(_class="row")[
          T.span(_class="name")[T.link_to(url_for(action="show", peer_uri=peer.uri))[peer.uri]],
          T.span(_class="transmit")[str(peer.session.tx)],
          T.span(_class="receive")[str(peer.session.rx)],
          T.span(_class="uuid")[uuid],
          T.span(_class="conv")[repr(peer.session)],
          T.div(_class="clear")
        ])
      else:
        peerlist.append(T.div(_class="row")[
          T.span(_class="name")[T.link_to(url_for(action="show", peer_uri=peer.uri))[peer.uri]],
          "not connected",
          T.div(_class="clear")
        ])
    
    return [T.div(_class="mininav")[T.span(_class='item')[T.link_to(url_for('new_peer'))["new"]]],
            T.div(id="peers")[peerlist]]