Commit 6741742f authored by Matt Traudt's avatar Matt Traudt Committed by Matt Traudt
Browse files

Create config.log.ini in sbws init

parent 21915d34
from sbws.globals import (is_initted, fail_hard)
from sbws.globals import (is_initted, fail_hard, touch_file)
from sbws.util.config import get_user_example_config
from argparse import ArgumentDefaultsHelpFormatter
import os
......@@ -23,6 +23,7 @@ def main(args, conf):
log.info('Creating %s', args.directory)
os.makedirs(args.directory, exist_ok=False)
touch_file(os.path.join(args.directory, 'config.log.ini'))
config_fname = os.path.join(args.directory, 'config.ini')
c = get_user_example_config()
c['paths']['sbws_home'] = args.directory
......
......@@ -27,6 +27,9 @@ def is_initted(d):
if not os.path.isdir(d):
return False
conf_fname = os.path.join(d, 'config.ini')
if not os.path.exists(conf_fname):
return False
conf_fname = os.path.join(d, 'config.log.ini')
if not os.path.exists(conf_fname):
return False
return True
......@@ -90,3 +93,18 @@ def lock_directory(dname):
'''
assert os.path.isdir(dname)
return FileLock(os.path.join(dname, 'lockfile'))
def touch_file(fname, times=None):
'''
If **fname** exists, update its last access and modified times to now. If
**fname** does not exist, create it. If **times** are specified, pass them
to os.utime for use.
:param str fname: Name of file to update or create
:param tuple times: 2-tuple of floats for access time and modified time
respectively
'''
log.debug('Touching %s', fname)
with open(fname, 'a') as fd:
os.utime(fd.fileno(), times=times)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment