当前位置: 首页>>代码示例>>Python>>正文


Python urls.extend函数代码示例

本文整理汇总了Python中urls.urls.extend函数的典型用法代码示例。如果您正苦于以下问题:Python extend函数的具体用法?Python extend怎么用?Python extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了extend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: weather_to_delay

# !/usr/bin/env python
from random import randint
import thread

import web, json, time, re
import gv # Get access to ospy's settings
import urllib, urllib2
from urls import urls # Get access to ospy's URLs
from gpio_pins import set_output
from ospy import template_render
from webpages import ProtectedPage

urls.extend(['/wa', 'plugins.weather_adj.settings', '/wj', 'plugins.weather_adj.settings_json', '/uwa', 'plugins.weather_adj.update']) # Add a new url to open the data entry page.
gv.plugin_menu.append(['Weather-based Rain Delay', '/wa']) # Add this plugin to the home page plugins menu

def weather_to_delay(run_loop=False):
    if run_loop:
        time.sleep(randint(3, 10)) # Sleep some time to prevent printing before startup information

    while True:
        data = get_weather_options()
        if data["auto_delay"] != "off":
            print("Checking rain status...")
            weather = get_weather_data() if data['weather_provider'] == "yahoo" else get_wunderground_weather_data()
            delay = code_to_delay(weather["code"])
            if delay > 0:
                print("Rain detected: " + weather["text"] + ". Adding delay of " + str(delay))
                gv.sd['rd'] = float(delay)
                gv.sd['rdst'] = gv.now + gv.sd['rd'] * 3600 + 1 # +1 adds a smidge just so after a round trip the display hasn't already counted down by a minute.
                stop_onrain()
            elif delay == 0:
开发者ID:delind,项目名称:OSPy,代码行数:31,代码来源:weather_adj.py

示例2: get_rpi_revision

from urls import urls  # Get access to ospi's URLs
from ospy import template_render
from webpages import ProtectedPage
from helpers import get_rpi_revision

# I2C bus Rev Raspi RPI=1 rev1 RPI=0 rev0 
try:
    import smbus  # for PCF 8591
    ADC = smbus.SMBus(1 if get_rpi_revision() >= 2 else 0)
except ImportError:
    ADC = None

# Add a new url to open the data entry page.
urls.extend(['/pcf', 'plugins.pcf_8591_adj.settings',
             '/pcfj', 'plugins.pcf_8591_adj.settings_json',
             '/pcfa', 'plugins.pcf_8591_adj.update',
             '/pcfl', 'plugins.pcf_8591_adj.pcf_log',
             '/pcfr', 'plugins.pcf_8591_adj.delete_log'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['PCF8591 voltage and temperature settings ', '/pcf'])

################################################################################
# Main function loop:                                                          #
################################################################################


class PCFSender(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
开发者ID:teodoryantcheff,项目名称:OSPy,代码行数:31,代码来源:pcf_8591_adj.py

示例3: GPIO

import gv  # Get access to ospi's settings, gv = global variables
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage

gv.use_gpio_pins = False  # Signal OSPi to not use GPIO pins

# Load the Raspberry Pi GPIO (General Purpose Input Output) library
try:
    import RPi.GPIO as GPIO
except IOError:
    pass

# Add a new url to open the data entry page.
urls.extend(['/rb', 'plugins.relay_board.settings',
	'/rbj', 'plugins.relay_board.settings_json',
	'/rbu', 'plugins.relay_board.update']) 

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Relay Board', '/rb'])

params = {}

# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/relay_board.json', 'r') as f:  # Read the settings from file
            params = json.load(f)
    except IOError: #  If file does not exist create file with defaults.
        params = {
开发者ID:Qasemt,项目名称:relay_board,代码行数:31,代码来源:relay_board.py

示例4: settings

""" SIP plugin uses mqtt plugin to broadcast station status every time it changes.
"""
__author__ = "Daniel Casner <[email protected]>"

import web  # web.py framework
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
from blinker import signal # To receive station notifications
import json  # for working with data file
from plugins import mqtt

# Add new URLs to access classes in this plugin.
urls.extend([
    '/zone2mqtt-sp', 'plugins.mqtt_zones.settings',
    '/zone2mqtt-save', 'plugins.mqtt_zones.save_settings'
    ])
gv.plugin_menu.append(['MQTT zone broadcaster', '/zone2mqtt-sp'])

class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = mqtt.get_settings()
        zone_topic = settings.get('zone_topic', gv.sd[u'name'] + '/zones')
        return template_render.mqtt_zones(zone_topic, "")  # open settings page

class save_settings(ProtectedPage):
    """Save user input to json file.
    Will create or update file when SUBMIT button is clicked
    CheckBoxes only appear in qdict if they are checked.
开发者ID:Dan-in-CA,项目名称:sip_plugins,代码行数:32,代码来源:mqtt_zones.py

示例5: float

    return float(s)
  except:
    return 0

def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

# Add a new url to open the data entry page.
urls.extend(['/lwa',  'plugins.weather_level_adj.settings',
             '/lwj',  'plugins.weather_level_adj.settings_json',
             '/luwa', 'plugins.weather_level_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Weather-based Water Level', '/lwa'])


################################################################################
# Main function loop:                                                          #
################################################################################

class WeatherLevelChecker(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
开发者ID:Dan-in-CA,项目名称:sip_plugins,代码行数:31,代码来源:weather_level_adj.py

示例6: import

#!/usr/bin/env python

import web, json, time
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs

try:
    from apscheduler.scheduler import (
        Scheduler,
    )  # This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    print "The Python module apscheduler could not be found."
    pass

urls.extend(
    ["/ma", "plugins.monthly_adj.monthly_percent", "/uma", "plugins.monthly_adj.update_percents"]
)  # Add a new url to open the data entry page.

gv.plugin_menu.append(["Monthly Adjust", "/ma"])  # Add this plugin to the home page plugins menu

try:
    sched = Scheduler()
    sched.start()  # Start the scheduler
except NameError:
    pass


def set_wl():
    """Adjust irrigation time by percent based on historical climate data."""
    f = open("./data/levels.json", "r")  # Read the monthly percentages from file
    levels = json.load(f)
开发者ID:raj566,项目名称:OSPi,代码行数:31,代码来源:monthly_adj.py

示例7: set_wl

#!/usr/bin/env python

import web, json, time
import gv # Get access to ospi's settings
from urls import urls # Get access to ospi's URLs
try:
    from apscheduler.scheduler import Scheduler #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    pass

urls.extend(['/ma', 'plugins.monthly_adj.monthly_percent', '/uma', 'plugins.monthly_adj.update_percents']) # Add a new url to open the data entry page.
try:
    sched = Scheduler()
    sched.start() # Start the scheduler
except NameError:
    pass    
 
def set_wl():
    """Adjust irrigation time by percent based on historical climate data.""" 
    f = open('./data/levels.json', 'r') # Read the monthly percentages from file
    levels = json.load(f)
    f.close()
    mon = time.localtime().tm_mon # Get current month.
    gv.sd['wl'] = levels[mon-1] # Set the water level% (levels list is zero based).
    print 'Setting water level to {}%'.format(gv.sd['wl'])
    return

class monthly_percent:
    """Load an html page for entering monthly irrigation time adjustments"""
    def __init__(self):
        self.render = web.template.render('templates/')
开发者ID:AlesLesjak,项目名称:OSPi,代码行数:31,代码来源:monthly_adj.py

示例8: Scheduler

    daysWatched = d
    metrics=m
    return
    
try:
    from apscheduler.scheduler import Scheduler #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    pass

try:
    sched = Scheduler()
    sched.start() # Start the scheduler
except NameError:
    pass    

urls.extend(['/auto', 'plugins.auto_program.auto_program', '/uap', 'plugins.auto_program.update_auto_program', '/rap', 'plugins.auto_program.start_auto_program']) # Add a new url to open the data entry page
gv.plugin_menu.append(['Auto-Program', '/auto']) # Add this plugin to the home page plugins menu
    
def runAutoProgram():
    global daysWatched
    global metrics
    days=[0,0]
    zone_history=[]

    wx_settings.checkRain()
    if not gv.sd['en']: return # check operation status
    if gv.sd['rd'] or (gv.sd['urs'] and gv.sd['rs']): # If rain delay or rain detected by sensor then exit
        return

    # this routine will create a new program for today based on historical rainfall total and last 7 day watering
    try:
开发者ID:scottshaffer,项目名称:OSPi,代码行数:31,代码来源:auto_program.py

示例9: set_wl

import thread
import json
import time

import web
import gv  # Get access to sip's settings
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend([
    '/cama', 'plugins.california_monthly.monthly_percent',
    '/cauma', 'plugins.california_monthly.update_percents',
    '/cacalcma', 'plugins.california_monthly.calc_percents'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['California Monthly', '/cama'])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical California climate data."""
    if run_loop:
        time.sleep(2)  # Sleep some time to prevent printing before startup information

    last_month = 0
    while True:
        try:
开发者ID:Pelado-Mat,项目名称:sip_plugins,代码行数:30,代码来源:california_monthly.py

示例10: load_params

from blinker import signal
import web, json, time
import gv  # Get access to ospi's settings, gv = global variables
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
import picamera
from time import sleep
import os
import errno

# Add a new url to open the data entry page.
urls.extend(['/ca', 'plugins.camera.settings',
	'/caj', 'plugins.camera.settings_json',
	'/cau', 'plugins.camera.update',
        '/cap', 'plugins.camera.pic', 
        '/captz', 'plugins.camera.ptz']) 

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Camera', '/ca'])

params = {}

# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/camera.json', 'r') as f:  # Read the settings from file
            params = json.load(f)
    except IOError: #  If file does not exist create file with defaults.
开发者ID:bkoblenz,项目名称:Irricloud_plugins,代码行数:30,代码来源:camera.py

示例11: load_params

load_params()
image_path = os.path.join('.', 'static', 'images')

try:
    os.makedirs(image_path)
except OSError as exc:  # Python >2.5
    if exc.errno == errno.EEXIST and os.path.isdir(image_path):
        pass
    else:
        raise

try:
    # Add a new url to open the data entry page if camera working
    if 'plugins.camera' not in urls:
        urls.extend(['/ca', 'plugins.camera.view_camera',
            '/cau', 'plugins.camera.change_camera',
            '/cap', 'plugins.camera.pic', 
            '/captz', 'plugins.camera.ptz']) 

        # Add this plugin to the home page plugins menu
        gv.plugin_menu.append(['Camera', '/ca'])

    take_picture('camera.jpg')

except:
    pass

zones = signal('zone_change')
zones.connect(on_zone_change)

################################################################################
# Web pages:                                                                   #
开发者ID:bkoblenz,项目名称:Irricloud,代码行数:32,代码来源:camera.py

示例12: initialize_fm_pins

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage, WebPage, load_and_save_remote, message_base, validate_remote, get_ip_to_base
from helpers import jsave, get_ip, read_log, reboot, get_remote_sensor_boards, update_upnp, update_hostname, update_tza, mkdir_p
from system_update import checker as updatechecker
import subprocess

disable_substations = False
# Add a new url to open the data entry page.  DO THIS AFTER possible error exit in initialize_fm_pins()
if 'plugins.substations' not in urls:
    if gv.sd['master']:
        urls.extend(['/suslv',  'plugins.substations.view_substations',
                     '/suslj',  'plugins.substations.join_master',
                     '/susde',  'plugins.substations.delete_substation',
                     '/suset',  'plugins.substations.set_substation',
                     '/susle',  'plugins.substations.execute_substation'])
    if gv.sd['slave']:
        urls.extend(['/susldr',  'plugins.substations.slave_data_request'])
        urls.extend(['/suiface',  'plugins.substations.slave_iface'])

    urls.extend(['/surrsd',  'plugins.substations.receive_remote_sensor_data'])
    urls.extend(['/surzd',  'plugins.substations.remote_zone_data'])

    if not gv.sd['slave'] and not gv.sd['master']:
        disable_substations = True

    # Add this plugin to the home page plugins menu
    #gv.plugin_menu.append(['Substations', '/sua'])
开发者ID:bkoblenz,项目名称:Irricloud,代码行数:30,代码来源:substations.py

示例13: set_wl

import json
import time

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend(
    [
        "/cama",
        "plugins.california_monthly.monthly_percent",
        "/cauma",
        "plugins.california_monthly.update_percents",
        "/cacalcma",
        "plugins.california_monthly.calc_percents",
    ]
)

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(["California Monthly", "/cama"])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical California climate data."""
    if run_loop:
        time.sleep(2)  # Sleep some time to prevent printing before startup information

    last_month = 0
开发者ID:Tails86,项目名称:ospi_plugins,代码行数:32,代码来源:california_monthly.py

示例14: set_wl

# !/usr/bin/env python
from random import randint
import thread
import json
import time

import web
import gv  # Get access to ospy's settings
from urls import urls  # Get access to ospy's URLs
from ospy import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend(['/ma', 'plugins.monthly_adj.monthly_percent', '/uma', 'plugins.monthly_adj.update_percents'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Monthly Adjust', '/ma'])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical climate data."""
    if run_loop:
        time.sleep(randint(3, 10))  # Sleep some time to prevent printing before startup information

    last_month = 0
    while True:
        with open('./data/levels.json', 'r') as f:  # Read the monthly percentages from file
            levels = json.load(f)
        month = time.localtime().tm_mon  # Get current month.
        if month != last_month:
开发者ID:teodoryantcheff,项目名称:OSPy,代码行数:31,代码来源:monthly_adj.py

示例15: toggle_relay

# !/usr/bin/env python

import time

import gv
from gpio_pins import GPIO, pin_relay
from urls import urls
import web
from webpages import ProtectedPage


urls.extend(['/tr', 'plugins.relay.toggle_relay'])  # Add a new url for this plugin.

gv.plugin_menu.append(['Test Relay', '/tr'])  # Add this plugin to the home page plugins menu


class toggle_relay(ProtectedPage):
    """Test relay by turning it on for a short time, then off."""
    def GET(self):
        try:
            GPIO.output(pin_relay, GPIO.HIGH)  # turn relay on
            time.sleep(3)
            GPIO.output(pin_relay, GPIO.LOW)  # Turn relay off
        except Exception:
            pass
        raise web.seeother('/')  # return to home page
开发者ID:alustig,项目名称:OSPi,代码行数:26,代码来源:relay.py


注:本文中的urls.urls.extend函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。