#coding:utf-8
import textwrap
class Modules(object):
    """
    Client auto partition module.
    """
    def __init__(self, command):
        self.cmd = command

    @property
    def __help__(self):
        info = """
        #==============================================================
        # %s
        #
        # module_path: %s
        # module_name: %s
        #==============================================================
        """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
        return info
        
    def run(self, args):

        content = []
        content.append(self.__help__)

        parts = """
        /bin/echo "sunhpc force-default" > /tmp/user_partition_info

        if [ ! -f /tmp/do_partition.py ]
        then
            /bin/cat /applets/partition.py > /tmp/do_partition.py
        fi

        /bin/chmod 755 /tmp/do_partition.py
        /tmp/do_partition.py
        """
        content.append(parts)
        self.cmd.ks.addPre(content)

    def __repr__(self):
        return "kickstart-partition"
