예제 #1
0
def stopLogging():
    global config
    logMessage("Stopped data logging, as requested in web interface. " +
               "BrewPi will continue to control temperatures, but will not log any data.")
    config = util.configSet(configFile, 'beerName', None)
    config = util.configSet(configFile, 'dataLogging', 'stopped')
    changeWwwSetting('beerName', None)
    return {'status': 0, 'statusMessage': "Successfully stopped logging"}
예제 #2
0
def stopLogging():
    global config
    logMessage("Stopped data logging, as requested in web interface. " +
               "BrewPi will continue to control temperatures, but will not log any data.")
    config = util.configSet(configFile, 'beerName', None)
    config = util.configSet(configFile, 'dataLogging', 'stopped')
    changeWwwSetting('beerName', None)
    return {'status': 0, 'statusMessage': "Successfully stopped logging"}
예제 #3
0
def startNewBrew(newName):
    global config
    if len(newName) > 1:     # shorter names are probably invalid
        config = util.configSet(configFile, 'beerName', newName)
        config = util.configSet(configFile, 'dataLogging', 'active')
        startBeer(newName)
        logMessage("Notification: Restarted logging for beer '%s'." % newName)
        return {'status': 0, 'statusMessage': "Successfully switched to new brew '%s'. " % urllib.unquote(newName) +
                                              "Please reload the page."}
    else:
        return {'status': 1, 'statusMessage': "Invalid new brew name '%s', "
                                              "please enter a name with at least 2 characters" % urllib.unquote(newName)}
예제 #4
0
def startNewBrew(newName):
    global config
    if len(newName) > 1:     # shorter names are probably invalid
        config = util.configSet(configFile, 'beerName', newName)
        config = util.configSet(configFile, 'dataLogging', 'active')
        startBeer(newName)
        logMessage("Notification: Restarted logging for beer '%s'." % newName)
        return {'status': 0, 'statusMessage': "Successfully switched to new brew '%s'. " % urllib.unquote(newName) +
                                              "Please reload the page."}
    else:
        return {'status': 1, 'statusMessage': "Invalid new brew name '%s', "
                                              "please enter a name with at least 2 characters" % urllib.unquote(newName)}
예제 #5
0
def resumeLogging():
    global config
    logMessage("Continued logging data, as requested in web interface.")
    if config['dataLogging'] == 'paused':
        config = util.configSet(configFile, 'dataLogging', 'active')
        return {'status': 0, 'statusMessage': "Successfully continued logging."}
    else:
        return {'status': 1, 'statusMessage': "Logging was not paused."}
예제 #6
0
def resumeLogging():
    global config
    logMessage("Continued logging data, as requested in web interface.")
    if config['dataLogging'] == 'paused':
        config = util.configSet(configFile, 'dataLogging', 'active')
        return {'status': 0, 'statusMessage': "Successfully continued logging."}
    else:
        return {'status': 1, 'statusMessage': "Logging was not paused."}
예제 #7
0
def pauseLogging():
    global config
    logMessage("Paused logging data, as requested in web interface. " +
               "BrewPi will continue to control temperatures, but will not log any data until resumed.")
    if config['dataLogging'] == 'active':
        config = util.configSet(configFile, 'dataLogging', 'paused')
        return {'status': 0, 'statusMessage': "Successfully paused logging."}
    else:
        return {'status': 1, 'statusMessage': "Logging already paused or stopped."}
예제 #8
0
def pauseLogging():
    global config
    logMessage("Paused logging data, as requested in web interface. " +
               "BrewPi will continue to control temperatures, but will not log any data until resumed.")
    if config['dataLogging'] == 'active':
        config = util.configSet(configFile, 'dataLogging', 'paused')
        return {'status': 0, 'statusMessage': "Successfully paused logging."}
    else:
        return {'status': 1, 'statusMessage': "Logging already paused or stopped."}
예제 #9
0
     logMessage("quit message received on socket. Stopping script.")
     run = 0
     # Leave dontrunfile alone.
     # This instruction is meant to restart the script or replace it with another instance.
     continue
 elif messageType == "eraseLogs":
     # erase the log files for stderr and stdout
     open(util.scriptPath() + '/logs/stderr.txt', 'wb').close()
     open(util.scriptPath() + '/logs/stdout.txt', 'wb').close()
     logMessage("Fresh start! Log files erased.")
     continue
 elif messageType == "interval":  # new interval received
     newInterval = int(value)
     if 5 < newInterval < 5000:
         try:
             config = util.configSet(configFile, 'interval', float(newInterval))
         except ValueError:
             logMessage("Cannot convert interval '" + value + "' to float")
             continue
         logMessage("Notification: Interval changed to " +
                    str(newInterval) + " seconds")
 elif messageType == "startNewBrew":  # new beer name
     newName = value
     result = startNewBrew(newName)
     conn.send(json.dumps(result))
 elif messageType == "pauseLogging":
     result = pauseLogging()
     conn.send(json.dumps(result))
 elif messageType == "stopLogging":
     result = stopLogging()
     conn.send(json.dumps(result))
예제 #10
0
     logMessage("quit message received on socket. Stopping script.")
     run = 0
     # Leave dontrunfile alone.
     # This instruction is meant to restart the script or replace it with another instance.
     continue
 elif messageType == "eraseLogs":
     # erase the log files for stderr and stdout
     open(util.scriptPath() + '/logs/stderr.txt', 'wb').close()
     open(util.scriptPath() + '/logs/stdout.txt', 'wb').close()
     logMessage("Fresh start! Log files erased.")
     continue
 elif messageType == "interval":  # new interval received
     newInterval = int(value)
     if 5 < newInterval < 5000:
         try:
             config = util.configSet(configFile, 'interval',
                                     float(newInterval))
         except ValueError:
             logMessage("Cannot convert interval '" + value +
                        "' to float")
             continue
         logMessage("Notification: Interval changed to " +
                    str(newInterval) + " seconds")
 elif messageType == "startNewBrew":  # new beer name
     newName = value
     result = startNewBrew(newName)
     conn.send(json.dumps(result))
 elif messageType == "pauseLogging":
     result = pauseLogging()
     conn.send(json.dumps(result))
 elif messageType == "stopLogging":
     result = stopLogging()
예제 #11
0
 elif messageType == "quit":  # quit instruction received. Probably sent by another brewpi script instance
     logMessage("quit message received on socket. Stopping script.")
     run = 0
     # Leave dontrunfile alone.
     # This instruction is meant to restart the script or replace it with another instance.
     continue
 elif messageType == "eraseLogs":
     # erase the log files for stderr and stdout
     open(util.scriptPath() + "/logs/stderr.txt", "wb").close()
     open(util.scriptPath() + "/logs/stdout.txt", "wb").close()
     logMessage("Fresh start! Log files erased.")
     continue
 elif messageType == "interval":  # new interval received
     newInterval = int(value)
     if 5 < newInterval < 5000:
         config = util.configSet(configFile, "interval", float(newInterval))
         logMessage("Notification: Interval changed to " + str(newInterval) + " seconds")
 elif messageType == "name":  # new beer name
     newName = value
     if len(newName) > 3:  # shorter names are probably invalid
         config = util.configSet(configFile, "beerName", newName)
         startBeer(newName)
         logMessage("Notification: restarted for beer: " + newName)
 elif messageType == "profileKey":
     config = util.configSet(configFile, "profileKey", value)
     changeWwwSetting("profileKey", value)
 elif messageType == "uploadProfile":
     # use urllib to download the profile as a CSV file
     profileUrl = (
         "https://spreadsheets.google.com/tq?key=" + config["profileKey"] + "&tq=select D,E&tqx=out:csv"
     )  # select the right cells and CSV format