Exemple #1
0
 def confirmed1(self, arg):
     from Components import Task
     job = Task.Job(_("Reconstruct AP/SC"))
     task = Task.PythonTask(job, _("Reconstruct AP/SC"))
     task.work = self.offline.reindex
     Task.job_manager.AddJob(job)
     self.close()
Exemple #2
0
	def addToTask(self, service, path):
		name = self.getName(service, path)
		offline = self.serviceHandler.offlineOperations(service)
		if offline is None:
			print "[Reconstruct AP/SC] Cannot reconstruct", name
			return
		text = _("Reconstruct AP/SC - %s") % name
		job = Task.Job(text)
		task = Task.PythonTask(job, text)
		task.work = offline.reindex
		Task.job_manager.AddJob(job)
Exemple #3
0
 def confirmed1(self, arg):
     global rApScTasks
     if not rApScTimer.isActive():
         rApScTimer.startLongTimer(10)
         rApScTasks = []
     rApScTasks.append(str(len(rApScTasks) + 1) + '. ' + self.name)
     job = Task.Job(_("Reconstruct AP/SC"))
     task = Task.PythonTask(job, self.name)
     task.work = self.offline.reindex
     Task.job_manager.AddJob(job)
     self.close()
Exemple #4
0
	def createInitializeJob(self):
		job = Task.Job(_("Initializing storage device..."))
		size = self.diskSize()
		print("[Harddisk] size: %s MB" % size)

		task = UnmountTask(job, self)

		task = Task.PythonTask(job, _("Removing partition table"))
		task.work = self.killPartitionTable
		task.weighting = 1

		task = Task.LoggingTask(job, _("Rereading partition table"))
		task.weighting = 1
		task.setTool('hdparm')
		task.args.append('-z')
		task.args.append(self.disk_path)

		task = Task.ConditionTask(job, _("Waiting for partition"), timeoutCount=20)
		task.check = lambda: not os.path.exists(self.partitionPath("1"))
		task.weighting = 1

		if os.path.exists('/usr/sbin/parted'):
			use_parted = True
		else:
			if size > 2097151:
				addInstallTask(job, 'parted')
				use_parted = True
			else:
				use_parted = False

		task = Task.LoggingTask(job, _("Creating partition"))
		task.weighting = 5
		if use_parted:
			task.setTool('parted')
			if size < 1024:
				# On very small devices, align to block only
				alignment = 'min'
			else:
				# Prefer optimal alignment for performance
				alignment = 'opt'
			if size > 2097151:
				parttype = 'gpt'
			else:
				parttype = 'msdos'
			task.args += ['-a', alignment, '-s', self.disk_path, 'mklabel', parttype, 'mkpart', 'primary', '0%', '100%']
		else:
			task.setTool('sfdisk')
			task.args.append('-f')
			task.args.append('-uS')
			task.args.append(self.disk_path)
			if size > 128000:
				# Start at sector 8 to better support 4k aligned disks
				print("[Harddisk] Detected >128GB disk, using 4k alignment")
				task.initial_input = "8,,L\n;0,0\n;0,0\n;0,0\ny\n"
			else:
				# Smaller disks (CF cards, sticks etc) don't need that
				task.initial_input = ",,L\n;\n;\n;\ny\n"

		task = Task.ConditionTask(job, _("Waiting for partition"))
		task.check = lambda: os.path.exists(self.partitionPath("1"))
		task.weighting = 1

		task = MkfsTask(job, _("Creating filesystem"))
		big_o_options = ["dir_index"]
		if isFileSystemSupported("ext4"):
			task.setTool("mkfs.ext4")
			if size > 20000:
				try:
					version = map(int, open("/proc/version", "r").read().split(' ', 4)[2].split('.', 2)[:2])
					if (version[0] > 3) or (version[0] > 2 and version[1] >= 2):
						# Linux version 3.2 supports bigalloc and -C option, use 256k blocks
						task.args += ["-C", "262144"]
						big_o_options.append("bigalloc")
				except Exception as ex:
					print("[Harddisk] Failed to detect Linux version:", ex)
		else:
			task.setTool("mkfs.ext3")
		if size > 250000:
			# No more than 256k i-nodes (prevent problems with fsck memory requirements)
			task.args += ["-T", "largefile", "-N", "262144"]
			big_o_options.append("sparse_super")
		elif size > 16384:
			# between 16GB and 250GB: 1 i-node per megabyte
			task.args += ["-T", "largefile"]
			big_o_options.append("sparse_super")
		elif size > 2048:
			# Over 2GB: 32 i-nodes per megabyte
			task.args += ["-T", "largefile", "-N", str(size * 32)]
		task.args += ["-F", "-F", "-m0", "-O", ",".join(big_o_options), self.partitionPath("1")]

		task = MountTask(job, self)
		task.weighting = 3

		task = Task.ConditionTask(job, _("Waiting for mount"), timeoutCount=20)
		task.check = self.mountDevice
		task.weighting = 1

		return job
    def createInitializeJob(self):
        print("[Harddisk] Initializing storage device...")
        job = Task.Job(_("Initializing storage device..."))
        size = self.diskSize()
        print("[Harddisk] Disk size: %s MB." % size)
        task = UnmountTask(job, self)
        task = Task.PythonTask(job, _("Removing partition table."))
        task.work = self.killPartitionTable
        task.weighting = 1
        task = Task.LoggingTask(job, _("Rereading partition table."))
        task.weighting = 1
        task.setTool("hdparm")
        task.args.append("-z")
        task.args.append(self.disk_path)
        task = Task.ConditionTask(job,
                                  _("Waiting for partition."),
                                  timeoutCount=20)
        task.check = lambda: not exists(self.partitionPath("1"))
        task.weighting = 1
        if exists("/usr/sbin/parted"):
            use_parted = True
        else:
            if size > 2097151:
                addInstallTask(job, "parted")
                use_parted = True
            else:
                use_parted = False
        print("[Harddisk] Creating partition.")
        task = Task.LoggingTask(job, _("Creating partition."))
        task.weighting = 5
        if use_parted:
            task.setTool("parted")
            if size < 1024:
                alignment = "min"  # On very small devices, align to block only.
            else:
                alignment = "opt"  # Prefer optimal alignment for performance.
            if size > 2097151:
                parttype = "gpt"
            else:
                parttype = "msdos"
            task.args += [
                "-a", alignment, "-s", self.disk_path, "mklabel", parttype,
                "mkpart", "primary", "0%", "100%"
            ]
        else:
            task.setTool("sfdisk")
            task.args.append("-f")
            task.args.append("-uS")
            task.args.append(self.disk_path)
            if size > 128000:
                # Start at sector 8 to better support 4k aligned disks
                print("[Harddisk] Detected >128GB disk, using 4k alignment.")
                task.initial_input = "8,,L\n;0,0\n;0,0\n;0,0\ny\n"
            else:
                # Smaller disks (CF cards, sticks etc) don't need that
                task.initial_input = ",,L\n;\n;\n;\ny\n"
        task = Task.ConditionTask(job, _("Waiting for partition"))
        task.check = lambda: exists(self.partitionPath("1"))
        task.weighting = 1
        task = MkfsTask(job, _("Creating filesystem"))
        big_o_options = ["dir_index"]
        if isFileSystemSupported("ext4"):
            task.setTool("mkfs.ext4")
            if size > 20000:
                try:
                    version = map(
                        int,
                        fileReadLine("/proc/version").split(" ", 4)[2].split(
                            ".", 2)[:2])
                    if (version[0] > 3) or (version[0] > 2
                                            and version[1] >= 2):
                        # Linux version 3.2 supports bigalloc and -C option, use 256k blocks
                        task.args += ["-C", "262144"]
                        big_o_options.append("bigalloc")
                except Exception as err:
                    print(
                        "[Harddisk] Error: Failed to detect Linux version - '%s'!"
                        % str(err))
        else:
            task.setTool("mkfs.ext3")
        if size > 250000:
            # No more than 256k i-nodes (prevent problems with fsck memory requirements)
            task.args += ["-T", "largefile", "-N", "262144"]
            big_o_options.append("sparse_super")
        elif size > 16384:
            # between 16GB and 250GB: 1 i-node per megabyte
            task.args += ["-T", "largefile"]
            big_o_options.append("sparse_super")
        elif size > 2048:
            # Over 2GB: 32 i-nodes per megabyte
            task.args += ["-T", "largefile", "-N", str(size * 32)]
        task.args += [
            "-F", "-F", "-m0", "-O", ",".join(big_o_options),
            self.partitionPath("1")
        ]
        task = MountTask(job, self)
        task.weighting = 3
        task = Task.ConditionTask(job, _("Waiting for mount"), timeoutCount=20)
        task.check = self.mountDevice
        task.weighting = 1

        task = Task.PythonTask(job, _("Create directory") + ": movie")
        task.work = self.createMovieDir
        task.weighting = 1

        return job