Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/processInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import stateFiles
from formattedText import FormattedText
from usageStrings import USAGE_STR
from screenFlags import ScreenFlags


def getLineObjs():
Expand Down Expand Up @@ -57,6 +58,15 @@ def usage():


if __name__ == '__main__':
flags = ScreenFlags.initFromArgs(sys.argv[1:])
if (flags.getIsCleanMode()):
print('Cleaning out state files...')
for filePath in stateFiles.getAllStateFiles():
if os.path.isfile(filePath):
os.remove(filePath)
print('Done! Removed %d files ' % len(stateFiles.getAllStateFiles()))
sys.exit(0)

if sys.stdin.isatty():
if os.path.isfile(stateFiles.getPickleFilePath()):
print('Using old result...')
Expand Down
13 changes: 12 additions & 1 deletion src/screenFlags.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ def getIsRecordMode(self):
def getPresetCommand(self):
return ' '.join(self.args.command)

def getIsCleanMode(self):
return self.args.clean

@staticmethod
def getArgParser():
parser = argparse.ArgumentParser(prog='fpp')
parser.add_argument('-r',
'--record',
help='''record input and output. This is
help='''
Record input and output. This is
largely used for testing, but you may find it useful for scripting.''',
default=False,
action='store_true')
parser.add_argument('--clean',
default=False,
action='store_true',
help='''
Remove the state files that fpp uses when starting up, including
the previous input used and selection pickle. Useful when using fpp
in a script context where the previous state should be discarded.''')
parser.add_argument('-ko',
'--keep-open',
default=False,
Expand Down
11 changes: 11 additions & 0 deletions src/stateFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ def getScriptOutputFilePath():
def getLoggerFilePath():
assertDirCreated()
return os.path.expanduser(os.path.join(FPP_DIR, LOGGER_FILE))


def getAllStateFiles():
# keep this update to date! We do not include
# the script output path since that gets cleaned automatically
return [
getPickleFilePath(),
getSelectionFilePath(),
getLoggerFilePath(),
getScriptOutputFilePath(),
]