[REM] hw_drivers, hw_posbox_homepage, pos: Remove MPD

Remove the MPD server and Six configuration from the IoT Box.
MPD will be replaced by TIM, which doesn't require the IoT Box.

closes odoo/odoo#46424

Taskid: 2188566
X-original-commit: 9d43308a8f6b521d3d18f7fc472303f58f56a0c3
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
This commit is contained in:
Antoine Prieels
2020-02-27 11:17:15 +00:00
parent f0def7414d
commit a200c6ddf8
6 changed files with 0 additions and 131 deletions
-32
View File
@@ -427,7 +427,6 @@ class Manager(Thread):
while 1:
updated_devices = self.usb_loop()
updated_devices.update(self.video_loop())
updated_devices.update(mpdm.devices)
updated_devices.update(display_devices)
updated_devices.update(bt_devices)
updated_devices.update(socket_devices)
@@ -494,42 +493,11 @@ class SocketManager(Thread):
except OSError as e:
_logger.error(_('Error in SocketManager: %s') % (e.strerror))
class MPDManager(Thread):
def __init__(self):
super(MPDManager, self).__init__()
self.devices = {}
self.mpd_session = ctypes.c_void_p()
def run(self):
eftapi.EFT_CreateSession(ctypes.byref(self.mpd_session))
while True:
if self.terminal_connected(terminal_id):
self.devices[terminal_id] = IoTDevice(terminal_id, 'mpd')
elif terminal_id in self.devices:
self.devices = {}
time.sleep(20)
def terminal_connected(self, terminal_id):
eftapi.EFT_QueryStatus(self.mpd_session)
device_status = ctypes.c_long()
eftapi.EFT_GetDeviceStatusCode(self.mpd_session, ctypes.byref(device_status))
return device_status.value in [0, 1]
conn = cups_connection()
PPDs = conn.getPPDs()
printers = conn.getPrinters()
cups_lock = Lock() # We can only make one call to Cups at a time
mpdm = MPDManager()
terminal_id = helpers.read_file_first_line('odoo-six-payment-terminal.conf')
subprocess.call(["pkill", "-9", "eftdvs"]) # Kill any running MPD server
if terminal_id:
subprocess.Popen(["eftdvs", "/ConfigDir", "/usr/share/eftdvs/", "/TID", terminal_id]) # Start MPD server
eftapi = ctypes.CDLL("eftapi.so") # Library given by Six
mpdm.daemon = True
mpdm.start()
m = Manager()
m.daemon = True
m.start()
@@ -46,7 +46,6 @@ wifi_config_template = jinja_env.get_template('wifi_config.html')
driver_list_template = jinja_env.get_template('driver_list.html')
remote_connect_template = jinja_env.get_template('remote_connect.html')
configure_wizard_template = jinja_env.get_template('configure_wizard.html')
six_payment_terminal_template = jinja_env.get_template('six_payment_terminal.html')
list_credential_template = jinja_env.get_template('list_credential.html')
upgrade_page_template = jinja_env.get_template('upgrade_page.html')
@@ -58,10 +57,6 @@ class IoTboxHomepage(web.Home):
def clean_partition(self):
subprocess.check_call(['sudo', 'bash', '-c', '. /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/upgrade.sh; cleanup'])
def get_six_terminal(self):
terminal_id = helpers.read_file_first_line('odoo-six-payment-terminal.conf')
return terminal_id or 'Not Configured'
def get_homepage_data(self):
hostname = str(socket.gethostname())
mac = get_mac()
@@ -92,7 +87,6 @@ class IoTboxHomepage(web.Home):
'mac': ":".join(i + next(h) for i in h),
'iot_device_status': iot_device,
'server_status': helpers.get_odoo_server_url() or 'Not Configured',
'six_terminal': self.get_six_terminal(),
'network_status': network,
'version': helpers.get_version(),
}
@@ -270,26 +264,6 @@ class IoTboxHomepage(web.Home):
else:
return 'already running'
@http.route('/six_payment_terminal', type='http', auth='none', cors='*', csrf=False)
def six_payment_terminal(self):
return six_payment_terminal_template.render({
'title': 'Six Payment Terminal',
'breadcrumb': 'Six Payment Terminal',
'terminalId': self.get_six_terminal(),
})
@http.route('/six_payment_terminal_add', type='http', auth='none', cors='*', csrf=False)
def add_six_payment_terminal(self, terminal_id):
helpers.write_file('odoo-six-payment-terminal.conf', terminal_id)
subprocess.check_call(["sudo", "service", "odoo", "restart"])
return 'http://' + helpers.get_ip() + ':8069'
@http.route('/six_payment_terminal_clear', type='http', auth='none', cors='*', csrf=False)
def clear_six_payment_terminal(self):
helpers.unlink_file('odoo-six-payment-terminal.conf')
subprocess.check_call(["sudo", "service", "odoo", "restart"])
return "<meta http-equiv='refresh' content='0; url=http://" + helpers.get_ip() + ":8069'>"
@http.route('/hw_proxy/upgrade', type='http', auth='none', )
def upgrade(self):
commit = subprocess.check_output(["git", "--work-tree=/home/pi/odoo/", "--git-dir=/home/pi/odoo/.git", "log", "-1"]).decode('utf-8').replace("\n", "<br/>")
@@ -110,12 +110,6 @@
<td class="heading">Server</td>
<td><a href='{{ server_status }}' target=_blank>{{ server_status }}<a class="btn btn-sm float-right" href='/server'>configure</a></td>
</tr>
{% if server_status != "Not Configured" %}
<tr>
<td class="heading">Six payment terminal</td>
<td>{{ six_terminal }} <a class="btn btn-sm float-right" href='/six_payment_terminal'>configure</a></td>
</tr>
{% endif %}
<tr>
<td class="heading">IOT Device</td>
<td>
@@ -1,61 +0,0 @@
{% extends "layout.html" %}
{% from "loading.html" import loading_block_ui %}
{% block head %}
<script>
var _onQueryDone = function () {
$('.message-status').html('Updated configuration <br> Refreshing page');
setTimeout(function () {
location.reload();
}, 30000);
}
$(document).ready(function () {
$('#terminal-id').submit(function(e){
e.preventDefault();
$('.loading-block').removeClass('o_hide');
$.ajax({
url: '/six_payment_terminal_add',
type: 'post',
data: $('#terminal-id').serialize(),
}).always(_onQueryDone);
});
$('#terminal-clear').submit(function(e){
e.preventDefault();
$('.loading-block').removeClass('o_hide');
$.ajax({
url: '/six_payment_terminal_clear',
type: 'get',
}).always(_onQueryDone);
});
});
</script>
{% endblock %}
{% block content %}
<h2 class="text-center">Six Payment Terminal</h2>
<p>
Set the Terminal ID (TID) of the terminal you want to use.
</p>
<form id="terminal-id" action='/six_payment_terminal_add' method='POST'>
<table align="center">
<tr>
<td>Terminal ID</td>
<td><input type="text" name="terminal_id"></td>
</tr>
<tr>
<td/>
<td><input class="btn" type="submit" value="Connect"/></td>
</tr>
</table>
{{ loading_block_ui(loading_message) }}
</form>
{% if terminalId %}
<p class="text-center font-small">
Current Terminal Id: <strong>{{ terminalId }}</strong>
</p>
<div class="text-center font-small" style="margin: 10px auto;">
You can clear the terminal configuration
<form id="terminal-clear" style="display: inline-block;margin-left: 4px;">
<input class="btn btn-sm" type="submit" value="Clear"/>
</form>
</div>
{% endif %}
{% endblock %}
@@ -1 +0,0 @@
/Trace logstd /TraceDir /var/log/eftdvs
@@ -121,11 +121,6 @@ PIP_TO_INSTALL="
pip3 install ${PIP_TO_INSTALL}
# Dowload MPD server and library for Six terminals
wget 'https://nightly.odoo.com/master/iotbox/eftdvs' -P /usr/local/bin/
chmod +x /usr/local/bin/eftdvs
wget 'https://nightly.odoo.com/master/iotbox/eftapi.so' -P /usr/lib/
groupadd usbusers
usermod -a -G usbusers pi
usermod -a -G lp pi