Esempio n. 1
0
    def test_DistTool(self):
        self.assertTrue(disttool.is_linux())
        self.assertTrue(disttool.is_redhat_based())
        self.assertTrue(disttool.is_fedora())

        self.assertFalse(disttool.is_win())
        self.assertFalse(disttool.is_sun())
        self.assertFalse(disttool.is_debian_based())
Esempio n. 2
0
	
		
	def __str__(self):
		return "%s\t%s\t%s\t%s\t%s\t%s" % (
			self.devname, self.mpoint, self.fstype, self.options, 
			self.dump if self.dump is not None else '', 
			self.fsckorder if self.fsckorder is not None else '' 
		)

		
if disttool.is_linux():
	Fstab.LOCATION = "/etc/fstab"	
	Mtab.LOCATION = "/etc/mtab"
	Mtab.LOCAL_FS_TYPES = ('ext2', 'ext3', 'xfs', 'jfs', 'reiserfs', 'tmpfs', 'sysfs', 'proc')
	
elif disttool.is_sun():
	Fstab.LOCATION = "/etc/vfstab"	
	Mtab.LOCATION = "/etc/mnttab"
	Mtab.LOCAL_FS_TYPES = ('ext2', 'ext3', 'xfs', 'jfs', 'reiserfs', 'tmpfs', 
		'ufs', 'sharefs', 'dev', 'devfs', 'ctfs', 'mntfs',
		'proc', 'lofs',   'objfs', 'fd', 'autofs')
	

def mount (device, mpoint = '/mnt', options=None, make_fs=False, fstype='ext3', auto_mount=False):
	if not os.path.exists(mpoint):
		os.makedirs(mpoint)
	
	options = options or ('-t', 'auto')
	
	if make_fs:
		mkfs(device,fstype)
Esempio n. 3
0
class Tar:
    EXECUTABLE = "/usr/sfw/bin/gtar" if disttool.is_sun() else "tar"

    _executable = None
    _options = None
    _files = None

    def __init__(self, executable=None):
        self._executable = executable if executable else self.EXECUTABLE
        self._options = []
        self._files = []

    def version(self):
        self._options.append("--version")
        return self

    def verbose(self):
        self._options.append("-v")
        return self

    def create(self):
        self._options.append("-c")
        return self

    def bzip2(self):
        self._options.append("-j")
        return self

    def diff(self):
        self._options.append("-d")
        return self

    def gzip(self):
        self._options.append("-z")
        return self

    def extract(self):
        self._options.append("-x")
        return self

    def update(self):
        self._options.append("-u")
        return self

    def sparse(self):
        self._options.append("-S")
        return self

    def dereference(self):
        self._options.append("-h")
        return self

    def archive(self, filename):
        self._options.append("-f " + filename if filename else "-")
        return self

    def chdir(self, dir):
        self._options.append("-C " + dir)
        return self

    def add(self, filename, dir=None):
        item = filename if dir is None else "-C " + dir + " " + filename
        self._files.append(item)
        return self

    def __str__(self):
        ret = "%(executable)s %(options)s %(files)s" % dict(
            executable=self._executable,
            options=" ".join(self._options),
            files=" ".join(self._files))
        return ret.strip()