Beispiel #1
0
class ExampleLoggingJob(Job):
    interval = IntegerVar(default=4,
                          description="The time in seconds to sleep.")

    class Meta:
        name = "Example logging job."
        description = "I log stuff to demonstrate how UI logging works."

    def run(self, data, commit):
        interval = data["interval"]
        self.log_debug(message=f"Running for {interval} seconds.")
        for step in range(1, interval + 1):
            time.sleep(1)
            self.log_info(message=f"Step {step}")
        self.log_success(obj=None)
        return f"Ran for {interval} seconds"
Beispiel #2
0
    class TestJob(Job):
        class Meta:
            name = "Test job"

        var1 = StringVar()
        var2 = IntegerVar()
        var3 = BooleanVar()

        def run(self, data, commit=True):
            self.log_info(message=data["var1"])
            self.log_success(message=data["var2"])
            self.log_failure(message=data["var3"])

            return "Job complete"

        def test_foo(self):
            self.log_success(obj=None, message="Test completed")
Beispiel #3
0
class APITestJob(Job):
    class Meta:
        name = "Job for API Tests"

    var1 = StringVar()
    var2 = IntegerVar(
        required=True
    )  # explicitly stated, though required=True is the default in any case
    var3 = BooleanVar()
    var4 = ObjectVar(model=DeviceRole)

    def run(self, data, commit=True):
        self.log_debug(message=data["var1"])
        self.log_info(message=data["var2"])
        self.log_success(message=data["var3"])
        self.log_warning(message=data["var4"])

        return "Job complete"