def __init__(self, parent, umlmachines, name='InstallerWidget'): QWidget.__init__(self, parent, name) self.resize(600, 600) self.app = get_application_pointer() self.conn = self.app.conn self.umlmachines = umlmachines self.machine = self.umlmachines.current self.current_machine_process = 'start' self.current_profile = None self.current_trait = None self.traitlist = [] self.curenv = CurrentEnvironment(self.conn, self.machine) self.curenv['current_profile'] = 'None' self.curenv['current_trait'] = 'None' self.curenv['current_machine_process'] = self.current_machine_process self.timer = QTimer(self) self.connect(self.timer, SIGNAL('timeout()'), self.update_progress) self.timer.startTimer(1000) self.grid = QGridLayout(self, 4, 1, 5, 7) self.main_label = QLabel(self) self.main_label.setText(self._msg()) self.grid.addWidget(self.main_label, 0, 0) self.profile_progress_lbl = QLabel(self) self.grid.addWidget(self.profile_progress_lbl, 1, 0) self.profile_progress = KProgress(self) self.grid.addWidget(self.profile_progress, 2, 0) self.logview = LogBrowser(self, '/tmp/uml-installer.log') self.grid.addWidget(self.logview, 3, 0) #self.console_view = StdOutBrowser(self) #self.console_view = KTextBrowser(self) #self.grid.addWidget(self.console_view, 4, 0) self.console_text = ''
class AuditGameDialog(BaseDialogWindow): def __init__(self, parent, name='AuditGameDialog'): BaseDialogWindow.__init__(self, parent, name=name) #self.grid = QGridLayout(self, 2, 1, 5, 7) self.frame = KTextBrowser(self) self.frame.setNotifyClick(True) self.frame.setSource = self.setSource self.doc = AuditGameDocument(self.app) #self.grid.addWidget(self.frame, 0, 0) self.progress_label = QLabel(self) self.progress = KProgress(self) #self.grid.addWidget(self.progress, 1, 0) self.setMainWidget(self.frame) layout = self.layout() # we use insertWidget instead of # addWidget here so the widgets # are above the dialog buttons # self frame should be at 0 index in the layout # we set the progress and label below this layout.insertWidget(1, self.progress) # inserting into index 1 here knocks self.progress down to 2 layout.insertWidget(1, self.progress_label) # disable and hide extra buttons self.enableButtonApply(False) self.showButtonApply(False) self.enableButtonCancel(False) self.showButtonCancel(False) # the dialog should be a little taller than what # it defaults to self.resize(0, 300) def report_md5check(self, filename, count): self.progress_label.setText('checking %s' % filename) self.progress.setProgress(count) self.app.processEvents() def audit_game(self, name, from_install=True, time='now'): filehandler = self.app.make_new_fileshandler() total = len(filehandler.datahandler.get_installed_files(name)) self.progress.setTotalSteps(total) filehandler.archivehelper.report_installed_file_handled = self.report_md5check unchanged, changed, extra = filehandler.audit_game_files(name, from_install=from_install, time=time) self.doc.set_info(unchanged, changed, extra) self.frame.setText(self.doc.output()) self.progress_label.setText('Audit Completed') def setSource(self, url): print url if url == 'show': self.doc.append_unchanged_files() self.frame.setText(self.doc.output())
def __init__(self, parent, name='AuditGameDialog'): BaseDialogWindow.__init__(self, parent, name=name) #self.grid = QGridLayout(self, 2, 1, 5, 7) self.frame = KTextBrowser(self) self.frame.setNotifyClick(True) self.frame.setSource = self.setSource self.doc = AuditGameDocument(self.app) #self.grid.addWidget(self.frame, 0, 0) self.progress_label = QLabel(self) self.progress = KProgress(self) #self.grid.addWidget(self.progress, 1, 0) self.setMainWidget(self.frame) layout = self.layout() # we use insertWidget instead of # addWidget here so the widgets # are above the dialog buttons # self frame should be at 0 index in the layout # we set the progress and label below this layout.insertWidget(1, self.progress) # inserting into index 1 here knocks self.progress down to 2 layout.insertWidget(1, self.progress_label) # disable and hide extra buttons self.enableButtonApply(False) self.showButtonApply(False) self.enableButtonCancel(False) self.showButtonCancel(False) # the dialog should be a little taller than what # it defaults to self.resize(0, 300)
def __init__(self, parent, umlmachines, name="InstallerWidget"): QWidget.__init__(self, parent, name) self.resize(600, 600) self.app = get_application_pointer() self.conn = self.app.conn self.umlmachines = umlmachines self.machine = self.umlmachines.current self.current_machine_process = "start" self.current_profile = None self.current_trait = None self.traitlist = [] self.curenv = CurrentEnvironment(self.conn, self.machine) self.curenv["current_profile"] = "None" self.curenv["current_trait"] = "None" self.curenv["current_machine_process"] = self.current_machine_process self.timer = QTimer(self) self.connect(self.timer, SIGNAL("timeout()"), self.update_progress) self.timer.startTimer(1000) self.grid = QGridLayout(self, 4, 1, 5, 7) self.main_label = QLabel(self) self.main_label.setText(self._msg()) self.grid.addWidget(self.main_label, 0, 0) self.profile_progress_lbl = QLabel(self) self.grid.addWidget(self.profile_progress_lbl, 1, 0) self.profile_progress = KProgress(self) self.grid.addWidget(self.profile_progress, 2, 0) self.logview = LogBrowser(self, "/tmp/uml-installer.log") self.grid.addWidget(self.logview, 3, 0) # self.console_view = StdOutBrowser(self) # self.console_view = KTextBrowser(self) # self.grid.addWidget(self.console_view, 4, 0) self.console_text = ""
def __init__(self, parent, action, name='MultiGameProgress'): QWidget.__init__(self, parent, name) self.app = get_application_pointer() self.fhandler = self.app.make_new_fileshandler() self.action = action self.game_progressBar = KProgress(self) self.file_progressBar = KProgress(self) self.file_progressBarLbl = QLabel(self) self.game_progressBarLbl = QLabel(self) self.grid = QGridLayout(self, 4, 1, 5, 7) self.grid.addWidget(self.file_progressBarLbl, 0, 0) self.grid.addWidget(self.file_progressBar, 1, 0) self.grid.addWidget(self.game_progressBarLbl, 2, 0) self.grid.addWidget(self.game_progressBar, 3, 0) if action == 'prepare_game': self.game_action = 'Prepare' self.fhandler._report_extract_from_installed_archive = self.report_file_extracted else: self.game_action = 'Clean up' self.fhandler.archivehelper.report_installed_file_handled = self.report_file_handled
class InstallerWidget(QWidget): def __init__(self, parent, umlmachines, name='InstallerWidget'): QWidget.__init__(self, parent, name) self.resize(600, 600) self.app = get_application_pointer() self.conn = self.app.conn self.umlmachines = umlmachines self.machine = self.umlmachines.current self.current_machine_process = 'start' self.current_profile = None self.current_trait = None self.traitlist = [] self.curenv = CurrentEnvironment(self.conn, self.machine) self.curenv['current_profile'] = 'None' self.curenv['current_trait'] = 'None' self.curenv['current_machine_process'] = self.current_machine_process self.timer = QTimer(self) self.connect(self.timer, SIGNAL('timeout()'), self.update_progress) self.timer.startTimer(1000) self.grid = QGridLayout(self, 4, 1, 5, 7) self.main_label = QLabel(self) self.main_label.setText(self._msg()) self.grid.addWidget(self.main_label, 0, 0) self.profile_progress_lbl = QLabel(self) self.grid.addWidget(self.profile_progress_lbl, 1, 0) self.profile_progress = KProgress(self) self.grid.addWidget(self.profile_progress, 2, 0) self.logview = LogBrowser(self, '/tmp/uml-installer.log') self.grid.addWidget(self.logview, 3, 0) #self.console_view = StdOutBrowser(self) #self.console_view = KTextBrowser(self) #self.grid.addWidget(self.console_view, 4, 0) self.console_text = '' def _msg(self): return 'Installing uml machine %s - %s' % ( self.machine, self.current_machine_process) def update_console_text(self): if self.umlmachines.run_process is not None: stdout = self.umlmachines.run_process.stdout stdoutfd = stdout.fileno() ready = select.select([stdoutfd], [], []) while stdoutfd in ready[0]: line = stdout.readline() if line: self.console_text += line ready = select.select([stdoutfd], [], []) stdout = self.umlmachines.run_process.stdout line = stdout.readline() if line: self.console_text += line self.console_view.setText(self.console_text) def update_progress(self): #self.update_console_text() process = self.curenv['current_machine_process'] #print 'update_progress', process if process != self.current_machine_process: self.current_machine_process = process self.main_label.setText(self._msg()) if self.current_profile is None: profile = self.curenv['current_profile'] if profile != 'None': self.current_profile = profile print 'profile set to', profile traitlist = self.curenv['traitlist'] tl = [t.strip() for t in traitlist.split(',')] self.traitlist = tl self.profile_progress.setTotalSteps(len(self.traitlist)) else: trait = self.curenv['current_trait'] if trait != 'None': trait_process = self.curenv['current_trait_process'] profile = self.current_profile msg = 'Installing profile %s, trait %s, process %s' % ( profile, trait, trait_process) self.profile_progress_lbl.setText(msg) self.profile_progress.setProgress( self.traitlist.index(trait) + 1) self.app.processEvents()
class InstallerWidget(QWidget): def __init__(self, parent, umlmachines, name="InstallerWidget"): QWidget.__init__(self, parent, name) self.resize(600, 600) self.app = get_application_pointer() self.conn = self.app.conn self.umlmachines = umlmachines self.machine = self.umlmachines.current self.current_machine_process = "start" self.current_profile = None self.current_trait = None self.traitlist = [] self.curenv = CurrentEnvironment(self.conn, self.machine) self.curenv["current_profile"] = "None" self.curenv["current_trait"] = "None" self.curenv["current_machine_process"] = self.current_machine_process self.timer = QTimer(self) self.connect(self.timer, SIGNAL("timeout()"), self.update_progress) self.timer.startTimer(1000) self.grid = QGridLayout(self, 4, 1, 5, 7) self.main_label = QLabel(self) self.main_label.setText(self._msg()) self.grid.addWidget(self.main_label, 0, 0) self.profile_progress_lbl = QLabel(self) self.grid.addWidget(self.profile_progress_lbl, 1, 0) self.profile_progress = KProgress(self) self.grid.addWidget(self.profile_progress, 2, 0) self.logview = LogBrowser(self, "/tmp/uml-installer.log") self.grid.addWidget(self.logview, 3, 0) # self.console_view = StdOutBrowser(self) # self.console_view = KTextBrowser(self) # self.grid.addWidget(self.console_view, 4, 0) self.console_text = "" def _msg(self): return "Installing uml machine %s - %s" % (self.machine, self.current_machine_process) def update_console_text(self): if self.umlmachines.run_process is not None: stdout = self.umlmachines.run_process.stdout stdoutfd = stdout.fileno() ready = select.select([stdoutfd], [], []) while stdoutfd in ready[0]: line = stdout.readline() if line: self.console_text += line ready = select.select([stdoutfd], [], []) stdout = self.umlmachines.run_process.stdout line = stdout.readline() if line: self.console_text += line self.console_view.setText(self.console_text) def update_progress(self): # self.update_console_text() process = self.curenv["current_machine_process"] # print 'update_progress', process if process != self.current_machine_process: self.current_machine_process = process self.main_label.setText(self._msg()) if self.current_profile is None: profile = self.curenv["current_profile"] if profile != "None": self.current_profile = profile print "profile set to", profile traitlist = self.curenv["traitlist"] tl = [t.strip() for t in traitlist.split(",")] self.traitlist = tl self.profile_progress.setTotalSteps(len(self.traitlist)) else: trait = self.curenv["current_trait"] if trait != "None": trait_process = self.curenv["current_trait_process"] profile = self.current_profile msg = "Installing profile %s, trait %s, process %s" % (profile, trait, trait_process) self.profile_progress_lbl.setText(msg) self.profile_progress.setProgress(self.traitlist.index(trait) + 1) self.app.processEvents()
def __init__(self, parent, name='SimpleProgress'): KProgress.__init__(self, parent, name) self.app = get_application_pointer()
class MultiGameProgress(QWidget): def __init__(self, parent, action, name='MultiGameProgress'): QWidget.__init__(self, parent, name) self.app = get_application_pointer() self.fhandler = self.app.make_new_fileshandler() self.action = action self.game_progressBar = KProgress(self) self.file_progressBar = KProgress(self) self.file_progressBarLbl = QLabel(self) self.game_progressBarLbl = QLabel(self) self.grid = QGridLayout(self, 4, 1, 5, 7) self.grid.addWidget(self.file_progressBarLbl, 0, 0) self.grid.addWidget(self.file_progressBar, 1, 0) self.grid.addWidget(self.game_progressBarLbl, 2, 0) self.grid.addWidget(self.game_progressBar, 3, 0) if action == 'prepare_game': self.game_action = 'Prepare' self.fhandler._report_extract_from_installed_archive = self.report_file_extracted else: self.game_action = 'Clean up' self.fhandler.archivehelper.report_installed_file_handled = self.report_file_handled def set_game_label(self, game): message = '%s game <b>%s</b>' % (self.game_action, game) self.game_progressBarLbl.setText(message) def report_file_handled(self, filename, count): msg = 'File %s handled.' % filename self.file_progressBarLbl.setText(msg) self.file_progressBar.setProgress(count) self.app.processEvents() def report_file_extracted(self, filenamee, count, total): if count == 1: self.file_progressBar.setTotalSteps(total) msg = '%s extracted.' % filenamee self.file_progressBarLbl.setText(msg) self.file_progressBar.setProgress(count) self.app.processEvents() def report_action_on_game(self, game, title): progress = self.game_progressBar.progress() print 'game progress', progress self.set_game_label(title) progress += 1 self.game_progressBar.setProgress(progress) if self.action == 'cleanup_game': total = len(self.fhandler.datahandler.get_installed_files(game)) self.file_progressBar.setTotalSteps(total) self.file_progressBar.setProgress(0) self.app.processEvents() def act_on_games(self, gamelist, titles): num_games = len(gamelist) action_method = getattr(self.fhandler, self.action) self.game_progressBar.setTotalSteps(num_games) for game in gamelist: self.report_action_on_game(game, titles[game]) action_method(game)