コード例 #1
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
 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
コード例 #2
0
ファイル: views_chat.py プロジェクト: G10h4ck/djrs
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))
コード例 #3
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #4
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #5
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #6
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #7
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #8
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #9
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
 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
コード例 #10
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #11
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #12
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #13
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #14
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
 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
コード例 #15
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #16
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #17
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #18
0
ファイル: views_chat.py プロジェクト: G10h4ck/djrs
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))
コード例 #19
0
ファイル: views_search.py プロジェクト: G10h4ck/djrs
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))
コード例 #20
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #21
0
ファイル: views_transfer.py プロジェクト: BlindlyMobile/djrs
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))
コード例 #22
0
ファイル: views_friends.py プロジェクト: alexeicolin/djrs
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))
コード例 #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)
コード例 #24
0
ファイル: views.py プロジェクト: G10h4ck/djrs
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))
コード例 #25
0
ファイル: views.py プロジェクト: G10h4ck/djrs
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))
コード例 #26
0
ファイル: views.py プロジェクト: G10h4ck/djrs
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))
コード例 #27
0
ファイル: views_friends.py プロジェクト: BlindlyMobile/djrs
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))
コード例 #28
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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)
コード例 #29
0
ファイル: views_friends.py プロジェクト: alexeicolin/djrs
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))
コード例 #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)
コード例 #31
0
ファイル: views_transfer.py プロジェクト: G10h4ck/djrs
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))
コード例 #32
0
ファイル: views_transfer.py プロジェクト: alexeicolin/djrs
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))
コード例 #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)
コード例 #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
コード例 #35
0
ファイル: harness.py プロジェクト: BlindlyMobile/djrs
  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
コード例 #36
0
ファイル: views_chat.py プロジェクト: xxl007/djrs
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))
コード例 #37
0
ファイル: views_search.py プロジェクト: alexeicolin/djrs
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))
コード例 #38
0
ファイル: views_chat.py プロジェクト: alexeicolin/djrs
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))
コード例 #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
コード例 #40
0
ファイル: context_processors.py プロジェクト: xxl007/djrs
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
コード例 #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)
コード例 #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))
コード例 #43
0
ファイル: views_friends.py プロジェクト: xxl007/djrs
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))
コード例 #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))
コード例 #45
0
ファイル: views_search.py プロジェクト: alexeicolin/djrs
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
コード例 #46
0
ファイル: templatize.py プロジェクト: xxl007/djrs
def dump_dict(addict):

    logging.info("templatize.dump_dict")
    for k, v in addict.iteritems():
        logging.info("K: %s => v: %s" % (k, v))
コード例 #47
0
ファイル: views_search.py プロジェクト: alexeicolin/djrs
        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)
コード例 #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
コード例 #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))