Example #1
0
	def __init__(self, show_progress_bar=True, verbose=True, callback=None, module_output=None):
		self.show_progress_bar = show_progress_bar
		self.verbose = verbose
		self.callback = callback
		self.module_output = module_output
		self.isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty()
		self.progress_bar = ProgressBar(self.isatty, title="Emaint", max_desc_length=27)
Example #2
0
 def __init__(self, show_progress_bar=True, verbose=True, callback=None):
     self.show_progress_bar = show_progress_bar
     self.verbose = verbose
     self.callback = callback
     self.isatty = os.environ.get("TERM") != "dumb" and sys.stdout.isatty()
     self.progress_bar = ProgressBar(
         self.isatty, title="Portage-Sync", max_desc_length=27
     )
Example #3
0
	def __init__(self, show_progress_bar=True, verbose=True, callback=None, module_output=None):
		self.show_progress_bar = show_progress_bar
		self.verbose = verbose
		self.callback = callback
		self.module_output = module_output
		self.isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty()
		self.progress_bar = ProgressBar(self.isatty, title="Emaint", max_desc_length=27)
Example #4
0
class TaskHandler(object):
    """Handles the running of the tasks it is given"""
    def __init__(self,
                 show_progress_bar=True,
                 verbose=True,
                 callback=None,
                 module_output=None):
        self.show_progress_bar = show_progress_bar
        self.verbose = verbose
        self.callback = callback
        self.module_output = module_output
        self.isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty()
        self.progress_bar = ProgressBar(self.isatty,
                                        title="Emaint",
                                        max_desc_length=27)

    def run_tasks(self, tasks, func, status=None, verbose=True, options=None):
        """Runs the module tasks"""
        if tasks is None or func is None:
            return
        returncodes = []
        for task in tasks:
            inst = task()
            show_progress = self.show_progress_bar and self.isatty
            # check if the function is capable of progressbar
            # and possibly override it off
            if show_progress and hasattr(inst, 'can_progressbar'):
                show_progress = inst.can_progressbar(func)
            if show_progress:
                self.progress_bar.reset()
                self.progress_bar.set_label(func + " " + inst.name())
                onProgress = self.progress_bar.start()
            else:
                onProgress = None
            kwargs = {
                'onProgress': onProgress,
                'module_output': self.module_output,
                # pass in a copy of the options so a module can not pollute or change
                # them for other tasks if there is more to do.
                'options': options.copy()
            }
            returncode, msgs = getattr(inst, func)(**kwargs)
            returncodes.append(returncode)
            if show_progress:
                # make sure the final progress is displayed
                self.progress_bar.display()
                print()
                self.progress_bar.stop()
            if self.callback:
                self.callback(msgs)

        return returncodes
Example #5
0
class TaskHandler(object):
	"""Handles the running of the tasks it is given"""

	def __init__(self, show_progress_bar=True, verbose=True, callback=None, module_output=None):
		self.show_progress_bar = show_progress_bar
		self.verbose = verbose
		self.callback = callback
		self.module_output = module_output
		self.isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty()
		self.progress_bar = ProgressBar(self.isatty, title="Emaint", max_desc_length=27)

	def run_tasks(self, tasks, func, status=None, verbose=True, options=None):
		"""Runs the module tasks"""
		if tasks is None or func is None:
			return
		returncodes = []
		for task in tasks:
			inst = task()
			show_progress = self.show_progress_bar and self.isatty
			# check if the function is capable of progressbar
			# and possibly override it off
			if show_progress and hasattr(inst, 'can_progressbar'):
				show_progress = inst.can_progressbar(func)
			if show_progress:
				self.progress_bar.reset()
				self.progress_bar.set_label(func + " " + inst.name())
				onProgress = self.progress_bar.start()
			else:
				onProgress = None
			kwargs = {
				'onProgress': onProgress,
				'module_output': self.module_output,
				# pass in a copy of the options so a module can not pollute or change
				# them for other tasks if there is more to do.
				'options': options.copy()
				}
			returncode, msgs = getattr(inst, func)(**kwargs)
			returncodes.append(returncode)
			if show_progress:
				# make sure the final progress is displayed
				self.progress_bar.display()
				print()
				self.progress_bar.stop()
			if self.callback:
				self.callback(msgs)

		return returncodes
Example #6
0
class TaskHandler:
    """Handles the running of the tasks it is given"""

    def __init__(self, show_progress_bar=True, verbose=True, callback=None):
        self.show_progress_bar = show_progress_bar
        self.verbose = verbose
        self.callback = callback
        self.isatty = os.environ.get("TERM") != "dumb" and sys.stdout.isatty()
        self.progress_bar = ProgressBar(
            self.isatty, title="Portage-Sync", max_desc_length=27
        )

    def run_tasks(self, tasks, func, status=None, verbose=True, options=None):
        """Runs the module tasks"""
        # Ensure we have a task and function
        assert tasks
        assert func
        for task in tasks:
            inst = task()
            show_progress = self.show_progress_bar and self.isatty
            # check if the function is capable of progressbar
            # and possibly override it off
            if show_progress and hasattr(inst, "can_progressbar"):
                show_progress = inst.can_progressbar(func)
            if show_progress:
                self.progress_bar.reset()
                self.progress_bar.set_label(func + " " + inst.name())
                onProgress = self.progress_bar.start()
            else:
                onProgress = None
            kwargs = {
                "onProgress": onProgress,
                # pass in a copy of the options so a module can not pollute or change
                # them for other tasks if there is more to do.
                "options": options.copy(),
            }
            result = getattr(inst, func)(**kwargs)
            if show_progress:
                # make sure the final progress is displayed
                self.progress_bar.display()
                print()
                self.progress_bar.stop()
            if self.callback:
                self.callback(result)
Example #7
0
class TaskHandler(object):
    """Handles the running of the tasks it is given
	"""

    def __init__(self, show_progress_bar=True, verbose=True, callback=None):
        self.show_progress_bar = show_progress_bar
        self.verbose = verbose
        self.callback = callback
        self.isatty = os.environ.get("TERM") != "dumb" and sys.stdout.isatty()
        self.progress_bar = ProgressBar(self.isatty, title="Portage-Sync", max_desc_length=27)

    def run_tasks(self, tasks, func, status=None, verbose=True, options=None):
        """Runs the module tasks"""
        # Ensure we have a task and function
        assert tasks
        assert func
        for task in tasks:
            inst = task()
            show_progress = self.show_progress_bar and self.isatty
            # check if the function is capable of progressbar
            # and possibly override it off
            if show_progress and hasattr(inst, "can_progressbar"):
                show_progress = inst.can_progressbar(func)
            if show_progress:
                self.progress_bar.reset()
                self.progress_bar.set_label(func + " " + inst.name())
                onProgress = self.progress_bar.start()
            else:
                onProgress = None
            kwargs = {
                "onProgress": onProgress,
                # pass in a copy of the options so a module can not pollute or change
                # them for other tasks if there is more to do.
                "options": options.copy(),
            }
            result = getattr(inst, func)(**kwargs)
            if show_progress:
                # make sure the final progress is displayed
                self.progress_bar.display()
                print()
                self.progress_bar.stop()
            if self.callback:
                self.callback(result)
Example #8
0
 def __init__(self, show_progress_bar=True, verbose=True, callback=None):
     self.show_progress_bar = show_progress_bar
     self.verbose = verbose
     self.callback = callback
     self.isatty = os.environ.get("TERM") != "dumb" and sys.stdout.isatty()
     self.progress_bar = ProgressBar(self.isatty, title="Portage-Sync", max_desc_length=27)