OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Custom Additions to Interval Program for OSPi? Re: Re: Custom Additions to Interval Program for OSPi?

#24605

djagerif
Participant

Thanks for making me investigate further. By changing the ospi.py urls variable to a ‘list’ variable I am now able to extend the list from the custom.py script.

The ospi.py script change below, notice just the urls variable change and the addition of the custom script section.


urls = [
'/', 'home',
'/cv', 'change_values',
'/vo', 'view_options',
'/co', 'change_options',
'/vs', 'view_stations',
'/cs', 'change_stations', # name and master
'/sn(d+?Z)', 'get_station', # regular expression, accepts any station number
'/sn(d+?=d(&t=d+?Z)?)', 'set_station', # regular expression, accepts any digits
'/vr', 'view_runonce',
'/cr', 'change_runonce',
'/vp', 'view_programs',
'/mp', 'modify_program', # open 'Modify program' window
'/cp', 'change_program',
'/dp', 'delete_program',
'/gp', 'graph_programs',
'/vl', 'view_log',
'/cl', 'clear_log',
'/lo', 'log_options1',
]

#### Load Custom Import file if it exists ####
try:
with open('./custom.py'):
import custom

except IOError:
print 'Custom Imports not found.'

And in the custom.py script I have the following:

import ospi

ospi.urls.extend()

class custom_1:
"""View all the options above and also station names."""
def GET(self):
custpg = 'n'
custpg += 'n'
custpg += 'n'
custpg += 'n'
return custpg

class custom_2:
""" Custom Script 2 """
def GET(self):
custpg = 'n'
#Insert Custom Code here.
return custpg

class custom_3:
""" Custom Script 3 """
def GET(self):
custpg = 'n'
#Insert Custom Code here.
return custpg