Ejemplo n.º 1
0
 def send_request(self, msg_id, msg):
   try:
     req_id = self.rpc.request(msg_id, msg);
   except Exception, e:
     self._connected = False
     logging.info("webharness.send_request() Exception")
     raise e
Ejemplo n.º 2
0
def chat_lobby(request, lobby_id):
    logging.info("djrs.view.chat_lobby")
    template_vars = {}
    template_vars['lobby_id'] = lobby_id

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    # get this lobby details.
    try:
        (req_id, msg_id) = harness.request_chat_lobby_list("all")
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            for lobby in resp_msg.lobbies:
                if lobby.lobby_id == lobby_id:
                    template_vars['lobby_details'] = lobby
    
            # build a list from Lobby List.
            template_vars['sidebar_menu'] = 'Subscribed Lobbies'
            template_vars['sidebar_sublinks'] = []
            for lobby in resp_msg.lobbies:
                if lobby.lobby_state == chat_pb2.ChatLobbyInfo.LOBBYSTATE_JOINED:
                    url = "/lobby/%s/" % lobby.lobby_id
                    template_vars['sidebar_sublinks'].append({ 'url':url , 'name': lobby.lobby_name })

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 3
0
  def request_system_status(self):
    logging.info("webharness.request_system_status()")

    rp = system_pb2.RequestSystemStatus();
    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.SYSTEM, system_pb2.MsgId_RequestSystemStatus, False);

    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 4
0
  def request_chat_lobby_list(self, list_type):
    logging.info("webharness.request_chat_lobby_list()")

    rp = chat_pb2.RequestChatLobbies();
    rp.lobby_set = chat_pb2.RequestChatLobbies.LOBBYSET_ALL;

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestChatLobbies, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 5
0
  def request_set_chat_nickname(self, nickname):
    logging.info("webharness.request_set_chat_nickname()")

    rp = chat_pb2.RequestSetLobbyNickname();
    rp.nickname = nickname

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestSetLobbyNickname, False);
    req_id = self.request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 6
0
  def request_close_search(self, search_id):
    logging.info("webharness.request_close_search()")

    rp = search_pb2.RequestCloseSearch()
    rp.search_id = search_id

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.SEARCH, search_pb2.MsgId_RequestCloseSearch, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 7
0
  def request_dirlisting(self, peer_id, path):
    logging.info("webharness.request_dirlisting()")

    rp = files_pb2.RequestShareDirList()
    rp.ssl_id = peer_id;
    rp.path = path;

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.FILES, files_pb2.MsgId_RequestShareDirList, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 8
0
  def request_basic_search(self, search_terms):
    logging.info("webharness.request_basic_search()")

    rp = search_pb2.RequestBasicSearch();
    for term in search_terms:
      rp.terms.append(term)

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.SEARCH, search_pb2.MsgId_RequestBasicSearch, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 9
0
 def first_response(self):
   logging.info("webharness.first_response()")
   ans = self.rpc.first_response()
   if ans:
     (msg_id, msg_body) = ans;
     print "Received Response: msg_id: %d" % (msg_id);
     resp = self.parser.construct(msg_id, msg_body);
     if resp:
       print "Parsed Msg:";
       print resp;
       return (msg_id, resp)
   return None
Ejemplo n.º 10
0
  def request_transfer_download(self, hash, filename, size):
    logging.info("webharness.request_transfer_download()")

    rp = files_pb2.RequestControlDownload()
    rp.file.hash = hash
    rp.file.name = filename
    rp.file.size = int(size)
    rp.action = files_pb2.RequestControlDownload.ACTION_START

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.FILES, files_pb2.MsgId_RequestControlDownload, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 11
0
  def request_register_chat_events(self):
    logging.info("webharness.request_register_chat_events()")

    rp = chat_pb2.RequestRegisterEvents(); 
    rp.action = chat_pb2.RequestRegisterEvents.REGISTER

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestRegisterEvents, False);
    req_id = self.send_request(msg_id, rp)

    # slightly different... remember this parameter,
    self.event_id_chat = req_id
    return (req_id, msg_id)
Ejemplo n.º 12
0
  def request_transfer_list(self, dir_upload):
    logging.info("webharness.request_transfer_list()")

    rp = files_pb2.RequestTransferList();
    if dir_upload:
      rp.direction = files_pb2.DIRECTION_UPLOAD
    else:
      rp.direction = files_pb2.DIRECTION_DOWNLOAD

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.FILES, files_pb2.MsgId_RequestTransferList, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 13
0
  def request_join_or_leave_lobby(self, lobby_id, to_join):
    logging.info("webharness.request_join_or_leave_lobby()")
  
    rp = chat_pb2.RequestJoinOrLeaveLobby()
    rp.lobby_id = lobby_id
    if to_join:
      rp.action = chat_pb2.RequestJoinOrLeaveLobby.JOIN_OR_ACCEPT
    else:
      rp.action = chat_pb2.RequestJoinOrLeaveLobby.LEAVE_OR_DENY

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestJoinOrLeaveLobby, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 14
0
 def specific_response(self, req_id):
   logging.info("webharness.response()")
   timeout = 2.0
   ans = self.rpc.response(req_id, timeout)
   if ans:
     (msg_id, msg_body) = ans;
     print "Received Response: msg_id: %d" % (msg_id);
     resp = self.parser.construct(msg_id, msg_body);
     if resp:
       print "Parsed Msg:";
       print resp;
       return (msg_id, resp)
   return None
Ejemplo n.º 15
0
  def request_search_list(self, search_ids, limit):
    logging.info("webharness.request_search_list()")

    rp = search_pb2.RequestSearchResults()
    rp.result_limit = limit
    if search_ids is None:
      pass
    else:
      for id in search_ids:
        rp.search_ids.append(id)

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.SEARCH, search_pb2.MsgId_RequestSearchResults, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 16
0
  def request_peer_details(self, peer_id):
    logging.info("webharness.request_peer_details()")

    # ignoring list_type for now.
    rp = peers_pb2.RequestPeers();

    rp.set = peers_pb2.RequestPeers.LISTED;
    rp.info = peers_pb2.RequestPeers.ALLINFO;
    rp.pgp_ids.append(peer_id);

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.PEERS, peers_pb2.MsgId_RequestPeers, False);

    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 17
0
  def request_chat_history(self, chat_type, chat_id):
    logging.info("webharness.request_chat_history()")

    rp = chat_pb2.RequestChatHistory();

    if chat_type == 'lobby':
        rp.id.chat_type = chat_pb2.TYPE_LOBBY
    else:
        rp.id.chat_type = chat_pb2.TYPE_PRIVATE

    rp.id.chat_id = chat_id;

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestChatHistory, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 18
0
def lobby_drop(request, lobby_id):
    logging.info("djrs.view.lobby_drop")
    template_vars = {}

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    try:
        (req_id, msg_id) = harness.request_join_or_leave_lobby(lobby_id, False)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 19
0
def search_close(request, search_id):
    logging.info("djrs.view.search_close")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_close_search(int(search_id))
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 20
0
  def request_send_message(self, chat_type, chat_id, msg):
    logging.info("webharness.request_send_message()")

    rp = chat_pb2.RequestSendMessage();

    if chat_type == 'lobby':
        rp.msg.id.chat_type = chat_pb2.TYPE_LOBBY
    else:
        rp.msg.id.chat_type = chat_pb2.TYPE_PRIVATE

    rp.msg.id.chat_id = chat_id;
    rp.msg.msg = msg;

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT, chat_pb2.MsgId_RequestSendMessage, False);
    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 21
0
def transfer_cancel(request, hash):
    logging.info("djrs.view.transfer_cancel")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_transfer_cancel(hash)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 22
0
def friend_add(request, friend_id):
    logging.info("djrs.view.friend_add")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_friend_add(friend_id, True)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            # should check the result...

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 23
0
    def request_chat_history(self, chat_type, chat_id):
        logging.info("webharness.request_chat_history()")

        rp = chat_pb2.RequestChatHistory()

        if chat_type == 'lobby':
            rp.id.chat_type = chat_pb2.TYPE_LOBBY
        else:
            rp.id.chat_type = chat_pb2.TYPE_PRIVATE

        rp.id.chat_id = chat_id

        msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT,
                                          chat_pb2.MsgId_RequestChatHistory,
                                          False)
        req_id = self.send_request(msg_id, rp)
        return (req_id, msg_id)
Ejemplo n.º 24
0
def transfers(request):
    logging.info("djrs.view.transfers")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse("djrs_login"))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_transfer_list(True)  # upload
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            template_vars["upload_list"] = resp_msg.transfers

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 25
0
def chat(request):
    logging.info("djrs.view.chat")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse("djrs_login"))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_chat_lobby_list("all")
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            template_vars["lobby_list"] = resp_msg.lobbies

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 26
0
def friend_details(request, friend_id):
    logging.info("djrs.view.friend_details")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse("djrs_login"))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_peer_list("all")
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            template_vars["friend_list"] = resp_msg.peers

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 27
0
def friend_add(request, friend_id):
    logging.info("djrs.view.friend_add")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_friend_add(friend_id, True)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            # should check the result...

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 28
0
  def request_friend_add(self, peer_id, toadd):
    logging.info("webharness.request_friend_add()")

    # ignoring list_type for now.
    rp = peers_pb2.RequestAddPeer();

    if toadd:
      rp.cmd = peers_pb2.RequestAddPeer.ADD;
    else:
      rp.cmd = peers_pb2.RequestAddPeer.REMOVE;

    rp.pgp_id = peer_id;

    msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.PEERS, peers_pb2.MsgId_RequestAddPeer, False);

    req_id = self.send_request(msg_id, rp)
    return (req_id, msg_id)
Ejemplo n.º 29
0
def friend_details(request, friend_id):
    logging.info("djrs.view.friend_details")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_peer_details(friend_id)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['friend_list'] = core_personlist(dict_msg['peers'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 30
0
    def request_send_message(self, chat_type, chat_id, msg):
        logging.info("webharness.request_send_message()")

        rp = chat_pb2.RequestSendMessage()

        if chat_type == 'lobby':
            rp.msg.id.chat_type = chat_pb2.TYPE_LOBBY
        else:
            rp.msg.id.chat_type = chat_pb2.TYPE_PRIVATE

        rp.msg.id.chat_id = chat_id
        rp.msg.msg = msg

        msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.CHAT,
                                          chat_pb2.MsgId_RequestSendMessage,
                                          False)
        req_id = self.send_request(msg_id, rp)
        return (req_id, msg_id)
Ejemplo n.º 31
0
def transfers(request):
    logging.info("djrs.view.transfers")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_transfer_list(True) # upload
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['upload_list'] = files_transferlist(dict_msg['transfers'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 32
0
def transfers(request):
    logging.info("djrs.view.transfers")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_transfer_list(True)  # upload
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['upload_list'] = files_transferlist(
                dict_msg['transfers'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 33
0
    def request_friend_add(self, peer_id, toadd):
        logging.info("webharness.request_friend_add()")

        # ignoring list_type for now.
        rp = peers_pb2.RequestAddPeer()

        if toadd:
            rp.cmd = peers_pb2.RequestAddPeer.ADD
        else:
            rp.cmd = peers_pb2.RequestAddPeer.REMOVE

        rp.pgp_id = peer_id

        msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.PEERS,
                                          peers_pb2.MsgId_RequestAddPeer,
                                          False)

        req_id = self.send_request(msg_id, rp)
        return (req_id, msg_id)
Ejemplo n.º 34
0
    def setup_connection(self):
        logging.info("webharness.setup()")
        if self.is_setup():
            logging.info("webharness.setup() Already Setup")
            return

        logging.info("webharness.setup() Running setup")
        (req_id, msg_id) = self.request_register_chat_events()
        (resp_msg_id, resp) = self.specific_response(req_id)

        logging.info("webharness.setup() Setup Done")
        self._setup = True
Ejemplo n.º 35
0
  def setup_connection(self):
    logging.info("webharness.setup()")
    if self.is_setup():
      logging.info("webharness.setup() Already Setup")
      return

    logging.info("webharness.setup() Running setup")
    (req_id, msg_id) = self.request_register_chat_events()
    (resp_msg_id, resp) = self.specific_response(req_id)

    logging.info("webharness.setup() Setup Done")
    self._setup = True
Ejemplo n.º 36
0
def chat_friend(request, peer_id):
    logging.info("djrs.view.chat_friend")
    template_vars = {}
    template_vars['peer_id'] = peer_id

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    # get peer details.
    # get this lobby details.
    #try:
    #    (req_id, msg_id) = harness.request_chat_lobby_list("all")
    #    resp = harness.specific_response(req_id)
    #    if resp:
    #        (resp_id, resp_msg) = resp
    #        for lobby in resp_msg.lobbies:
    #            if lobby.lobby_id == lobby_id:
    #                template_vars['lobby_details'] = lobby
    #
    #        # build a list from Lobby List.
    #        template_vars['sidebar_menu'] = 'Subscribed Lobbies'
    #        template_vars['sidebar_sublinks'] = []
    #        for lobby in resp_msg.lobbies:
    #            if lobby.lobby_state == chat_pb2.ChatLobbyInfo.LOBBYSTATE_JOINED:
    #                url = "/lobby/%s/" % lobby.lobby_id
    #                template_vars['sidebar_sublinks'].append({ 'url':url , 'name': lobby.lobby_name })
    #
    #except Exception, e:
    #    logging.info("Unexpected Exception: %s" % (e))

    # get chat from lobby.
    try:
        (req_id, msg_id) = harness.request_chat_history('friend', peer_id)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            if 'msgs' in dict_msg:
                template_vars['messages'] = chat_chathistory(dict_msg['msgs'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 37
0
def search_details(request, search_id):
    logging.info("djrs.view.search_details")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_search_list(int(search_id))
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['search_list'] = search_searchlist(dict_msg['searches'])


    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 38
0
def chat_send(request, chat_type, chat_id):
    logging.info("djrs.view.chat_send")

    template_vars = {}

    if request.method == 'POST':
        form = ChatForm(request.POST)
        if form.is_valid():

            harness = getWebHarness()

            message = form.cleaned_data['message']
            # get this lobby details.
            try:
                (req_id, msg_id) = harness.request_send_message(
                    chat_type, chat_id, message)
                resp = harness.specific_response(req_id)
                if resp:
                    (resp_id, resp_msg) = resp
            except Exception, e:
                logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 39
0
def login(request):

    template_vars = {}

    if request.method == 'POST': # If the form has been submitted...
        form = LoginForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            logging.info("Hello... we have a form")

            harness = getWebHarness()

            # try to login.
            # wait around until we are logged in.
            user = form.cleaned_data['user']
            pwd = form.cleaned_data['password']
            host = form.cleaned_data['host']
            port = form.cleaned_data['port']

            try: 
                harness.connect_params(user, pwd, host, port)
                return HttpResponseRedirect(reverse('djrs_home'))
            except paramiko.SSHException, e:
                logging.info("Login Exception: %s" % (e))
                error_msg = "Login Error: %s" % e
            except Exception, e:
                error_msg = "Unexpected Error: %s" % e
                logging.info("Unexpected Exception: %s" % (e))
            template_vars['error_message'] = error_msg
Ejemplo n.º 40
0
def pyrs_status(request):
    "Returns context variables for basic status."

    context_extras = {}
    if 'offline' == request.session.get('djrs','offline'):
        return context_extras

    web_harness = getWebHarness()

    # default False...     
    pyrs_status = {'connected':False}

    if web_harness is None:
        # major error - bail out.
        context_extras['pyrs_status'] = pyrs_status
        return context_extras

    try:
        # run requests (System Status)
        (req_id, msg_id) = web_harness.request_system_status()
        resp = web_harness.specific_response(req_id)
        pyrs_status['connection'] = web_harness.connect_state()

        if resp:
            (resp_id, resp_msg) = resp

            pyrs_status['connected'] = True

            pyrs_status['no_peers'] = resp_msg.no_peers
            pyrs_status['no_connected'] = resp_msg.no_connected
            pyrs_status['upload_rate'] = resp_msg.bw_total.up
            pyrs_status['download_rate'] = resp_msg.bw_total.down
            pyrs_status['network_status'] = resp_msg.net_status  # This will need to be translated
        else:
            pyrs_status['connected'] = False
    except Exception, e:
        logging.info("djrs::context_processors.pyrs_status() Exception: %s" % e)
        pass
Ejemplo n.º 41
0
    def request_peer_list(self, list_type):
        logging.info("webharness.request_peer_info()")

        # ignoring list_type for now.
        rp = peers_pb2.RequestPeers()

        if list_type == 'friends':
            rp.set = peers_pb2.RequestPeers.FRIENDS
        elif list_type == 'connected':
            rp.set = peers_pb2.RequestPeers.CONNECTED
        elif list_type == 'self':
            rp.set = peers_pb2.RequestPeers.OWNID
        else:
            rp.set = peers_pb2.RequestPeers.ALL

        #rp.set = peers_pb2.RequestPeers.VALID
        rp.info = peers_pb2.RequestPeers.ALLINFO

        msg_id = pyrs.msgs.constructMsgId(core_pb2.CORE, core_pb2.PEERS,
                                          peers_pb2.MsgId_RequestPeers, False)

        req_id = self.send_request(msg_id, rp)
        return (req_id, msg_id)
Ejemplo n.º 42
0
def file_listing(request, peer_id='', path=''):
    logging.info("djrs.view.file_listing() peer_id: %s, path: %s " %
                 (peer_id, path))

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    if path and path[0] != '/':
        # need to have starting /
        path = '/' + path

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_dirlisting(peer_id, path)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['file_listing'] = files_sharedirlist(dict_msg)

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 43
0
def friends(request, list_type='friends'):
    logging.info("djrs.view.friends")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    acceptable_types = ['all', 'friends', 'connected', 'self']
    if list_type not in acceptable_types:
        template_vars['error_message'] = 'Invalid Arguments Friends Listing'
        return render_to_response('djrs_error.dtml', template_vars, context_instance=RequestContext(request))

    try:
        (req_id, msg_id) = harness.request_peer_list(list_type)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            if 'peers' in dict_msg:
                template_vars['friend_list'] = core_personlist(dict_msg['peers'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 44
0
def transfer_download(request, hash):
    logging.info("djrs.view.transfer_download")

    template_vars = {}
    # parse the extra arguments for the full download details.
    size = request.GET.get('size', None)
    name = request.GET.get('name', None)

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    if not size or not name:
        template_vars['error_message'] = 'Missing Arguments for Download Request'
        return render_to_response('djrs_error.dtml', template_vars, context_instance=RequestContext(request))

    try:
        (req_id, msg_id) = harness.request_transfer_download(hash, name, size)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))
Ejemplo n.º 45
0
def searches(request):
    logging.info("djrs.view.searches")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}

    if request.method == 'POST': # If the form has been submitted...
        form = SearchForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass

            terms = form.cleaned_data['terms']
            term_list = terms.split(' ')

            logging.info("Completed Search Form. Term_list: %s" % term_list)

            # default...
            template_vars['search_started'] = False
            try:
                # trigger the search...

                (req_id, msg_id) = harness.request_basic_search(term_list)
                resp = harness.specific_response(req_id)
                if resp:
                    (resp_id, resp_msg) = resp
                    template_vars['search_started'] = True
                    template_vars['search_terms'] = term_list

            except Exception, e:
                logging.info("Unexpected Exception: %s" % (e))

            # reset the form for next search.
            # form = SearchForm() # An unbound form
            form = None # disable for more info,
        else:
            # invalid form will return errors.
            pass
Ejemplo n.º 46
0
def dump_dict(addict):

    logging.info("templatize.dump_dict")
    for k, v in addict.iteritems():
        logging.info("K: %s => v: %s" % (k, v))
Ejemplo n.º 47
0
        form = SearchForm() # An unbound form

    template_vars['form'] = form

    # now grab existing search results.
    try:
	limit = 500
        (req_id, msg_id) = harness.request_search_list(None, limit)
        resp = harness.specific_response(req_id)
        if resp:
            (resp_id, resp_msg) = resp
            dict_msg = protobuf_to_dict(resp_msg)
            template_vars['search_list'] = search_searchlist(dict_msg['searches'])

    except Exception, e:
        logging.info("Unexpected Exception: %s" % (e))

    return render_to_response('djrs_search.dtml', template_vars, context_instance=RequestContext(request))


def search_details(request, search_id):
    logging.info("djrs.view.search_details")

    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))

    template_vars = {}
    try:
        (req_id, msg_id) = harness.request_search_list(int(search_id))
        resp = harness.specific_response(req_id)
Ejemplo n.º 48
0
 def get_event_chats(self):
     logging.info("webharness.get_event_chats()")
     if self.event_id_chat:
         return self.response(self.event_id_chat, 0)
     return None
Ejemplo n.º 49
0
def home(request):
    logging.info("djrs.view.home")
    harness = getWebHarness()
    if harness.is_connected() is False:
        return HttpResponseRedirect(reverse('djrs_login'))
    return render_to_response('djrs_home.dtml', {}, context_instance=RequestContext(request))