Within your main python file you get a bunch of stuff for free:

I normally call these .cft files, see examples/ for examples.


Functions and Objects:
	files:
		run(cmd)
		 	Lets you execute shell code.  returns (returnCode, [output])
		append(files,lines,out='REPLACE',linesep=True)
			append is way to append lines in files if the line is not already in the file (exact match only)
		sub(files,subs,out='REPLACE')
			sub is a sed-like subsitution for lines in files.
        getOctPerms(filename)
            return octal string of current permissions on filename
        getStringPerms(filename)
            return User,Group and Other perms in 'rwx' format of current permissions on filename
        getOwner(filename)
            return the current UID.
        getGroup(filename)
            return the current GID.
        setPermissions(filename,owner,group,mode):
            set owner,group and mode on filename (owner/group can be names or UID/GID, mode is octal
    
				
	procs:
		stopService(svcname)
            Stop a system service
		startService(svcname)
            Start a system service
		checkService(svcname)
            Check if a system service is running.
        restartService(svcname)
            Restart a system service.

        stopProcess(name)
            stop a process.  name is regex against running processes.
        startProcess(cmd):
           same as run. except on OSX uses open. does not daemonize for you.
		getProcesses()
			returns a ton of info about the running processes. in a {} keys ARE:
                USER
                PID
                CPU
                MEM
                VSZ
                RSS
                TT
                STAT
                STARTED
                TIME
                COMMAND
            For more information see the manpage of ps auxww
		isRunning(name)
			check if 'name' is running, name is regexed against list of running processes.


    classes:
        Storage Object (dictionary):

            DISTRIB_ID          Unix Distribution
            DISTRIB_RELEASE     Unix Version
            hostname            hostname of machine.
            hour                current (at time of execution)
            dow                 current Day Of the Week) (Monday,Tuesday,etc.)
            platform            type of system.
            mainip              Main IP address of machine.
            kernelver           version of linux kernel
            dirname             The directory from which the currently running cft file came from.

        add to with: classes.classes[key] = value

        

    include(filename)
        lets you include another .cft file.

    pkg:
        installPythonEgg(package)
            Install a python egg using easy_install.

        isInstalled(pkgname)
            returns if pkgname is installed or not
        getPackages()
            return list of packages and their versions as a dic {name:version}
        installPackage(pkgname)
            if pkg is not already installed install it.
        removePackage(pkgname)
            remove package from system.
        updatePackages()
            update list of available packages.
        upgradePackages()
            upgrade installed packages.

    pear:
        getPackages()
            get list of installed PHP pear packages
        installPackage(pkgname)
            install pkgname
        removePackage(pkgname)
            remove pkgname
