Skip to content
Permalink
Browse files
Fix #2317 -- use state file for deploy dates in github_deploy and nik…
…ola status

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 29, 2016
1 parent 78adaf3 commit 91f245d7f491ff49c923e708cacf94f64dd2f6f9
Showing 4 changed files with 8 additions and 15 deletions.
@@ -9,6 +9,8 @@ Features
Bugfixes
--------

* Use state files in ``nikola github_deploy`` and ``nikola status``
(Issue #2317)
* Add ``align`` options for ``youtube``, ``vimeo``, ``soundcloud``
reST directives (Issue #2304)
* Update ``FILE_METADATA_REGEXP`` example in docs (Issue #2296)
@@ -130,7 +130,6 @@ def _execute(self, command, args):
new_deploy = datetime.utcnow()
self._emit_deploy_event(last_deploy, new_deploy, clean, undeployed_posts)

makedirs(self.site.config['CACHE_FOLDER'])
# Store timestamp of successful deployment
self.site.state.set('last_deploy', new_deploy.isoformat())

@@ -164,8 +164,5 @@ def _commit_and_push(self, commit_first_line):
self.logger.info("Successful deployment")

# Store timestamp of successful deployment
timestamp_path = os.path.join(self.site.config["CACHE_FOLDER"], "lastdeploy")
new_deploy = datetime.utcnow()
makedirs(self.site.config["CACHE_FOLDER"])
with io.open(timestamp_path, "w+", encoding="utf8") as outf:
outf.write(unicode_str(new_deploy.isoformat()))
self.site.state.set('last_deploy', new_deploy.isoformat())
@@ -27,7 +27,6 @@
"""Display site status."""

from __future__ import print_function
import io
import os
from datetime import datetime
from dateutil.tz import gettz, tzlocal
@@ -75,15 +74,11 @@ def _execute(self, options, args):
"""Display site status."""
self.site.scan_posts()

timestamp_path = os.path.join(self.site.config["CACHE_FOLDER"], "lastdeploy")

last_deploy = None

try:
with io.open(timestamp_path, "r", encoding="utf8") as inf:
last_deploy = datetime.strptime(inf.read().strip(), "%Y-%m-%dT%H:%M:%S.%f")
last_deploy_offset = datetime.utcnow() - last_deploy
except (IOError, Exception):
last_deploy = self.site.state.get('last_deploy')
if last_deploy is not None:
last_deploy = datetime.strptime(last_deploy, "%Y-%m-%dT%H:%M:%S.%f")
last_deploy_offset = datetime.utcnow() - last_deploy
else:
print("It does not seem like you've ever deployed the site (or cache missing).")

if last_deploy:

0 comments on commit 91f245d

Please sign in to comment.