def blog_post(user, name, path, commits): ''' Convert the given path into a blog post. :arg user: User who is posting :arg name: Name of the problem/directory :arg path: Path to the git source. :arg commits: Github commit details ''' text = u'' if commits: commits.reverse() system('pushd .;cd gitsources/%s;git pull;popd' % user) fpath = os.path.join(path, 'solution.rst') if os.path.exists(fpath): # First remove the old listing directory try: shutil.rmtree(os.path.join('2013/listings/', user, name)) except OSError as e: print e # Then copy the directory to the listing shutil.copytree(path, '2013/listings/%s/%s' % (user, name)) title = '%s %s %s' %(user, name, get_timestamp()) try: fobj = codecs.open(fpath, 'r', encoding='utf-8') text = fobj.read() fobj.close() except Exception, e: print e text = text + '\n' + get_commits_text(commits) create_task(title, text, tags=[user,]) print "blog posted for", user, name
def blog_post(user, name, path, commits): ''' Convert the given path into a blog post. :arg user: User who is posting :arg name: Name of the problem/directory :arg path: Path to the git source. :arg commits: Github commit details ''' text = u'' if commits: commits.reverse() system('pushd .;cd gitsources/%s;git pull;popd' % user) fpath = os.path.join(path, 'solution.rst') if os.path.exists(fpath): # First remove the old listing directory try: shutil.rmtree(os.path.join('2013/listings/', user, name)) except OSError as e: print e # Then copy the directory to the listing shutil.copytree(path, '2013/listings/%s/%s' % (user, name)) title = '%s %s %s' % (user, name, get_timestamp()) try: fobj = codecs.open(fpath, 'r', encoding='utf-8') text = fobj.read() fobj.close() except Exception, e: print e text = text + '\n' + get_commits_text(commits) create_task(title, text, tags=[ user, ]) print "blog posted for", user, name
def reload_blog(): system('pushd .;cd 2013;nikola deploy;popd')