#!/usr/bin/env python3 import sys import os import logging import argparse import getpass import json import shutil import subprocess logging.basicConfig(format='%(message)s', level=logging.DEBUG) logger = logging.getLogger(__name__) DEVKIT_TOOL_FOLDER = os.path.expanduser('~/devkit-game') if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--verbose', required=False, action='store_true') parser.add_argument('--gameid', required=True, action='store') parser.add_argument('--restart-steam', required=False, default='0', action='store') parser.add_argument('--use-mask-unmask', required=False, default='0', action='store') parser.add_argument('--prevent-auto-repair', required=False, default='0', action='store') conf = parser.parse_args() if conf.verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) directory = os.path.join( os.path.expanduser(DEVKIT_TOOL_FOLDER), conf.gameid ) os.makedirs(directory, exist_ok=True) INHIBIT_SENTINEL = os.path.expanduser('~/.config/inhibit-short-session-tracker') if int(conf.prevent_auto_repair) == 1: open(INHIBIT_SENTINEL, 'w').close() logger.info(f'Created sentinel file: {INHIBIT_SENTINEL}') elif os.path.exists(INHIBIT_SENTINEL): os.remove(INHIBIT_SENTINEL) logger.info(f'Removed sentinel file: {INHIBIT_SENTINEL}') ret = { 'user': getpass.getuser(), 'directory': directory, } print(json.dumps(ret))