def testGetResourceFileName(self): r = resources.Resources('/test') self.assertRaises(resources.FileNotFound, r.GetResourceFileName, 'missing.txt') self.assertEqual(r.GetResourceFileName('file.txt'), '/test/file.txt') with mock.patch.object(r.os, 'cwd') as cwd: cwd.return_value = '/test2' r = resources.Resources() self.assertEqual(r.GetResourceFileName('file.txt'), '/test2/resources/file.txt')
def LoadMap(self): res = resources.Resources() try: win_zones = parse( res.GetResourceFileName(FLAGS.windows_zones_resource)) except resources.FileNotFound: raise TimezoneError('Cannot load zone map from %s.' % FLAGS.windows_zones_resource) for zone in win_zones.getElementsByTagName('mapZone'): self.zones[zone.getAttribute('type')] = zone.getAttribute('other')
def _GuiLogo(self): """Creates the UI graphical logo.""" self.logo_frame = tk.Frame(self.root) self.logo_frame.columnconfigure(0, weight=1) r = resources.Resources() path = r.GetResourceFileName('logo.gif') self.logo_img = tk.PhotoImage(file=path) self.logo = tk.Label(self.logo_frame, image=self.logo_img, text='logo here') self.logo.grid(column=0, row=0, sticky='SE') self.logo_frame.grid(column=0, row=self.row, sticky='EW') self.row += 1
def _GetResPath(self, path): """Translate an installer resource path into a local path. Args: path: the resource path string Raises: PowerShellError: unable to locate the requested resource Returns: The local filesystem path as a string. """ r = resources.Resources() try: path = r.GetResourceFileName(path) except resources.FileNotFound as e: raise PowerShellError(e) return os.path.normpath(path)