added lunchuman
This commit is contained in:
49
subsites/lunchuman/manage
Executable file
49
subsites/lunchuman/manage
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pickle
|
||||
|
||||
_absfile = os.path.abspath(__file__)
|
||||
_filedir = os.path.dirname(_absfile)
|
||||
dfile = os.path.join(_filedir, '.dynamicsettings')
|
||||
|
||||
def write(data):
|
||||
with open(dfile, 'wb') as f:
|
||||
pickle.dump(data, f)
|
||||
|
||||
def touch(fname):
|
||||
if os.path.exists(fname):
|
||||
return os.utime(fname, None)
|
||||
else:
|
||||
with open(path, 'w'):
|
||||
pass
|
||||
|
||||
def _traverse(xs):
|
||||
for x in xs:
|
||||
pass
|
||||
|
||||
def act(d):
|
||||
try:
|
||||
d[sys.argv[1]]()
|
||||
except (IndexError, KeyError):
|
||||
print('unknown command', file=sys.stderr)
|
||||
print_help()
|
||||
|
||||
def print_help():
|
||||
print('''
|
||||
Run one of:
|
||||
stop
|
||||
start
|
||||
restart
|
||||
''')
|
||||
|
||||
if __name__ == '__main__':
|
||||
act({
|
||||
'stop': lambda: write({'status': 'stop'}),
|
||||
'start': lambda: write({'status': 'running'}),
|
||||
'restart': lambda: _traverse(
|
||||
f() for f in (lambda: write({'status': 'running'}),
|
||||
lambda: touch(dfile))),
|
||||
'help': print_help, '-h': print_help, '--help': print_help
|
||||
})
|
||||
Reference in New Issue
Block a user