Skip to content

Commit a0ce9e0

Browse files
committed
refactoring
1 parent 5321815 commit a0ce9e0

4 files changed

Lines changed: 84 additions & 62 deletions

File tree

Dockerfile

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
# Use an official Python runtime as a parent image
2-
FROM python:3.13-slim-buster
3-
4-
# Set the working directory in the container
5-
WORKDIR /app
6-
7-
# Install additional dependencies for wxPython
8-
RUN apt-get update && apt-get install -y build-essential libgtk-3-dev
9-
RUN pip install --upgrade pip
10-
11-
RUN pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/debian-9 wxPython
12-
13-
# RUN pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython
14-
15-
COPY requirements.txt requirements.txt
16-
RUN pip install -r requirements.txt
17-
18-
# Copy the local wxPython app source code into the container
19-
COPY . .
20-
21-
# Set the display environment variable for GUI support
22-
ENV DISPLAY=:0
23-
24-
# Run the wxPython GUI app
25-
CMD ["python", "devsimpy.py"]
1+
# Utiliser une base Ubuntu
2+
FROM ubuntu:22.04
3+
4+
# Mettre à jour et installer les dépendances nécessaires
5+
RUN apt-get update && apt-get install -y \
6+
xfce4 xfce4-goodies \
7+
x11vnc xvfb \
8+
python3 python3-pip python3-venv \
9+
supervisor wget curl git \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Installer noVNC
13+
RUN mkdir -p /opt/novnc \
14+
&& git clone https://github.com/novnc/noVNC.git /opt/novnc \
15+
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
16+
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
17+
18+
# Installer TigerVNC
19+
RUN apt-get update && apt-get install -y tigervnc-standalone-server
20+
21+
# Installer DEVSimPy
22+
RUN python3 -m venv /opt/devsimpy-env \
23+
&& /opt/devsimpy-env/bin/pip install --upgrade pip \
24+
&& /opt/devsimpy-env/bin/pip install devsimpy wxpython
25+
26+
# Configurer un mot de passe VNC (par défaut "password")
27+
RUN mkdir -p /root/.vnc \
28+
&& echo "password" | vncpasswd -f > /root/.vnc/passwd \
29+
&& chmod 600 /root/.vnc/passwd
30+
31+
# Configurer Supervisor pour gérer les services
32+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
33+
34+
# Exposer les ports VNC et noVNC
35+
EXPOSE 5901 6080
36+
37+
# Lancer les services
38+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

devsimpy/PreferencesGUI.py

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,11 @@ def OnwxPythonVersionChanged(self, event):
264264

265265
### if ini file exist we remove old section and option
266266
if os.path.exists(path):
267-
try:
267+
if parser.has_option(section, option):
268268
parser.remove_option(section, option)
269-
except:
270-
pass
271-
try:
269+
if parser.has_section(section):
272270
parser.remove_section(section)
273-
except:
274-
pass
275-
try:
276-
parser.add_section(section)
277-
except:
278-
pass
271+
parser.add_section(section)
279272

280273
if not parser.has_section(section):
281274
parser.add_section(section)
@@ -400,21 +393,15 @@ def InitUI(self):
400393
def OnAbout(self, evt):
401394
""" Search doc directory into 'doc' directory of DEVS package
402395
"""
403-
### DEVS package
404396
choice = self.cb3.GetValue()
397+
doc_path = os.path.join(os.path.dirname(getattr(builtins, 'DEVS_DIR_PATH_DICT').get(choice)), 'doc', 'index.html')
405398

406-
### possible path of doc directory
407-
path = os.path.join(os.path.dirname(getattr(builtins,'DEVS_DIR_PATH_DICT').get(choice)), 'doc', 'index.html')
408-
409-
### Html frame
410-
frame = HtmlFrame(self, wx.NewIdRef(), "Doc", (600,600))
411-
### if page exist in <package_dir>/<doc>
412-
if os.path.exists(path):
413-
frame.LoadFile(path)
399+
frame = HtmlFrame(self, wx.NewIdRef(), "Doc", (600, 600))
400+
if os.path.exists(doc_path):
401+
frame.LoadFile(doc_path)
414402
else:
415-
frame.SetPage(_("<p> %s documentation directory not found! <p>")%choice)
403+
frame.SetPage(_("<p> %s documentation directory not found! <p>") % choice)
416404

417-
### Show frame
418405
frame.Show()
419406

420407
def OnSelectSound(self, evt):
@@ -463,8 +450,7 @@ def onCb1Check(self, evt):
463450
def onCb4(self, evt):
464451
""" ComboBox has been checked.
465452
"""
466-
val = evt.GetEventObject().GetValue()
467-
self.sim_defaut_strategy = val
453+
self.sim_defaut_strategy = evt.GetEventObject().GetValue()
468454

469455
def onCb3(self, evt):
470456
""" ComboBox has been checked.
@@ -490,8 +476,7 @@ def onCb3(self, evt):
490476
def onSc(self, evt):
491477
""" CheckBox has been checked.
492478
"""
493-
val = evt.GetEventObject().GetValue()
494-
self.sim_defaut_plot_dyn_freq = val
479+
self.sim_defaut_plot_dyn_freq = evt.GetEventObject().GetValue()
495480

496481
def OnApply(self, evt):
497482
""" Apply changes.
@@ -559,11 +544,7 @@ def InitUI(self):
559544
choices = []
560545

561546
for editor in EditorPanel.EDITORS:
562-
try:
563-
importlib.import_module(editor)
564-
except:
565-
pass
566-
else:
547+
if importlib.util.find_spec(editor) is not None:
567548
choices.append(editor)
568549

569550
### add the choice object to select one external code editor
@@ -602,17 +583,16 @@ def OnUpdateExternalEditors(self, event):
602583
""" Update Button has been clicked in order to update the list of available external editors.
603584
"""
604585

605-
installed = False
586+
installed_editors = []
606587
for editor in EditorPanel.EDITORS:
607588
if self.choice.FindString(editor) == wx.NOT_FOUND and BuzyCursorNotification(install(editor)):
608-
installed = True
609-
items = self.choice.GetItems()+[editor]
610-
self.choice.SetItems(items)
589+
installed_editors.append(editor)
611590

612-
if installed:
613-
msg = _('You need to restart DEVSimPy to use the new installed code editor.')
591+
if installed_editors:
592+
self.choice.AppendItems(installed_editors)
593+
msg = _('You need to restart DEVSimPy to use the newly installed code editor(s).')
614594
else:
615-
msg = _('All external editors are installed.')
595+
msg = _('All external editors are already installed.')
616596

617597
dial = wx.MessageDialog(self.parent, msg, _("External Code Editor Installation"), wx.OK | wx.ICON_INFORMATION)
618598
dial.ShowModal()

devsimpy/searchTreeList.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import sys
33

44
class TreeItem(object):
5+
"""
6+
"""
57
def __init__(self, text, data=None, filterable=True):
68
self._children = []
79
self._text = text

supervisord.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:Xvfb]
5+
command=Xvfb :1 -screen 0 1920x1080x24
6+
autostart=true
7+
autorestart=true
8+
9+
[program:fluxbox]
10+
command=fluxbox
11+
autostart=true
12+
autorestart=true
13+
14+
[program:x11vnc]
15+
command=x11vnc -display :1 -forever -shared -rfbport 5901 -passwd password
16+
autostart=true
17+
autorestart=true
18+
19+
[program:noVNC]
20+
command=/opt/novnc/utils/novnc_proxy --vnc localhost:5901 --listen 6080
21+
autostart=true
22+
autorestart=true
23+
24+
[program:devsimpy]
25+
command=python /app/devsimpy.py
26+
autostart=true
27+
autorestart=true

0 commit comments

Comments
 (0)