Skip to content

Commit

Permalink
few more py3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vesellov committed Dec 7, 2018
1 parent af3624b commit 16dff9b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion automats/automat.py
Expand Up @@ -695,7 +695,7 @@ def executeStateChangedCallbacks(self, oldstate, newstate, event_string, args):
"""
Compare conditions and execute state changed callback methods.
"""
for key, cb_list in (self._state_callbacks.items() + self._callbacks_before_die.items()):
for key, cb_list in list(self._state_callbacks.items()) + list(self._callbacks_before_die.items()):
old, new = key
catched = False
if old is None and new is None:
Expand Down
16 changes: 11 additions & 5 deletions contacts/contactsdb.py
Expand Up @@ -557,7 +557,9 @@ def save_suppliers(path=None, customer_idurl=None):
global_id.UrlToGlobalID(customer_idurl),
'supplierids',
)
bpio._write_list(path, suppliers(customer_idurl=customer_idurl))
lst = suppliers(customer_idurl=customer_idurl)
lst = list(map(strng.to_text, lst))
bpio._write_list(path, lst)
return True

def load_suppliers(path=None, customer_idurl=None, all_customers=False):
Expand All @@ -574,6 +576,7 @@ def load_suppliers(path=None, customer_idurl=None, all_customers=False):
if lst is None:
lg.warn('did not found suppliers ids at %s' % path)
continue
lst = list(map(strng.to_bin, lst))
set_suppliers(lst, customer_idurl=global_id.GlobalUserToIDURL(customer_id))
lg.out(4, 'contactsdb.load_suppliers %d items from %s' % (len(lst), path))
return True
Expand All @@ -585,6 +588,7 @@ def load_suppliers(path=None, customer_idurl=None, all_customers=False):
lst = bpio._read_list(path)
if lst is None:
lst = list()
lst = list(map(strng.to_bin, lst))
set_suppliers(lst)
lg.out(4, 'contactsdb.load_suppliers %d items from %s' % (len(lst), path))
return True
Expand All @@ -599,7 +603,9 @@ def save_customers(path=None, save_meta_info=False):
global _CustomersMetaInfo
if path is None:
path = settings.CustomerIDsFilename()
bpio._write_list(path, customers())
lst = customers()
lst = list(map(strng.to_text, lst))
bpio._write_list(path, lst)
if save_meta_info:
local_fs.WriteTextFile(settings.CustomersMetaInfoFilename(), jsn.dumps(_CustomersMetaInfo))

Expand All @@ -614,6 +620,7 @@ def load_customers(path=None):
lst = bpio._read_list(path)
if lst is None:
lst = list()
lst = list(map(strng.to_bin, lst))
set_customers(lst)
_CustomersMetaInfo = jsn.loads(
local_fs.ReadTextFile(settings.CustomersMetaInfoFilename()) or '{}'
Expand All @@ -629,9 +636,8 @@ def save_correspondents(path=None):
"""
if path is None:
path = settings.CorrespondentIDsFilename()
bpio._write_list(path, ["%s %s" % (
strng.to_text(t[0]), strng.to_text(t[1]),)
for t in correspondents()])
lst = ["%s %s" % (strng.to_text(t[0]), strng.to_text(t[1]),) for t in correspondents()]
bpio._write_list(path, lst)


def load_correspondents(path=None):
Expand Down
37 changes: 17 additions & 20 deletions regression/tests/test_role_customer/test_file_upload_download.py
@@ -1,11 +1,10 @@
import time
import os
import json
import base64
import hashlib
import requests

from ..utils import tunnel_url, run_ssh_command_and_wait, run_ssh_curl_and_wait
from ..utils import tunnel_url, run_ssh_command_and_wait


def get_hash(path):
Expand Down Expand Up @@ -46,45 +45,43 @@ def test_customer_1_upload_download_file_with_master():

response = requests.post(
url=tunnel_url('customer_1', 'file/create/v1'),
json={'remote_path': remote_path,}
json={
'remote_path': remote_path,
},
)
assert response.json()['status'] == 'OK', response.json()

response = run_ssh_curl_and_wait(
host='customer_1',
method='POST',
url='localhost:8180/file/upload/start/v1',
body=json.dumps({
response = requests.get(
url=tunnel_url('customer_1', 'file/upload/start/v1'),
json={
'remote_path': remote_path,
'local_path': directory_local_file,
'wait_result': 'true',
}),
},
)
assert response['status'] == 'OK', response
assert response.json()['status'] == 'OK', response.json()

for _ in range(100):
response = run_ssh_curl_and_wait(
host='customer_1',
method='POST',
url='localhost:8180/file/download/start/v1',
body=json.dumps({
response = requests.get(
url=tunnel_url('customer_1', 'file/download/start/v1'),
json={
'remote_path': remote_path,
'destination_folder': download_volume,
'wait_result': 'true',
}),
},
)
if response['status'] == 'OK':
if response.json()['status'] == 'OK':
break

if response['errors'][0].startswith('download not possible, uploading'):
if response.json()['errors'][0].startswith('download not possible, uploading'):
print('file is not ready for download: retry again in 1 sec')
time.sleep(1)
else:
assert False, response
assert False, response.json()

else:
print('download was not successful')
assert False, response
assert False, response.json()

assert os.path.exists(directory_dowloaded_file)

Expand Down

0 comments on commit 16dff9b

Please sign in to comment.