more stuff

master
nathaniel smith 2015-07-31 21:41:31 -07:00
parent 8751a6fa00
commit d1e87ac5b5
1 changed files with 9 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from functools import partial
from os import listdir
from os.path import getmtime, join
from datetime import datetime
from sh import find, facter
from sh import find, uptime, who, sort, wc, cut
from util import slurp, thread, p
# this script emits json on standard out that has information about tilde.town
@ -21,6 +21,9 @@ def bounded_find(path):
# find might return 1 but still have worked fine.
return find(path, "-maxdepth", "3", _ok_code=[0,1])
def active_user_count():
return int(wc(sort(cut(who(), "-d' '" "-f1"), "-u"), "-l"))
def guarded_mtime(path):
try:
return getmtime(path.rstrip())
@ -67,7 +70,11 @@ def get_user_data():
def get_data():
user_data = get_user_data()
data = {'generated_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
data = {'generated_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'site_name': 'tilde.town',
'site_url': 'http://tilde.town',
'uptime': uptime('-p'),}
data.update(user_data)
return data