asyncio loop working properly
This commit is contained in:
parent
ceca52dd70
commit
9af56f89e7
1 changed files with 13 additions and 6 deletions
19
nasg.py
19
nasg.py
|
@ -67,6 +67,7 @@ RE_PRECODE = re.compile(
|
||||||
r'<pre class="([^"]+)"><code>'
|
r'<pre class="([^"]+)"><code>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def url2slug(url, limit=200):
|
def url2slug(url, limit=200):
|
||||||
return slugify(
|
return slugify(
|
||||||
re.sub(r"^https?://(?:www)?", "", url),
|
re.sub(r"^https?://(?:www)?", "", url),
|
||||||
|
@ -74,6 +75,7 @@ def url2slug(url, limit=200):
|
||||||
lower=True
|
lower=True
|
||||||
)[:limit]
|
)[:limit]
|
||||||
|
|
||||||
|
|
||||||
def writepath(fpath, content, mtime=0):
|
def writepath(fpath, content, mtime=0):
|
||||||
d = os.path.dirname(fpath)
|
d = os.path.dirname(fpath)
|
||||||
if not os.path.isdir(d):
|
if not os.path.isdir(d):
|
||||||
|
@ -88,8 +90,6 @@ def writepath(fpath, content, mtime=0):
|
||||||
with open(fpath, mode) as f:
|
with open(fpath, mode) as f:
|
||||||
logger.info('writing file %s', fpath)
|
logger.info('writing file %s', fpath)
|
||||||
f.write(content)
|
f.write(content)
|
||||||
# TODO
|
|
||||||
# if (mtime > 0):
|
|
||||||
|
|
||||||
|
|
||||||
# def relurl(url,base=settings.site.get('url')):
|
# def relurl(url,base=settings.site.get('url')):
|
||||||
|
@ -103,6 +103,7 @@ def writepath(fpath, content, mtime=0):
|
||||||
#url = '.%s' % (url.path)
|
#url = '.%s' % (url.path)
|
||||||
# return os.path.relpath(url,start=base_dir)
|
# return os.path.relpath(url,start=base_dir)
|
||||||
|
|
||||||
|
|
||||||
class cached_property(object):
|
class cached_property(object):
|
||||||
""" extermely simple cached_property decorator:
|
""" extermely simple cached_property decorator:
|
||||||
whenever something is called as @cached_property, on first run, the
|
whenever something is called as @cached_property, on first run, the
|
||||||
|
@ -1645,7 +1646,11 @@ def makecomments():
|
||||||
if os.path.basename(e) == 'index.md':
|
if os.path.basename(e) == 'index.md':
|
||||||
continue
|
continue
|
||||||
# filenames are like [received epoch]-[slugified source url].md
|
# 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:
|
if mtime > newest:
|
||||||
newest = mtime
|
newest = mtime
|
||||||
newest = arrow.get(newest)
|
newest = arrow.get(newest)
|
||||||
|
@ -1667,6 +1672,7 @@ def makecomments():
|
||||||
logger.error('failed to query webmention.io: %s', e)
|
logger.error('failed to query webmention.io: %s', e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def makepost(fpath):
|
def makepost(fpath):
|
||||||
try:
|
try:
|
||||||
fname = os.path.basename(fpath)
|
fname = os.path.basename(fpath)
|
||||||
|
@ -1726,6 +1732,7 @@ def makeposts():
|
||||||
if makepost(js):
|
if makepost(js):
|
||||||
os.unlink(js)
|
os.unlink(js)
|
||||||
|
|
||||||
|
|
||||||
def make():
|
def make():
|
||||||
start = int(round(time.time() * 1000))
|
start = int(round(time.time() * 1000))
|
||||||
last = 0
|
last = 0
|
||||||
|
@ -1733,7 +1740,7 @@ def make():
|
||||||
try:
|
try:
|
||||||
makecomments()
|
makecomments()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('failed to make comments - are we offline?')
|
logger.error('failed to make comments: %s', e)
|
||||||
|
|
||||||
makeposts();
|
makeposts();
|
||||||
|
|
||||||
|
@ -1810,6 +1817,8 @@ def make():
|
||||||
staticfiles = []
|
staticfiles = []
|
||||||
staticpaths = [
|
staticpaths = [
|
||||||
os.path.join(content, '*.*'),
|
os.path.join(content, '*.*'),
|
||||||
|
os.path.join(settings.paths.get('tmpl'), '*.css'),
|
||||||
|
os.path.join(settings.paths.get('tmpl'), '*.js'),
|
||||||
]
|
]
|
||||||
for p in staticpaths:
|
for p in staticpaths:
|
||||||
staticfiles = staticfiles + glob.glob(p)
|
staticfiles = staticfiles + glob.glob(p)
|
||||||
|
@ -1836,8 +1845,6 @@ def make():
|
||||||
)
|
)
|
||||||
logger.info('syncing finished')
|
logger.info('syncing finished')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.info('sending webmentions')
|
logger.info('sending webmentions')
|
||||||
webmentions.run()
|
webmentions.run()
|
||||||
logger.info('sending webmentions finished')
|
logger.info('sending webmentions finished')
|
||||||
|
|
Loading…
Reference in a new issue