@@ -0,0 +1,1458 @@
+import os%0Aimport tarfile%0Aimport datetime%0Aimport shutil%0Aimport tempfile%0A%0Adef submit():%0A    pth = os.getcwd()%0A    tmpdir = tempfile.mkdtemp()%0A    %0A    try:%0A        # copy everything to a temporary directory%0A        assignment = os.path.split(pth)%5B1%5D%0A        shutil.copytree(pth, os.path.join(tmpdir, assignment))%0A        os.chdir(tmpdir)%0A%0A        # get the user name, write it to file%0A        user = os.environ%5B'USER'%5D%0A        with open(os.path.join(assignment, %22user.txt%22), %22w%22) as fh:%0A            fh.write(user)%0A%0A        # save the submission time%0A        timestamp = str(datetime.datetime.now())%0A        with open(os.path.join(assignment, %22timestamp.txt%22), %22w%22) as fh:%0A            fh.write(timestamp)%0A%0A        # get the path to where we will save the archive%0A        archive = os.path.join(%0A            os.environ%5B'HOME'%5D, %22.submissions%22, %22%7B%7D.tar.gz%22.format(assignment))%0A        if not os.path.exists(os.path.dirname(archive)):%0A            os.makedirs(os.path.dirname(archive))%0A        if os.path.exists(archive):%0A            shutil.copy(archive, %22%7B%7D.bak%22.format(archive))%0A            os.remove(archive)%0A%0A        # create a tarball with the assignment files%0A        tf = tarfile.open(archive, %22w:gz%22)%0A        tf.add(assignment)%0A        tf.close()%0A        %0A    except:%0A        raise%0A        %0A    else:%0A        print(%22%7B%7D submitted by %7B%7D at %7B%7D%22.format(assignment, user, timestamp))%0A        %0A    finally:%0A        shutil.rmtree(tmpdir)%0A        os.chdir(pth)    %0A

Add module for student functions