Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
works but it doesn't
#1
Hi hopping you can help me solve a mystery.
I wrote a program to automaticity back up my media system. It does a few other things too, like keeping a log of what has been updated and being able to bring up a file count of all directory and there back ups.

The system is actually two programs. There is a frontend this is a small program that is opened in terminal, its basically a remote control for the backend. you open it when you need to check something, then close it after.

The backend is the heart of the program and is running in the background all the time.

This system is working flawlessly. But you have to start both programs individually. I thought it would be much neater to have a one click starts both programs. the script below starts the frontend in terminal, but before doing so checks to see if the backend is running, if not it starts it. When you close the frontend the backend remains running.

The script below works perfectly on my main system, the one I wrote it on. But when I transfer it to my media system, the backend fails to stay running when you close the front end.

Both systems are basically the same, both are ubuntu 18.4 both have python 3.
the only tiny difference I can find in the system is that my main system has python 3.6.9 the media system is python 3.6.8. can't believe this would make a difference.

Any ideas would be great thanks.

#!/usr/bin/python3

import subprocess
import socket
import os

try:
    clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    clientsocket.connect(('localhost', 8085))
except socket.error:
    subprocess.Popen([os.path.dirname(os.path.realpath(__file__))+"/backupnew1.py", "-a", "arg1", "-b", "arg2"])

p=subprocess.Popen(["gnome-terminal","--",os.path.dirname(os.path.realpath(__file__))+"/backup-client1.py"])
p.wait()
Reply
#2
(Feb-01-2020, 04:00 PM)benlyboy Wrote: The script below works perfectly on my main system, the one I wrote it on. But when I transfer it to my media system, the backend fails to stay running when you close the front end.
When you say main and media systems, what are you referring to?

(Feb-01-2020, 04:00 PM)benlyboy Wrote: When you close the frontend the backend remains running.
Your going to have to get the PID when running the process to close it later.

I am assuming that both py files: one is the backend and the other is the front end?
Recommended Tutorials:
Reply
#3
Main is the computer on my desk, the one that i used when i wrote the code, the media is my media box which is what i wrote the code for.
Yes the file referenced in the "except" is the backend the later one in the code is the frontend.
Reply
#4
Hi all, well I thought i had it but..not quite Cry

[
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code works but doesn't give the right results colin_dent 2 674 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 1,928 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Gravity doesn't works, and my character just moves right and really fast izmamonke 1 1,496 Aug-08-2021, 02:55 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020