more stuff
parent
8751a6fa00
commit
d1e87ac5b5
|
@ -3,7 +3,7 @@ from functools import partial
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from os.path import getmtime, join
|
from os.path import getmtime, join
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sh import find, facter
|
from sh import find, uptime, who, sort, wc, cut
|
||||||
from util import slurp, thread, p
|
from util import slurp, thread, p
|
||||||
|
|
||||||
# this script emits json on standard out that has information about tilde.town
|
# 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.
|
# find might return 1 but still have worked fine.
|
||||||
return find(path, "-maxdepth", "3", _ok_code=[0,1])
|
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):
|
def guarded_mtime(path):
|
||||||
try:
|
try:
|
||||||
return getmtime(path.rstrip())
|
return getmtime(path.rstrip())
|
||||||
|
@ -67,7 +70,11 @@ def get_user_data():
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
user_data = get_user_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)
|
data.update(user_data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
Reference in New Issue