def _load_functions(self): '''Load functions file if it's valid. Check that the functions file is valid. If so, import it and return the function object. ''' app = gnome.program_get() try: filename = app.locate_file(gnome.FILE_DOMAIN_DATADIR, os.path.join(PROGRAMNAME, 'data', self.functionFile), True) except AttributeError: # We were unable to get a gnome program. Try to find a # functions file in the same directory as the checklist. filename = os.path.join(self.fileLoadDir, self.functionFile) else: try: filename = filename[0] except IndexError: ### FIXME: This pathway is untested. Won't be tested until # we support checklists in user defined locations. # (ie: User specifies to load custom checklist from home # directory. Custom checklist has a function file in that # directory.) filename = os.path.join(self.fileLoadDir, self.functionFile) try: functionFile = file(filename) except IOError: raise error.InvalidFunctions, ('Unable to open the functions' ' file %s.' % (filename)) # Make sure functionFile matches the hash. if self.functionHashType == 'sha1': import sha as thehash elif self.functionHashType == 'md5': import md5 as thehash elif self.functionHashType == 'nullhash': thehash = NullHash() else: raise error.UnknownHashType, ('The checklist says the functions' ' file has hash %s of type %s which is an unknown type' % (self.functionHash, self.functionHashType)) hasher = thehash.new(''.join(functionFile.readlines())) if hasher.hexdigest() != self.functionHash: raise error.InvalidFunctions, ('Function file %s does not match' ' recorded hash' % (self.functionFile)) # If so, load the file sys.path.append(os.path.dirname(filename)) exec('import ' + self.functionFile[0:-3] + ' as functions') return functions.QAFunctions(self)
def __init__(self): ''' Initialize dialog. ''' program = program_get() gtk.AboutDialog.__init__(self) self.connect('response', self._onResponse) gtk.AboutDialog.set_authors(self, self.AUTHORS) gtk.AboutDialog.set_artists(self, self.ARTISTS) gtk.AboutDialog.set_documenters(self, self.DOCUMENTERS) gtk.AboutDialog.set_comments(self, self.COMMENTS) gtk.AboutDialog.set_copyright(self, self.COPYRIGHT) gtk.AboutDialog.set_license(self, self.LICENSE) gtk.AboutDialog.set_logo_icon_name(self, 'macaroon') gtk.AboutDialog.set_version(self, program.get_app_version()) gtk.AboutDialog.set_website(self, self.WEB_URL) gtk.AboutDialog.set_website_label(self, self.WEB_LABEL)
def __init__(self): status_icon = gtk.status_icon_new_from_stock(gtk.STOCK_MEDIA_RECORD) status_icon.connect('activate', self._onActivate) status_icon.connect('popup-menu', self._onPopup) status_icon.set_tooltip(self.start_tooltip) self.ui_manager = self._newUIManager() self.script_buffer = ScriptBuffer(self.ui_manager) self.script_buffer.clearBuffer() self.script_buffer.connect('notify::recording', self._onRecordChange, status_icon) self.macro_preview = None # Get program ID global APP_ID from gnome import program_get _prog = program_get() if _prog is not None: APP_ID = _prog.get_app_id() pyatspi.Registry.start()