def submit(crontab, username=None, password=None):
    """Submit a crontab via the crontab program.
    Supply a crontab object. If it is to be installed for a different user
    supply the `username` parameter. If this is not run as root, then sudo is
    used and you must supply your own password for sudo."""
    if username is None:
        ct = proctools.spawnpipe("crontab -")
        ct.write(str(crontab))
        ct.close()
        return ct.wait()
    else:
        if os.getuid() == 0:
            ct = proctools.spawnpipe("crontab -u %s -" % (username,))
            ct.write(str(crontab))
            ct.close()
            return ct.wait()
        else:
            from pycopia import sudo
            if password is None:
                from pycopia import tty
                password = tty.getpass("Your password:")
            ct = sudo.sudo("crontab -u %s -" % (username,), password=password)
            ct.write(str(crontab))
            ct.close()
            return ct.wait()


# A useful integer set class ripped from the mhlib module. Thanks!
dataset/ETHPy150Open kdart/pycopia/process/pycopia/crontab.py/submit/original