コード例 #1
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="Emaint",
                                     max_desc_length=27)
コード例 #2
0
ファイル: main.py プロジェクト: nullishzero/Portage
	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)
コード例 #3
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
        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()
            }
            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)
コード例 #4
0
ファイル: main.py プロジェクト: nullishzero/Portage
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
		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()
				}
			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)
コード例 #5
0
ファイル: main.py プロジェクト: pombredanne/portage-3
 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="Emaint", max_desc_length=27)