Is there anything in the script which could cause it to not run its full course please?

ozstar1 at gmail.com ozstar1 at gmail.com
Sun May 3 21:33:17 EDT 2020


Hi,

A nooby here and I could do with some help in finding out what, if anything, is wrong with the script

Is there anything in this script that could cause the stream to stop before the allocated time? 

For example the time.txt file which gives the times to the script, shows the time to start and run, like this..

04-05-2020 09:30:00 40
04-05-2020 12:30:00 40
04-05-2020 15:30:00 40
04-05-2020 22:30:00 40

When I run the the stream manually not using the script, it runs the full 40 mins length however as soon as I use the script, it stops the stream a few minutes in. It is not any specific time, just a random time.

I see my two options are..
something in the script or
something going on in the PC background, although it doesn't do it when I don't use the script.

Please help and I am not sure where else to go as it does seem like a script or python event.

Thank you



---------------------
import time
import datetime
import sys
from pynput.mouse import Button, Controller
class Autostreaming(object):
 
    def __init__(self):
        self.mouse = Controller()
        pass
         
    def startstreaming(self):
        #load text file 
        time_file = open("time.txt", "r")
        for date_time_duration in time_file.readlines():
            input_date,input_time,input_duration=date_time_duration.split(' ')
            current_datetime = datetime.datetime.now()
            current_date = current_datetime.strftime('%d-%m-%Y')
            if(input_date>=current_date):
                while(True):
                    _time = datetime.datetime.now()
                    current_time= _time.strftime('%H:%M:%S')
                    if(input_time==current_time):
                        #self.mouse.position = (1912,594)
                        #self.mouse.click(Button.left,1)
                        #time.sleep(2)
                        self.mouse.position = (1250,710)
                        self.mouse.click(Button.left,1)
                        time.sleep(2)
                        self.mouse.position = (1824,1136)
                        self.mouse.click(Button.left,1)
                        time.sleep(2)
                        self.mouse.position = (1587,37)
                        self.mouse.click(Button.left,1)
                        time.sleep(2)
                        self.mouse.position = (1250,710)
                        self.mouse.click(Button.left,1)
                        time.sleep(2)
                        #self.mouse.position = (1202, 806)
                        #self.mouse.click(Button.left,1)
                        print("streaming........")
                        time.sleep(int(input_duration)*60)#please put your streaming function 
                        self.mouse.position = (1824,1136)
                        self.mouse.click(Button.left,1)
                        break
                    elif(input_time>current_time):
                        print('Waiting for the next stream to start at {}'.format(input_time)+" hrs on {}".format(input_date))
                        time.sleep(1)
                        continue
                    elif(input_date>current_date and input_time<current_time):
                        print('Waiting for the next stream to start at {}'.format(input_time)+" hrs on {}".format(input_date))
                        time.sleep(1)
                        continue
                    else:
                        break
                else:
                    pass
                     
        time_file.close()
        _msg = "All streaming task finished"
        return _msg
 
    def stopstreaming(self):
        print("streaming stoped")
        return sys.exit()
         
 
start_streaming = Autostreaming().startstreaming()


More information about the Python-list mailing list