fix when error conection network
This commit is contained in:
parent
cde0f93520
commit
372b706ade
37
app/main.py
37
app/main.py
|
@ -142,17 +142,12 @@ class AppWindow(FrontWindow):
|
|||
version = compare_versions(self.modules['sale_pos_frontend_rest']['version'], '6.0.7')
|
||||
if version in ('equal', 'higher'):
|
||||
if self.tasks_station:
|
||||
try:
|
||||
result = self.SaleLine.get_data_command_and_task(args)
|
||||
result = self.SaleLine.get_data_command_and_task(args)
|
||||
if isinstance(result, dict):
|
||||
orders = result.get('orders', [])
|
||||
tasks = result.get('tasks', [])
|
||||
except Exception:
|
||||
logger.exception('Error de conexion internet obtener tareas y comandas')
|
||||
else:
|
||||
try:
|
||||
orders = self.SaleLine.get_data_command(args)
|
||||
except Exception:
|
||||
logger.exception('Error de conexion internet obtener comanda')
|
||||
orders = self.SaleLine.get_data_command(args)
|
||||
# TODO: for remove this option
|
||||
else:
|
||||
logger.warning('The backend sale_pos_frontend_rest is deprecation, update version')
|
||||
|
@ -161,20 +156,20 @@ class AppWindow(FrontWindow):
|
|||
orders += record['orders'].values()
|
||||
tasks += record['tasks'].values()
|
||||
|
||||
try:
|
||||
result = self.receipt_order.print_orders(orders)
|
||||
if result:
|
||||
self.Sale.mark_commanded({'lines_ids': result})
|
||||
except Exception:
|
||||
logger.exception('Error de conexion internet al marcar tareas')
|
||||
result = self.receipt_order.print_orders(orders)
|
||||
if result:
|
||||
status = 'error_network'
|
||||
while status == 'error_network':
|
||||
status = self.Sale.mark_commanded({'lines_ids': result})
|
||||
time.sleep(1)
|
||||
|
||||
try:
|
||||
receipt = Receipt(context={}, environment='restaurant')
|
||||
result_print = receipt.print_tasks(tasks)
|
||||
if any(result_print):
|
||||
self.SaleLine.mark_tasks_printed({'task_ids': result_print})
|
||||
except Exception:
|
||||
logger.exception('Error de conexion internet al comandado')
|
||||
receipt = Receipt(context={}, environment='restaurant')
|
||||
result_task = receipt.print_tasks(tasks)
|
||||
if any(result_task):
|
||||
status = 'error_network'
|
||||
while status == 'error_network':
|
||||
status = self.SaleLine.mark_tasks_printed({'task_ids': result_task})
|
||||
time.sleep(1)
|
||||
time.sleep(30)
|
||||
# timer = QTimer()
|
||||
# timer.singleShot(30000, self.verify_print_order_automatic)
|
||||
|
|
33
app/proxy.py
33
app/proxy.py
|
@ -44,9 +44,9 @@ def logout(ctx):
|
|||
host = ctx['params']['server']
|
||||
db = ctx['params']['database']
|
||||
if ctx['params']['mode'] == 'http':
|
||||
conn = HTTPConnection(host, port=port)
|
||||
conn = HTTPConnection(host, port=port, timeout=30)
|
||||
else:
|
||||
conn = HTTPSConnection(host, port=port, context=context_http)
|
||||
conn = HTTPSConnection(host, port=port, timeout=30, context=context_http)
|
||||
url = '/' + db + '/logout'
|
||||
payload = json.dumps({
|
||||
'context': {
|
||||
|
@ -204,20 +204,25 @@ class Model(object):
|
|||
conn = self.conn(
|
||||
self.host,
|
||||
port=self.port,
|
||||
timeout=30,
|
||||
context=self.context_http)
|
||||
else:
|
||||
conn = self.conn(self.host, port=self.port)
|
||||
conn.request(method, url, body=payload, headers=HEADERS)
|
||||
response = conn.getresponse()
|
||||
res = json.loads(response.read())
|
||||
if response.status != 200:
|
||||
logging.error(f'error request {str(res)}')
|
||||
if self.main_window and hasattr(self.main_window, 'statusbar'):
|
||||
self.main_window.dialog(
|
||||
'error_server',
|
||||
extra_message=res['detail']['error'])
|
||||
res = res['detail']
|
||||
conn.close()
|
||||
conn = self.conn(self.host, port=self.port, timeout=30)
|
||||
res = 'error_network'
|
||||
try:
|
||||
conn.request(method, url, body=payload, headers=HEADERS)
|
||||
response = conn.getresponse()
|
||||
res = json.loads(response.read())
|
||||
if response.status != 200:
|
||||
logging.error(f'error request {str(res)}')
|
||||
if self.main_window and hasattr(self.main_window, 'statusbar'):
|
||||
self.main_window.dialog(
|
||||
'error_server',
|
||||
extra_message=res['detail']['error'])
|
||||
res = res['detail']
|
||||
conn.close()
|
||||
except Exception:
|
||||
logging.exception('error de conexion')
|
||||
return res
|
||||
|
||||
def __call__(self, values=None, args=None, ctx=None):
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "6.0.26"
|
||||
__version__ = "6.0.27"
|
||||
|
|
Loading…
Reference in New Issue