Commit aa8d1fa4 authored by Seblu's avatar Seblu
Browse files

watch interval is now limited to 0.5

to save the world from destruction and spoofin
parent 554b6d89
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ class Command_watch(OptionCommand):
    def __init__(self, cli, argv0):
        OptionCommand.__init__(self, cli, argv0)
        self.set_usage("%prog [options] command [options]")
        self.add_option("-n", "--interval", dest="seconds", type="float", default=1.0,
        self.add_option("-n", "--interval", dest="interval", type="float", default=1.0,
                        help="Define interval in seconds")

    def __call__(self, argv):
@@ -28,6 +28,8 @@ class Command_watch(OptionCommand):
        self.parse_args(argv)
        if len(self.args) == 0:
            raise cmdBadArgument()
        if self.options.interval < 0.5:
            raise cmdBadArgument("Interval must be >= 0.5")
        while True:
            # Substitute aliases
            self.args = self.cli.aliases.substitute(self.args)
@@ -41,7 +43,7 @@ class Command_watch(OptionCommand):
                # Print the buffer
                self.printer.out(sys.stdout.getvalue(), fd=sys.__stdout__)
                # Wait
                time.sleep(self.options.seconds)
                time.sleep(self.options.interval)
            except KeyboardInterrupt:
                raise
            except cliException: