Esempio n. 1
0
 def update(self):
     repo = Repo('./')
     o = repo.remotes.origin
     info = o.pull()
     cbpi.notify(
         "Pull successful",
         "The lasted updated was downloaded. Please restart the system")
     return ('', 204)
Esempio n. 2
0
 def checkout_tag(self, name):
     repo = Repo('./')
     repo.git.reset('--hard')
     o = repo.remotes.origin
     o.fetch()
     g = Git('./')
     g.checkout(name)
     cbpi.notify("Checkout successful", "Please restart the system")
     return ('', 204)
Esempio n. 3
0
 def VerifyConfigurations(self):
     parameterName = "step_sparge_kettle"
     parameterToVerify = cbpi.cache.get("config").get(parameterName)
     if parameterToVerify is not None and parameterToVerify.value is not None:
         mashKettle = cbpi.get_config_parameter("step_mash_kettle", None)
         boilKettle = cbpi.get_config_parameter("step_boil_kettle", None)
         # It may be a problem if the brewer have only two kettles and the boil kettle is used to sparge
         if parameterToVerify.value == mashKettle or parameterToVerify == boilKettle:
             cbpi.notify(
                 "Invalid kettle",
                 "Sparge Kettle cannot be the same mash or boil kettles",
                 timeout=5000)
             return False
Esempio n. 4
0
    def getSteps(self, id):
        e = xml.etree.ElementTree.parse(self.BEER_XML_FILE).getroot()
        steps = []
        totalWater = 0.0
        unit = self.api.get_config_parameter("unit", "C")

        if ((ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithStepInfusion
             or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithStepInfusionAndMashIn
             or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithTotalWater
             or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithTotalWaterAndMashIn)
                and not self.FlowMeterPluginIsInstalled()):
            cbpi.notify("Cannot found plugin Flowmeter",
                        "No Flowmeter step will be added during import.",
                        timeout=5000)

        if ((ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithTotalWater
             or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
             == FlowInAndMashInStepCreationEnum.FlowWithTotalWaterAndMashIn)
                and self.FlowMeterPluginIsInstalled()):

            totalWater = self.getTotalWater(id)

            # Notify that no water elements were found on recipe
            if totalWater > 0:
                # Create a Flowmeter step
                steps.append({
                    "name":
                    "Load Water(%s)" %
                    str(cbpi.get_config_parameter("ADRI_FlowmeterSensor",
                                                  None)),
                    "type":
                    MashStepTypes.Flowmeter,
                    "sensor":
                    self.getFlowMeterSensor(),
                    "actorA":
                    self.getFlowMeterActor(),
                    "volume":
                    totalWater,
                    "resetFlowmeter":
                    0
                })
            else:
                cbpi.notify(
                    "Can't load water amounts from recipe",
                    "No water elements were found on recipe. Flowmeter step were not added.",
                    timeout=5000)

        for e in e.findall('./RECIPE[%s]/MASH/MASH_STEPS/MASH_STEP' %
                           (str(id))):
            if unit == "C":
                temp = float(e.find("STEP_TEMP").text)
            else:
                temp = round(9.0 / 5.0 * float(e.find("STEP_TEMP").text) + 32,
                             2)

            # Verify if there is a mashin step with water aditions
            mashStepType = e.find('TYPE')
            mashStepAmount = float(
                str.replace(e.find('DISPLAY_INFUSE_AMT').text, " L", ""))

            # create a mashin step, not a mashstep
            if mashStepType is not None and mashStepType.text == "Infusion" and mashStepAmount is not None and mashStepAmount > 0:
                if unit == "C":
                    infusionTemp = float(
                        e.find("INFUSE_TEMP").text.replace(" C", ""))
                else:
                    infusionTemp = round(
                        9.0 / 5.0 *
                        float(e.find("INFUSE_TEMP").text.replace(" C", "")) +
                        32, 2)

                if ((ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
                     == FlowInAndMashInStepCreationEnum.FlowWithStepInfusion
                     or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
                     == FlowInAndMashInStepCreationEnum.
                     FlowWithStepInfusionAndMashIn)
                        and self.FlowMeterPluginIsInstalled()):

                    # Create a Flowmeter step
                    steps.append({
                        "name":
                        "Load Water(%s)" % str(
                            cbpi.get_config_parameter("ADRI_FlowmeterSensor",
                                                      None)),
                        "type":
                        MashStepTypes.Flowmeter,
                        "sensor":
                        self.getFlowMeterSensor(),
                        "actorA":
                        self.getFlowMeterActor(),
                        "volume":
                        mashStepAmount,
                        "resetFlowmeter":
                        0
                    })

                # Add a mashin step with strike temp
                if (ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
                        == FlowInAndMashInStepCreationEnum.MashInOnly
                        or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
                        == FlowInAndMashInStepCreationEnum.
                        FlowWithStepInfusionAndMashIn
                        or ImportBehavior.FLOWIN_AND_MASHIN_STEP_CREATION
                        == FlowInAndMashInStepCreationEnum.
                        FlowWithTotalWaterAndMashIn):
                    steps.append({
                        "name": "Mash in",
                        "type": MashStepTypes.MashinStep,
                        "temp": infusionTemp
                    })

            steps.append({
                "name": e.find("NAME").text,
                "type": MashStepTypes.MashStep,
                "temp": temp,
                "timer": float(e.find("STEP_TIME").text)
            })

        return steps