Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port from Python 2.7 to Python 3 #2

Open
agtic opened this issue Jun 3, 2024 · 17 comments
Open

Port from Python 2.7 to Python 3 #2

agtic opened this issue Jun 3, 2024 · 17 comments
Assignees

Comments

@agtic
Copy link
Owner

agtic commented Jun 3, 2024

Port from Python 2.7 to Python 3

@agtic
Copy link
Owner Author

agtic commented Jun 25, 2024

This code base is in need of modernization.
An updated version of Raspbian in the container would also be helpful.

@Car85
Copy link

Car85 commented Jun 26, 2024

Hello!

I am getting familiar with this application. I have successfully launched it locally with Docker using the following Dockerfile and entrypoint.sh.

FROM --platform=linux/arm raspbian/systemd:latest
workdir /home/chronos

RUN echo "deb http://legacy.raspbian.org/raspbian stretch main contrib non-free rpi" > /etc/apt/sources.list
run apt-get update -y && apt-get install python2.7 python-pip cron sqlite3 nginx libssl-dev vim -y
run useradd pi
run mkdir -p /home/pi/chronos_db
run CFLAGS="-I/usr/include/openssl" && LDFLAGS="-L/usr/lib/arm-linux-gnueabihf" && UWSGI_PROFILE_OVERRIDE=ssl=true && pip install -trusted-host pypi.org --trusted-host files.pythonhosted.or -I --no-binary=:all: --no-cache-dir uwsgi==2.0.20
run pip install flask pyserial pymodbus APScheduler==3.6.3
run pip install --upgrade setuptools
run pip install sqlalchemy python-socketio==0.4.1 socketIO_client six==1.15.0
run pip install gevent
run pip install python-engineio==3.11.2 python-socketio==4.4.0
run pip install gevent-websocket


run apt-get install python3 python3-pip socat -y

copy . .
copy chronos.sql /home/pi/chronos_db/
run python setup.py install
run rm /etc/nginx/sites-enabled/default
run ln -s /etc/nginx/sites-enabled/chronos_conf /etc/nginx/sites-enabled/default
RUN pip install uwsgi
run /usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/socketio_server.ini --pidfile /var/run/uwsgi/uwsgi-socketio.pid --daemonize /var/log/uwsgi/uwsgi-socketio.log
run chmod +x entrypoint.sh

entrypoint [ "./entrypoint.sh" ]


#!/bin/bash
set -e 

socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0 PTY,link=/tmp/ttyp0,raw,echo=0 &
socat -d -d PTY,link=/tmp/ptyp1,raw,echo=0 PTY,link=/tmp/ttyp1,raw,echo=0 &
python2 working-sync-server.py /tmp/ttyp0 &


sudo chown pi:pi /tmp/ptyp0
sudo chown pi:pi /tmp/ptyp1
sudo chown -R pi:pi /home/pi

sleep 2
mkdir -p /var/log/uwsgi

/usr/local/bin/uwsgi --version

/usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/socketio_server.ini --pidfile /var/run/uwsgi/uwsgi-socketio.pid --daemonize /var/log/uwsgi/uwsgi-socketio.log

echo -e "YES\nt=100" > /tmp/water_in
echo -e "YES\nt=150" > /tmp/water_out


service uwsgi start
service nginx start
service chronos start

tail -f /dev/null

image

To approve a PR, the application would need to work without this installation in the Dockerfile, right?

apt-get install python2.7

Apart from updating Raspbian to the newest version known as Raspberry Pi OS.

https://www.raspberrypi.com/software/

Regards!

@agtic
Copy link
Owner Author

agtic commented Jun 27, 2024

Hi thanks for looking at this.

Glad the docker build worked for you.

To approve a PR, the application would need to work without this installation in the Dockerfile, right?

apt-get install python2.7

Yes, that's correct.

@agtic
Copy link
Owner Author

agtic commented Jun 27, 2024

Some suggestions from ChatGPT on how AI tools might make this easier

https://chatgpt.com/share/4d9c9346-8782-49f0-846a-47cc0e58a7e2

@Car85
Copy link

Car85 commented Jun 28, 2024

Would you assign the issue to me? I'm focused on resolving it. @agtic

thank you!

@agtic agtic assigned agtic and Car85 and unassigned agtic Jun 28, 2024
@agtic
Copy link
Owner Author

agtic commented Jun 28, 2024

Assigned as requested @Car85.
Keep me posted on your progress.
Also please monitor the progress on the other open issue on this repo to split the front and backend into separate repos: #1
@fardin-developer is working on it.

If you get stuck, it might make sense to wait until the other issue is completed.

@Anshgrover23
Copy link

@agtic plss review my pr

@agtic
Copy link
Owner Author

agtic commented Jul 4, 2024

@agtic plss review my pr

Thanks will take a look.
Migh be a few days. It's a holiday in the US

@Anshgrover23
Copy link

@agtic sure you can take your time. And let me know if any changes required I can do

@Car85
Copy link

Car85 commented Jul 8, 2024

As part of addressing this issue , I have created two separate repositories:

https://github.com/Car85/neo_chronos_frontend
https://github.com/Car85/neo_chronos_backend

While working on the upgrade to Python 3.12, it became necessary to separate the frontend from the backend and essentially rebuild the application from scratch. This approach also aligns with another ongoing issue aimed at separating the front end from the back end.

I fully respect the work being done in the other issue and understand that our approaches might differ. Should you decide that this path is not suitable for solving the current issues, I will completely understand and support the decision to discard this approach.

Thank you for considering this solution. I look forward to your feedback.

@Car85
Copy link

Car85 commented Jul 8, 2024

Currently, the application is not yet fully replicated; I have primarily implemented the update of the settings. The frontend development, using Preact and TypeScript, was necessary to visually test the development progress. For the backend, I am using Python 3.12, Flask, SQLite3, and SQLAlchemy.

@Car85
Copy link

Car85 commented Jul 8, 2024

I believe it is necessary to work on the domain of the application to generate issues that we can distribute among ourselves, using this proposed separation as a primitive skeleton.

@agtic
Copy link
Owner Author

agtic commented Jul 8, 2024

Thank you @Car85
I will take a look

@fardin-developer
Copy link

elieve it is necessary to work on the

I was working on separating the frontend and backend for another issue. Although I didn't upgrade the backend yet, I have already separated the frontend. Can you please upgrade the backend only? Otherwise, my previous work will be wasted.

@Car85
Copy link

Car85 commented Jul 9, 2024

elieve it is necessary to work on the

I was working on separating the frontend and backend for another issue. Although I didn't upgrade the backend yet, I have already separated the frontend. Can you please upgrade the backend only? Otherwise, my previous work will be wasted.

Completely agree with you. I just created the front-end to do my own tests, but if you take a look, you'll see it's very basic. I think we need to work on two repositories, one for the front-end and one for the back-end, which should be uploaded to @agtic s GitHub account, as he was the one who proposed the modernization of Chronos. We should start working based on domain-specific issues. Obviously, we would need to coordinate. Best regards.

@agtic
Copy link
Owner Author

agtic commented Aug 13, 2024

@Car85 Just making sure you saw the issue I opened on your backend_repo
Car85/neo_chronos_backend#2

@Car85
Copy link

Car85 commented Aug 14, 2024

Yes, I’ve seen it. I’ll make a commit at the beginning of next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@fardin-developer @agtic @Anshgrover23 @Car85 and others