From 9af56f89e7a9968eefaa2b64c8157b743d6efe6b Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Mon, 19 Nov 2018 16:16:52 +0000 Subject: [PATCH] asyncio loop working properly --- nasg.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nasg.py b/nasg.py index c82b263..162bcff 100644 --- a/nasg.py +++ b/nasg.py @@ -67,6 +67,7 @@ RE_PRECODE = re.compile( r'
'
 )
 
+
 def url2slug(url, limit=200):
     return slugify(
         re.sub(r"^https?://(?:www)?", "", url),
@@ -74,6 +75,7 @@ def url2slug(url, limit=200):
         lower=True
     )[:limit]
 
+
 def writepath(fpath, content, mtime=0):
     d = os.path.dirname(fpath)
     if not os.path.isdir(d):
@@ -88,8 +90,6 @@ def writepath(fpath, content, mtime=0):
     with open(fpath, mode) as f:
         logger.info('writing file %s', fpath)
         f.write(content)
-    # TODO
-    # if (mtime > 0):
 
 
 # def relurl(url,base=settings.site.get('url')):
@@ -103,6 +103,7 @@ def writepath(fpath, content, mtime=0):
     #url = '.%s' % (url.path)
     # return os.path.relpath(url,start=base_dir)
 
+
 class cached_property(object):
     """ extermely simple cached_property decorator:
     whenever something is called as @cached_property, on first run, the
@@ -1645,7 +1646,11 @@ def makecomments():
         if os.path.basename(e) == 'index.md':
             continue
         # filenames are like [received epoch]-[slugified source url].md
-        mtime = int(os.path.basename(e).split('-')[0])
+        try:
+            mtime = int(os.path.basename(e).split('-')[0])
+        except Exception as exc:
+            logger.error('int conversation failed: %s, file was: %s', exc, e)
+            continue
         if mtime > newest:
             newest = mtime
     newest = arrow.get(newest)
@@ -1667,6 +1672,7 @@ def makecomments():
         logger.error('failed to query webmention.io: %s', e)
         pass
 
+
 def makepost(fpath):
     try:
         fname = os.path.basename(fpath)
@@ -1726,6 +1732,7 @@ def makeposts():
         if makepost(js):
             os.unlink(js)
 
+
 def make():
     start = int(round(time.time() * 1000))
     last = 0
@@ -1733,7 +1740,7 @@ def make():
     try:
         makecomments()
     except Exception as e:
-        logger.error('failed to make comments - are we offline?')
+        logger.error('failed to make comments: %s', e)
 
     makeposts();
 
@@ -1810,6 +1817,8 @@ def make():
     staticfiles = []
     staticpaths = [
         os.path.join(content, '*.*'),
+        os.path.join(settings.paths.get('tmpl'), '*.css'),
+        os.path.join(settings.paths.get('tmpl'), '*.js'),
     ]
     for p in staticpaths:
         staticfiles = staticfiles + glob.glob(p)
@@ -1836,8 +1845,6 @@ def make():
         )
         logger.info('syncing finished')
 
-
-
         logger.info('sending webmentions')
         webmentions.run()
         logger.info('sending webmentions finished')