Help for Scripting my AVI camera

Discussions on extending SharpCap using the built in Python scripting functionality
DavidCollings
Posts: 7
Joined: Thu Apr 20, 2017 4:21 am

Re: Help for Scripting my AVI camera

#11

Post by DavidCollings »

Hi Robin,

I am almost done with the entire 2017 Solar Eclipse program but I can not get the code you sent to work regarding the time/delay per the clock.
I get an error on line 5..... AttributeError: 'module' object has no attribute 'now' .
Also saw an error with datetime.combine ......AttributeError: 'module' object has no attribute 'combine'

I am probably doing something wrong with the code below you sent because I am just learning all of this. Can you steer me the right direction to get it to work? I typed it in exactly as you have it but changed the time in line 6 to be future by a couple minutes to see if the time.sleep delay works but it crashes early on in the code.
My goal was to have delay code in the beginning to wait until a certain clock time (11:59:30 AM) to execute my first Capture. Other places in the program I will need delay code for certain clock times as well. (3 places)

When I get this delay until clock is at time ##:##:## part working I will have the entire program finished for capturing the 2017 Solar Eclipse on August 21st using my 9MP Hi-Res camera. I will be sitting on the center line in western Tennessee recording the whole 3 hrs in 3 minute increments, 15 sec AVI's at high resolution HA with my Lunt Telescope. I will gladly share this program on here for all that could use it. It would only need slight modifications in times depending on where you are during the eclipse.
I will be making a complete movie from all my captured AVI frames after stacking and tweaking. It will be in Hi_Res color as well with tremendous surface detail and any prominence's and flares during the eclipse.

Thanks again, I look forward to hearing from you.
Dave

import datetime
import time
from datetime import date, time

now = datetime.now()
# Calculate the datetime representing 22:30 today -
later = datetime.combine(date.today(), time(22,30))

delay=(later-now).total_seconds()
time.sleep(delay)
User avatar
admin
Site Admin
Posts: 13173
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Help for Scripting my AVI camera

#12

Post by admin »

Hi David,

this is made a bit complicated by naming clashes - there is a module called 'datetime' which has a class called 'datetime' and a class called 'time', both of which we need. There is also a module called 'time' which contains the method 'sleep' which we need. Too many imports makes it easy to get python muddled between the different things with the same name, so perhaps this is the best approach

Code: Select all

import time
import datetime

# call function 'now' on the class datetime in the module datetime
now = datetime.datetime.now()
# Calculate the datetime representing 22:30 today -
# use the classes date and time in the module date time, also the method combine on the class datetime in the module datetime
later = datetime.datetime.combine(datetime.date.today(), datetime.time(22,30))

delay=(later-now).total_seconds()
# because we never tried to import time from module datetime, we can call time.sleep (which is the function sleep in the module time)
time.sleep(delay)
I'm sure there must be a better way out of this mess, but I'm not really a professional python programmer (SharpCap is written in C#). Python was a convenient language to choose for scripting as it is fairly simple (most of the time) and has wide uptake.

Hope this helps,

Robin
DavidCollings
Posts: 7
Joined: Thu Apr 20, 2017 4:21 am

Re: Help for Scripting my AVI camera

#13

Post by DavidCollings »

Thank you Robin!! :D

The delay/clock code works perfectly. I will add it where it needs to be in the total program at various places.

I will publish my Solar Eclipse program under scripting in this forum in the next few hours. I think others may like to use it with only easy time changes depending on location.
Thank you Robin for all the help....this has been fun learning the basics and then some!

Dave Collings
www.blueridge-observatory.net
Post Reply