def GET(self): log.clear(NAME) cmd = "sudo echo 'bcm2708_wdog' >> /etc/modules" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo echo 'bcm2835_wdog' >> /etc/modules" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo echo 'bcm2711_wdt' >> /etc/modules" log.debug(NAME, cmd) run_process(cmd) try: cmd = "sudo modprobe bcm2708_wdog" log.debug(NAME, cmd) run_process(cmd) except: try: cmd = "sudo modprobe bcm2835_wdog" log.debug(NAME, cmd) run_process(cmd) except: cmd = "sudo modprobe bcm2711_wdog" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo apt-get install -y watchdog chkconfig" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo chkconfig watchdog on" log.debug(NAME, cmd) run_process(cmd) log.debug(NAME, _('Saving config to /etc/watchdog.conf')) # http://linux.die.net/man/5/watchdog.conf f = open("/etc/watchdog.conf", "wb") f.write("watchdog-device = /dev/watchdog\n") f.write("watchdog-timeout = 14\n") f.write("realtime = yes\n") f.write("priority = 1\n") f.write("interval = 4\n") f.write("max-load-1 = 24\n") f.close() cmd = "sudo systemctl enable watchdog" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo systemctl daemon-reload" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo systemctl start watchdog" log.debug(NAME, cmd) run_process(cmd) reboot(True) # reboot HW software after instal watchdog msg = _( 'The system (Linux) will now restart (restart started by the user in the Watch-dog plugins), please wait for the page to reload.' ) return self.core_render.notice(plugin_url(status_page), msg)
def POST(self): logger.debug('POST ' + self.__class__.__name__) action = web.input().get('do', '').lower() if action == 'reboot': logger.info('System reboot requested via API') helpers.reboot() elif action == 'restart': logger.info('OSPy service restart requested via API') helpers.restart() elif action == 'poweroff': logger.info('System poweroff requested via API') helpers.poweroff() else: logger.error('Unknown system action: "%s"', action) raise badrequest()
def GET(self): log.clear(NAME) cmd = "sudo echo 'bcm2708_wdog' >> /etc/modules" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo modprobe bcm2708_wdog" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo apt-get install -y watchdog chkconfig" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo chkconfig watchdog on" log.debug(NAME, cmd) run_process(cmd) log.debug(NAME, _('Saving config to /etc/watchdog.conf')) # http://linux.die.net/man/5/watchdog.conf f = open("/etc/watchdog.conf", "w") f.write("watchdog-device = /dev/watchdog\n") f.write("watchdog-timeout = 14\n") f.write("realtime = yes\n") f.write("priority = 1\n") f.write("interval = 4\n") f.write("max-load-1 = 24\n") f.close() cmd = "sudo systemctl enable watchdog" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo systemctl daemon-reload" log.debug(NAME, cmd) run_process(cmd) cmd = "sudo systemctl start watchdog" log.debug(NAME, cmd) run_process(cmd) reboot(True) # reboot HW software after instal watchdog return self.core_render.restarting(plugin_url(status_page))
def run(self): log.clear(NAME) while not self._stop.is_set(): try: if plugin_options['use_button']: # if button plugin is enabled actual_buttons = read_buttons() #led_outputs(actual_buttons) for i in range(8): tb = "button" + str(i) if actual_buttons == i and plugin_options[tb]== "reboot": log.info(NAME, datetime_string() + ': ' + _('System reboot')) stations.clear() reboot() self._sleep(2) if actual_buttons == i and plugin_options[tb]== "pwrOff": log.info(NAME, datetime_string() + ': ' + _('System shutdown')) stations.clear() poweroff() self._sleep(2) if actual_buttons == i and plugin_options[tb]== "stopAll": log.info(NAME, datetime_string() + ': ' + _('All stations now stopped')) log.finish_run(None) # save log stations.clear() # set all station to off self._sleep(2) if actual_buttons == i and plugin_options[tb]== "schedEn": log.info(NAME, datetime_string() + ': ' + _('Scheduler is now enabled')) options.scheduler_enabled = True self._sleep(2) if actual_buttons == i and plugin_options[tb]== "schedDis": log.info(NAME, datetime_string() + ': ' + _('Scheduler is now disabled')) options.scheduler_enabled = False self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP1": log.info(NAME, datetime_string() + ': ' + _('Run now program 1')) for program in programs.get(): if (program.index == 0): # Run-now program 1 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP2": log.info(NAME, datetime_string() + ': ' + _('Run now program 2')) for program in programs.get(): if (program.index == 1): # Run-now program 2 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP3": log.info(NAME, datetime_string() + ': ' + _('Run now program 3')) for program in programs.get(): if (program.index == 2): # Run-now program 3 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP4": log.info(NAME, datetime_string() + ': ' + _('Run now program 4')) for program in programs.get(): if (program.index == 3): # Run-now program 4 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP5": log.info(NAME, datetime_string() + ': ' + _('Run now program 5')) for program in programs.get(): if (program.index == 4): # Run-now program 5 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP6": log.info(NAME, datetime_string() + ': ' + _('Run now program 6')) for program in programs.get(): if (program.index == 5): # Run-now program 6 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP7": log.info(NAME, datetime_string() + ': ' + _('Run now program 7')) for program in programs.get(): if (program.index == 6): # Run-now program 7 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) if actual_buttons == i and plugin_options[tb]== "RunP8": log.info(NAME, datetime_string() + ': ' + _('Run now program 8')) for program in programs.get(): if (program.index == 7): # Run-now program 8 options.manual_mode = False log.finish_run(None) stations.clear() programs.run_now(program.index) program.index+1 self._sleep(2) self._sleep(1) except Exception: log.clear(NAME) log.error(NAME, _('Button plug-in') + ':\n' + traceback.format_exc()) self._sleep(60) pass
def POST(self): qdict = web.input() change = False # if change language -> restart ospy if 'lang' in qdict and qdict['lang']: if options.lang != qdict['lang']: change = True qdict['name'] = qdict['name'] qdict['location'] = qdict['location'] qdict['darksky_key'] = qdict['darksky_key'] qdict['HTTP_web_ip'] = qdict['HTTP_web_ip'] save_to_options(qdict) if 'master' in qdict: m = int(qdict['master']) if m < 0: stations.master = None elif m < stations.count(): stations.master = m if 'master_two' in qdict: m = int(qdict['master_two']) if m < 0: stations.master_two = None elif m < stations.count(): stations.master_two = m if 'old_password' in qdict and qdict['old_password'] != "": try: if test_password(qdict['old_password']): if qdict['new_password'] == "": raise web.seeother('/options?errorCode=pw_blank') elif qdict['new_password'] == qdict['check_password']: options.password_salt = password_salt() # Make a new salt options.password_hash = password_hash(qdict['new_password'], options.password_salt) else: raise web.seeother('/options?errorCode=pw_mismatch') else: raise web.seeother('/options?errorCode=pw_wrong') except KeyError: pass if 'rbt' in qdict and qdict['rbt'] == '1': report_rebooted() reboot(True) # Linux HW software return self.core_render.home() if 'rstrt' in qdict and qdict['rstrt'] == '1': report_restarted() restart() # OSPy software return self.core_render.restarting(home_page) if 'pwrdwn' in qdict and qdict['pwrdwn'] == '1': poweroff() # shutdown HW system return self.core_render.restarting(home_page) if 'deldef' in qdict and qdict['deldef'] == '1': OPTIONS_FILE = './ospy/data' try: import shutil, time shutil.rmtree(OPTIONS_FILE) # delete data folder time.sleep(2) os.makedirs(OPTIONS_FILE) # create data folder report_restarted() restart() # restart OSPy software return self.core_render.restarting(home_page) except: pass if change: report_restarted() restart() # OSPy software return self.core_render.restarting(home_page) report_option_change() raise web.seeother('/')
def sms_check(self): """Control and processing SMS""" try: import gammu except Exception: log.error(NAME, _('SMS Modem plug-in') + ':\n' + traceback.format_exc()) tel1 = sms_options['tel1'] tel2 = sms_options['tel2'] comm1 = sms_options['txt1'] comm2 = sms_options['txt2'] comm3 = sms_options['txt3'] comm4 = sms_options['txt4'] comm5 = sms_options['txt5'] comm6 = sms_options['txt6'] comm7 = sms_options['txt7'] comm8 = sms_options['txt8'] comm9 = sms_options['txt9'] sm = gammu.StateMachine() sm.ReadConfig() try: sm.Init() log.debug(NAME, datetime_string() + ': ' + _('Checking SMS...')) except: log.error(NAME, _('SMS Modem plug-in') + ':\n' + traceback.format_exc()) self._sleep(60) if sms_options[ "use_strength"]: # print strength signal in status Window every check SMS signal = sm.GetSignalQuality( ) # list: SignalPercent, SignalStrength, BitErrorRate log.info( NAME, datetime_string() + ': ' + _('Signal') + ': ' + str(signal['SignalPercent']) + '% ' + str(signal['SignalStrength']) + 'dB') status = sm.GetSMSStatus() remain = status['SIMUsed'] + status['PhoneUsed'] + status['TemplatesUsed'] sms = [] start = True while remain > 0: if start: cursms = sm.GetNextSMS(Start=True, Folder=0) start = False else: cursms = sm.GetNextSMS(Location=cursms[0]['Location'], Folder=0) remain = remain - len(cursms) sms.append(cursms) data = gammu.LinkSMS(sms) for x in data: v = gammu.DecodeSMS(x) m = x[0] print '%-15s: %s' % ('Sender', m['Number']) print '%-15s: %s' % ('Date', str(m['DateTime'])) print '%-15s: %s' % ('State', m['State']) print '%-15s: %s' % ('SMS command', m['Text']) if (m['Number'] == tel1) or (m['Number'] == tel2): # If telephone is admin 1 or admin 2 log.info(NAME, datetime_string() + ': ' + _('SMS from admin')) if m['State'] == "UnRead": # If SMS is unread log.clear(NAME) if m['Text'] == comm1: # If command = comm1 (info - send SMS to admin phone1 and phone2) log.info( NAME, _('Command') + ' ' + comm1 + ' ' + _('is processed')) # send 1/2 SMS with text 1 up = helpers.uptime() temp = helpers.get_cpu_temp( options.temp_unit) + ' ' + options.temp_unit ip = str(helpers.get_ip()) ver = version.ver_date datastr = ('SMS 1/2. ' + datetime_string() + ', TEMP: ' + temp + ', IP: ' + ip + ', SW: ' + ver + ', UP: ' + up) message = { 'Text': datastr, 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) # send sms 1/2 log.info(NAME, datastr) # send 2/2 SMS with text 2 if inputs.rain_sensed(): rain = "Active" else: rain = "Inactive" try: from plugins import pressure_monitor state_press = pressure_monitor.get_check_pressure() if state_press: press = "High" else: press = "Low" except Exception: press = "N/A" finished = [ run for run in log.finished_runs() if not run['blocked'] ] if finished: last_prog = finished[-1]['start'].strftime( '%H:%M: ') + finished[-1]['program_name'] else: last_prog = 'None' datastr = ('SMS 2/2. ' + 'RAIN: ' + rain + ', PRESS: ' + press + ', LAST: ' + last_prog) message = { 'Text': datastr, 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) # send sms 2/2 log.info(NAME, datastr) log.info( NAME, _('Command') + ': ' + comm1 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) # SMS deleted log.info(NAME, _('Received SMS was deleted')) elif m['Text'] == comm2: # If command = comm2 (stop - scheduler) log.info( NAME, _('Command') + ' ' + comm2 + ' ' + _('is processed')) options.scheduler_enabled = False log.finish_run(None) stations.clear() message = { 'Text': 'Command: ' + comm2 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm2 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted')) elif m['Text'] == comm3: # If command = comm3 (start - scheduler) log.info( NAME, _('Command') + ' ' + comm3 + ' ' + _('is processed')) options.scheduler_enabled = True message = { 'Text': 'Command: ' + comm3 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm3 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted')) elif m['Text'] == comm4: # If command = comm4 (reboot system) log.info( NAME, _('Command') + ' ' + comm4 + ' ' + _('is processed')) message = { 'Text': 'Command: ' + comm4 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm4 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info( NAME, _('Received SMS was deleted and system is now reboot')) reboot() # restart linux system elif m['Text'] == comm5: # If command = comm5 (poweroff system) log.info( NAME, _('Command') + ' ' + comm5 + ' ' + _('is processed')) message = { 'Text': 'Command: ' + comm5 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm5 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info( NAME, _('Received SMS was deleted and system is now poweroff' )) poweroff() # poweroff linux system elif m['Text'] == comm6: # If command = comm6 (update ospi system) log.info( NAME, _('Command') + ' ' + comm6 + ' ' + _('is processed')) message = { 'Text': 'Command: ' + comm6 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm6 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) try: from plugins.system_update import perform_update perform_update() log.info( NAME, _('Received SMS was deleted, update was performed and program will restart' )) except ImportError: log.info( NAME, _('Received SMS was deleted, but could not perform update' )) sm.DeleteSMS(m['Folder'], m['Location']) elif m['Text'] == comm7: # If command = comm7 (send email with foto from webcam) log.info( NAME, _('Command') + ' ' + comm7 + ' ' + _('is processed')) message = { 'Text': 'Command: ' + comm7 + ' was processed', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm7 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) try: from plugins.webcam import get_run_cam, get_image_location get_run_cam() # process save foto to ./data/image.jpg msg = _('SMS plug-in send image file from webcam.') send_email(msg, attach=get_image_location()) except ImportError: log.info( NAME, _('Received SMS was deleted, but could not send email with photo from webcam' )) message = { 'Text': 'Error: not send foto from webcam', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) sm.DeleteSMS(m['Folder'], m['Location']) elif m['Text'] == comm8: # If command = comm8 (send SMS with available commands) log.info( NAME, _('Command') + ' ' + comm8 + ' ' + _('is processed')) message = { 'Text': 'Available commands: ' + comm1 + ',' + comm2 + ',' + comm3 + ',' + comm4 + ',' + comm5 + ',' + comm6 + ',' + comm7 + ',' + comm8 + ',' + comm9 + 'xx', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + comm8 + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted')) elif m['Text'][0:len( comm9 )] == comm9: # If command = lenght char comm9 (run now program xx) num = m['Text'][len( comm9 ):] # number from sms text example: run36 -> num=36 log.info( NAME, _('Command') + ' ' + comm9 + ' ' + _('is processed')) index = int(num) if index <= programs.count( ): # if program number from sms text exists in program db log.finish_run(None) stations.clear() prog = int(index - 1) programs.run_now(prog) log.info( NAME, _('Program') + ': ' + str(index) + ' ' + _('now run')) message = { 'Text': 'Program: ' + str(index) + ' now run', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } else: message = { 'Text': 'Program: ' + str(index) + ' no exists!', 'SMSC': { 'Location': 1 }, 'Number': m['Number'], } sm.SendSMS(message) log.info( NAME, _('Command') + ': ' + str(m['Text']) + ' ' + _('was processed and confirmation was sent as SMS to') + ': ' + m['Number']) sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted')) else: # If SMS command is not defined sm.DeleteSMS(m['Folder'], m['Location']) log.info( NAME, _('Received command') + ' ' + m['Text'] + ' ' + _('is not defined!')) else: # If SMS was read sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted - SMS was read')) else: # If telephone number is not admin 1 or admin 2 phone number sm.DeleteSMS(m['Folder'], m['Location']) log.info(NAME, _('Received SMS was deleted - SMS was not from admin'))
def run(self): log.clear(NAME) disable_text = True while not self._stop_event.is_set(): try: if plugin_options['use_button']: # if button plugin is enabled disable_text = True actual_buttons = read_buttons() # led_outputs(actual_buttons) # for test for i in range(8): tb = "button" + str(i) if actual_buttons == i and plugin_options[ tb] == "reboot": log.info( NAME, datetime_string() + ': ' + _(u'System reboot')) stations.clear() report_rebooted() reboot(block=True) # Linux HW software self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "pwrOff": log.info( NAME, datetime_string() + ': ' + _(u'System shutdown')) stations.clear() report_poweroff() poweroff(wait=10, block=True) # shutdown HW system self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "stopAll": log.info( NAME, datetime_string() + ': ' + _(u'Selected stations now stopped')) set_stations_in_scheduler_off() self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "schedEn": log.info( NAME, datetime_string() + ': ' + _(u'Scheduler is now enabled')) options.scheduler_enabled = True self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "schedDis": log.info( NAME, datetime_string() + ': ' + _(u'Scheduler is now disabled')) options.scheduler_enabled = False self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP1": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 1')) for program in programs.get(): if (program.index == 0): # Run-now program 1 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP2": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 2')) for program in programs.get(): if (program.index == 1): # Run-now program 2 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP3": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 3')) for program in programs.get(): if (program.index == 2): # Run-now program 3 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP4": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 4')) for program in programs.get(): if (program.index == 3): # Run-now program 4 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP5": log.info( NAME, datetime_string() + ': ' + _('Run now program 5')) for program in programs.get(): if (program.index == 4): # Run-now program 5 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP6": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 6')) for program in programs.get(): if (program.index == 5): # Run-now program 6 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP7": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 7')) for program in programs.get(): if (program.index == 6): # Run-now program 7 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) if actual_buttons == i and plugin_options[ tb] == "RunP8": log.info( NAME, datetime_string() + ': ' + _(u'Run now program 8')) for program in programs.get(): if (program.index == 7): # Run-now program 8 options.manual_mode = False if plugin_options['first_stop']: log.finish_run(None) stations.clear() programs.run_now(program.index) program.index + 1 self._sleep(1) self._sleep(1) else: # text on the web if plugin is disabled if disable_text: log.clear(NAME) log.info(NAME, _(u'Button plug-in is disabled.')) disable_text = False self._sleep(1) except Exception: log.clear(NAME) log.error( NAME, _(u'Button plug-in') + ':\n' + traceback.format_exc()) self._sleep(60) pass
def POST(self): qdict = web.input() change = False # if change language -> restart ospy if 'lang' in qdict and qdict['lang']: if options.lang != qdict['lang']: change = True newname = qdict['name'] # if name is asci char try: from ospy.helpers import ASCI_convert qdict['name'] = ASCI_convert(newname) except: qdict['name'] = ' ' save_to_options(qdict) if 'master' in qdict: m = int(qdict['master']) if m < 0: stations.master = None elif m < stations.count(): stations.master = m if 'master_two' in qdict: m = int(qdict['master_two']) if m < 0: stations.master_two = None elif m < stations.count(): stations.master_two = m if 'old_password' in qdict and qdict['old_password'] != "": try: if test_password(qdict['old_password']): if qdict['new_password'] == "": raise web.seeother('/options?errorCode=pw_blank') elif qdict['new_password'] == qdict['check_password']: options.password_salt = password_salt( ) # Make a new salt options.password_hash = password_hash( qdict['new_password'], options.password_salt) else: raise web.seeother('/options?errorCode=pw_mismatch') else: raise web.seeother('/options?errorCode=pw_wrong') except KeyError: pass if 'rbt' in qdict and qdict['rbt'] == '1': reboot(True) # Linux HW software return self.core_render.home() if 'rstrt' in qdict and qdict['rstrt'] == '1': restart() # OSPy software return self.core_render.restarting(home_page) if 'pwrdwn' in qdict and qdict['pwrdwn'] == '1': poweroff() # shutdown HW system return self.core_render.restarting(home_page) if 'deldef' in qdict and qdict['deldef'] == '1': OPTIONS_FILE = './ospy/data' try: import shutil, time shutil.rmtree(OPTIONS_FILE) # delete data folder time.sleep(2) os.makedirs(OPTIONS_FILE) # create data folder restart() # restart OSPy software return self.core_render.restarting(home_page) except: pass if change: restart() # OSPy software return self.core_render.restarting(home_page) raise web.seeother('/')