2 # -*- coding: utf-8 -*-
5 # Copyright 2016-2017 VMware Inc.
6 # This file is part of ETSI OSM
9 # Licensed under the Apache License, Version 2.0 (the "License"); you may
10 # not use this file except in compliance with the License. You may obtain
11 # a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18 # License for the specific language governing permissions and limitations
21 # For those usages not covered by the Apache License, Version 2.0 please
22 # contact: osslegalrouting@vmware.com
28 class RepeatingTimer(threading
._Timer
):
29 """ Class to run thread parally """
31 """ Method to run thread """
33 self
.finished
.wait(self
.interval
)
34 if self
.finished
.is_set():
37 self
.function(*self
.args
, **self
.kwargs
)
40 class CommandProgressbar(object):
41 """ Class to show progressbar while waiting fro command output """
46 def __show_progressbar(self
):
48 Private method to show progressbar while waiting for command to complete
55 def start_progressbar(self
):
57 Method to start progressbar thread
61 self
.timer
= RepeatingTimer(1.0, self
.__show
_progressbar
)
62 self
.timer
.daemon
= True # Allows program to exit if only the thread is alive
65 def stop_progressbar(self
):
67 Method to stop progressbar thread