Exemple #1
0
		def resp(dialog, r):
			if r == g.RESPONSE_OK:
				if not self.tmpdir:
					rox.alert("Archive not downloaded yet!")
					return
				unpack_dir = os.path.join(self.tmpdir, 'unpacked')

				url = widgets.get_widget('archive_url').get_text()
				if urlparse.urlparse(url)[1] == '':
					raise Exception('Missing host name in URL "%s"' % url)
				if urlparse.urlparse(url)[2] == '':
					raise Exception('Missing resource part in URL "%s"' % url)
				local_archive = widgets.get_widget('local_archive').get_filename()
				if not local_archive:
					raise Exception('Please select a local file')
				if selection.iter_is_selected(model.get_iter_root()):
					root = unpack_dir
					extract = None
				else:
					_, iter = selection.get_selected()
					extract = model[iter][0]
					root = os.path.join(unpack_dir, extract)

				size = os.path.getsize(local_archive)
				if self.start_offset:
					size -= self.start_offset
				self.create_archive_element(url, self.mime_type, root, extract, size,
						    self.start_offset)
			self.destroy_tmp()
			dialog.destroy()
Exemple #2
0
	def set_initial_expansion(self):
		model = self.model
		try:
			i = model.get_iter_root()
			while i:
				# expand only "Feeds"
				if model[i][ITEM_OBJECT.idx] is SECTION_INTERFACES:
					self.tree_view.expand_row(model.get_path(i), False)
				i = model.iter_next(i)
		finally:
			self.window.get_window().set_cursor(None)
Exemple #3
0
	def set_initial_expansion(self):
		model = self.model
		try:
			i = model.get_iter_root()
			while i:
				# expand only "Feeds"
				if model[i][ITEM_OBJECT.idx] is SECTION_INTERFACES:
					self.tree_view.expand_row(model.get_path(i), False)
				i = model.iter_next(i)
		finally:
			self.window.get_window().set_cursor(None)
Exemple #4
0
		def local_archive_changed(chooser):
			model.clear()
			path = chooser.get_filename()
			widgets.get_widget('subdirectory_frame').set_sensitive(False)
			self.destroy_tmp()
			if not path: return

			if mime_type.get_active() == 0:
				type = None
			else:
				type = mime_type.get_active_text()

			archive_url = widgets.get_widget('archive_url')
			url = archive_url.get_text()
			if not url:
				url = 'http://SITE/' + os.path.basename(path)
				archive_url.set_text(url)

			start_offset = 0
			if not type:
				if url.endswith('.package'):
					type = 'Autopackage'
				else:
					type = unpack.type_from_url(url)

			if type == 'Autopackage':
				# Autopackage isn't a real type. Examine the .package file
				# and find out what it really is.
				start_offset, type = autopackage_get_details(path)

			self.tmpdir = tempfile.mkdtemp('-0publish-gui')
			try:
				# Must be readable to helper process running as 'zeroinst'...
				old_umask = os.umask(0022)
				try:
					unpack_dir = os.path.join(self.tmpdir, 'unpacked')
					os.mkdir(unpack_dir)

					dialog.window.set_cursor(watch)
					gtk.gdk.flush()
					try:
						unpack.unpack_archive(url, file(path), unpack_dir,
								      type = type, start_offset = start_offset)
						manifest.fixup_permissions(unpack_dir)
					finally:
						dialog.window.set_cursor(None)
				finally:
					os.umask(old_umask)
			except:
				chooser.unselect_filename(path)
				self.destroy_tmp()
				raise
			iter = model.append(None, ['Everything'])
			items = os.listdir(unpack_dir)
			for f in items:
				model.append(iter, [f])
			tree.expand_all()
			# Choose a sensible default
			iter = model.get_iter_root()
			if len(items) == 1 and \
		           os.path.isdir(os.path.join(unpack_dir, items[0])) and \
			   items[0] not in ('usr', 'opt', 'bin', 'etc', 'sbin', 'doc', 'var'):
				iter = model.iter_children(iter)
			selection.select_iter(iter)

			self.mime_type = type
			self.start_offset = start_offset
			widgets.get_widget('subdirectory_frame').set_sensitive(True)