Skip to content

Commit

Permalink
packet.Payload needs to be translated to text in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vesellov committed Oct 26, 2018
1 parent ff23f4f commit a0bba32
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions access/key_ring.py
Expand Up @@ -55,9 +55,9 @@

from logs import lg

from contacts import identitycache
from lib import strng

from userid import my_id
from contacts import identitycache

from p2p import propagate
from p2p import p2p_service
Expand Down Expand Up @@ -93,7 +93,7 @@ def _do_request_service_keys_registry(key_id, idurl, include_private, timeout, r


def _on_service_keys_registry_response(response, info, key_id, idurl, include_private, result, timeout):
if not response.Payload.startswith('accepted'):
if not strng.to_text(response.Payload).startswith('accepted'):
result.errback(Exception('request for "service_keys_registry" refused by remote node'))
return
d = transfer_key(
Expand Down
5 changes: 4 additions & 1 deletion broadcast/broadcasters_finder.py
Expand Up @@ -57,11 +57,14 @@

from automats import automat

from lib import strng

from p2p import commands
from p2p import p2p_service
from p2p import lookup

from contacts import identitycache

from userid import my_id

from transport import callback
Expand Down Expand Up @@ -254,7 +257,7 @@ def _inbox_packet_received(self, newpacket, info, status, error_message):
def _node_acked(self, response, info):
if _Debug:
lg.out(_DebugLevel, 'broadcasters_finder._node_acked %r %r' % (response, info))
if not response.Payload.startswith('accepted'):
if not strng.to_text(response.Payload).startswith('accepted'):
if _Debug:
lg.out(_DebugLevel, 'broadcasters_finder._node_acked with service denied %r %r' % (response, info))
self.automat('service-denied')
Expand Down
5 changes: 4 additions & 1 deletion coins/accountants_finder.py
Expand Up @@ -56,11 +56,14 @@

from automats import automat

from lib import strng

from p2p import commands
from p2p import p2p_service
from p2p import lookup

from contacts import identitycache

from userid import my_id

from transport import callback
Expand Down Expand Up @@ -268,7 +271,7 @@ def _inbox_packet_received(self, newpacket, info, status, error_message):
def _node_acked(self, response, info):
if _Debug:
lg.out(_DebugLevel, 'accountants_finder._node_acked %r %r' % (response, info))
if not response.Payload.startswith('accepted'):
if not strng.to_text(response.Payload).startswith('accepted'):
if _Debug:
lg.out(_DebugLevel, 'accountants_finder._node_acked with service denied %r %r' % (response, info))
self.automat('service-denied')
Expand Down
5 changes: 3 additions & 2 deletions customer/supplier_connector.py
Expand Up @@ -70,6 +70,7 @@

from main import settings

from lib import strng
from lib import nameurl
from lib import diskspace

Expand Down Expand Up @@ -324,7 +325,7 @@ def isServiceAccepted(self, arg):
Condition method.
"""
newpacket = arg
if newpacket.Payload.startswith('accepted'):
if strng.to_text(newpacket.Payload).startswith('accepted'):
if _Debug:
lg.out(6, 'supplier_connector.isServiceAccepted !!!! supplier %s connected' % self.supplier_idurl)
return True
Expand All @@ -336,7 +337,7 @@ def isServiceCancelled(self, arg):
"""
newpacket = arg
if newpacket.Command == commands.Ack():
if newpacket.Payload.startswith('accepted'):
if strng.to_text(newpacket.Payload).startswith('accepted'):
if _Debug:
lg.out(6, 'supplier_connector.isServiceCancelled !!!! supplier %s disconnected' % self.supplier_idurl)
return True
Expand Down
4 changes: 3 additions & 1 deletion p2p/p2p_service_seeker.py
Expand Up @@ -60,6 +60,8 @@

from automats import automat

from lib import strng

from p2p import commands
from p2p import p2p_service
from p2p import lookup
Expand Down Expand Up @@ -289,7 +291,7 @@ def _inbox_packet_received(self, newpacket, info, status, error_message):
def _node_acked(self, response, info):
if _Debug:
lg.out(_DebugLevel, 'p2p_service_seeker._node_acked %r %r' % (response, info))
if not response.Payload.startswith('accepted'):
if not strng.to_text(response.Payload).startswith('accepted'):
if _Debug:
lg.out(_DebugLevel, 'p2p_service_seeker._node_acked with service denied %r %r' % (response, info))
self.automat('service-denied')
Expand Down
3 changes: 2 additions & 1 deletion services/service_supplier.py
Expand Up @@ -330,13 +330,14 @@ def _on_delete_file(self, newpacket):
import os
from logs import lg
from system import bpio
from lib import strng
from userid import global_id
from p2p import p2p_service
from main import events
if not newpacket.Payload:
ids = [newpacket.PacketID, ]
else:
ids = newpacket.Payload.split('\n')
ids = strng.to_text(newpacket.Payload).split('\n')
filescount = 0
dirscount = 0
lg.warn('going to erase files: %s' % ids)
Expand Down
3 changes: 2 additions & 1 deletion transport/proxy/proxy_receiver.py
Expand Up @@ -751,7 +751,8 @@ def _on_request_service_ack(self, response, info):
lg.warn('%s was not found in pending requests: %s' % (response.PacketID, self.request_service_packet_id))
if _Debug:
lg.out(_DebugLevel, 'proxy_receiver._on_request_service_ack : %s' % str(response.Payload))
if not response.Payload.startswith('rejected'):
service_ack_info = strng.to_text(response.Payload)
if not service_ack_info.startswith('rejected'):
self.automat('service-accepted', (response, info))
else:
self.automat('service-refused', (response, info))
Expand Down

0 comments on commit a0bba32

Please sign in to comment.