Exemplo n.º 1
0
def main():
    radio.init_session(tft=False, debug=True)
    radio.start()
    while True:
        radio.read_control(tft=False)
        if pygame.event.poll().type == pygame.QUIT:
            print('im trying to quit...')
            radio.terminate()
Exemplo n.º 2
0
def main():
    radio.init_session(tft=False, debug=True)
    radio.start()
    while True:
        radio.read_control(tft=False)
        if pygame.event.poll().type == pygame.QUIT:
            print('im trying to quit...')
            radio.terminate()
Exemplo n.º 3
0
Arquivo: swpi.py Projeto: cbolk/swpi
# Send SMS with IP information
if ( publicIP != None and cfg.usedongle and cfg.send_IP_by_sms  ):
	try:
		modem.sms_send(cfg.number_to_send, publicIP)
		log ("SMS sent to %s" % cfg.number_to_send)
	except:
		log("Error sending IP by SMS")





# Start radio thread
if ( cfg.useradio ):
	radio = radio.RadioThread(cfg)
	radio.start()
	
# Start service thread if necessary
service.run_all_service_thread(cfg)

if bConnected:
	log("Try to disconnect")
	modem.disconnectwvdial()
	reset_sms(modem)
	#modem.enable_textmode(True)
	#modem.enable_clip(True)	
	#modem.enable_nmi(True)
	
# Wait for valid data
maxwait = 0
if ( cfg.use_wind_sensor ) :
Exemplo n.º 4
0
#		log ("Mail sent to :" + cfg.mail_to )
#	else:
#		log ("ERROR sending mail" )

# Send SMS with IP information
if (publicIP != None and cfg.usedongle and cfg.send_IP_by_sms):
    try:
        modem.sms_send(cfg.number_to_send, publicIP)
        log("SMS sent to %s" % cfg.number_to_send)
    except:
        log("Error sending IP by SMS")

# Start radio thread
if (cfg.useradio):
    radio = radio.RadioThread(cfg)
    radio.start()

# Start service thread if necessary
service.run_all_service_thread(cfg)

if bConnected:
    log("Try to disconnect")
    modem.disconnectwvdial()
    reset_sms(modem)
    #modem.enable_textmode(True)
    #modem.enable_clip(True)
    #modem.enable_nmi(True)

# Wait for valid data
maxwait = 0
if (cfg.use_wind_sensor):
Exemplo n.º 5
0
    def __init__(self):
        """Main function that is called at the startup of radio."""
        self.started = False
        self.prefs = preferences.Prefs()

        from optparse import OptionParser

        p = OptionParser()

        # define command line options
        p.add_option('-p', '--port',
                     dest='port',
                     default=None,
                     help="Force webinterface to listen on this port")
        p.add_option('-d', '--daemon',
                     dest='daemon',
                     action='store_true',
                     help='Run as a daemon')
        p.add_option('--pidfile',
                     dest='pidfile',
                     help='Create a pid file (only relevant when running as a daemon)')
        p.add_option('--log',
                     dest='log',
                     help='Create a log file at a desired location')
        p.add_option('-v', '--verbose',
                     dest='verbose',
                     action='store_true',
                     help='Silence the logger')
        p.add_option('--develop',
                     action="store_true",
                     dest='develop',
                     help="Start instance of development server")
        p.add_option('--database',
                     dest='database',
                     help='Custom database file location')
        p.add_option('--webroot',
                     dest='webroot',
                     help='Web root for radio')
        p.add_option('--host',
                     dest='host',
                     help='Web host for radio')
        p.add_option('--kiosk',
                     dest='kiosk',
                     action='store_true',
                     help='Disable settings in the UI')
        p.add_option('--datadir',
                     dest='datadir',
                     help='Write program data to custom location')
        p.add_option('--noupdate',
                     action="store_true",
                     dest='noupdate',
                     help='Disable the internal updater')

        # parse command line for defined options
        options, args = p.parse_args()

        if options.datadir:
            data_dir = options.datadir
        else:
            data_dir = dataDir

        if options.daemon:
            radio.DAEMON = True
            radio.VERBOSE = False
        else:
            val = self.prefs.getDaemon()
            if val == "True":
                radio.DAEMON = True
                radio.VERBOSE = False

        if options.pidfile:
            radio.PIDFILE = options.pidfile
            radio.VERBOSE = False
        else:
            val = self.prefs.getPidFile()
            if val == "True":
                radio.PIDFILE = self.prefs.getPidFilName()
                radio.VERBOSE = False

        if options.port:
            PORT = int(options.port)
        else:
            PORT = self.prefs.getPort()  # 7000

        if options.log:
            radio.LOG_FILE = options.log

        if options.verbose:
            radio.VERBOSE = True
        else:
            val = self.prefs.getVerbose()
            if val == "True":
                radio.VERBOSE = True

        if options.develop:
            radio.DEVELOPMENT = True
        else:
            val = self.prefs.getDevelopment()
            if val == "True":
                radio.DEVELOPMENT = True

        if options.database:
            DATABASE = options.database
        else:
            DATABASE = os.path.join(dataDir, 'prefs.db')

        if options.webroot:
            radio.WEBROOT = options.webroot

        if options.host:
            radio.HOST = options.host

        if options.kiosk:
            radio.KIOSK = True
        else:
            val = self.prefs.getKiosk()
            if val == "True":
                radio.KIOSK = True

        if options.noupdate:
            radio.UPDATER = False
        else:
            val = self.prefs.getNoUpdate()
            if val == "True":
                radio.UPDATER = False

        radio.RUNDIR = rundir
        radio.DATA_DIR = data_dir
        radio.FULL_PATH = os.path.join(rundir, 'Radio.py')
        radio.ARGS = sys.argv[1:]
        radio.PORT = PORT
        radio.DATABASE = DATABASE
        radio.VERBOSE = True
        radio.DEVELOPMENT = False

        radio.initialize()

        if radio.PIDFILE or radio.DAEMON:
            radio.daemonize()

        import_modules()
        radio.init_updater()

        radio.start()