File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 17
17
import stateFiles
18
18
from formattedText import FormattedText
19
19
from usageStrings import USAGE_STR
20
+ from screenFlags import ScreenFlags
20
21
21
22
22
23
def getLineObjs ():
@@ -57,6 +58,15 @@ def usage():
57
58
58
59
59
60
if __name__ == '__main__' :
61
+ flags = ScreenFlags .initFromArgs (sys .argv [1 :])
62
+ if (flags .getIsCleanMode ()):
63
+ print ('Cleaning out state files...' )
64
+ for filePath in stateFiles .getAllStateFiles ():
65
+ if os .path .isfile (filePath ):
66
+ os .remove (filePath )
67
+ print ('Done! Removed %d files ' % len (stateFiles .getAllStateFiles ()))
68
+ sys .exit (0 )
69
+
60
70
if sys .stdin .isatty ():
61
71
if os .path .isfile (stateFiles .getPickleFilePath ()):
62
72
print ('Using old result...' )
Original file line number Diff line number Diff line change @@ -36,15 +36,26 @@ def getIsRecordMode(self):
36
36
def getPresetCommand (self ):
37
37
return ' ' .join (self .args .command )
38
38
39
+ def getIsCleanMode (self ):
40
+ return self .args .clean
41
+
39
42
@staticmethod
40
43
def getArgParser ():
41
44
parser = argparse .ArgumentParser (prog = 'fpp' )
42
45
parser .add_argument ('-r' ,
43
46
'--record' ,
44
- help = '''record input and output. This is
47
+ help = '''
48
+ Record input and output. This is
45
49
largely used for testing, but you may find it useful for scripting.''' ,
46
50
default = False ,
47
51
action = 'store_true' )
52
+ parser .add_argument ('--clean' ,
53
+ default = False ,
54
+ action = 'store_true' ,
55
+ help = '''
56
+ Remove the state files that fpp uses when starting up, including
57
+ the previous input used and selection pickle. Useful when using fpp
58
+ in a script context where the previous state should be discarded.''' )
48
59
parser .add_argument ('-ko' ,
49
60
'--keep-open' ,
50
61
default = False ,
Original file line number Diff line number Diff line change @@ -45,3 +45,14 @@ def getScriptOutputFilePath():
45
45
def getLoggerFilePath ():
46
46
assertDirCreated ()
47
47
return os .path .expanduser (os .path .join (FPP_DIR , LOGGER_FILE ))
48
+
49
+
50
+ def getAllStateFiles ():
51
+ # keep this update to date! We do not include
52
+ # the script output path since that gets cleaned automatically
53
+ return [
54
+ getPickleFilePath (),
55
+ getSelectionFilePath (),
56
+ getLoggerFilePath (),
57
+ getScriptOutputFilePath (),
58
+ ]
You can’t perform that action at this time.
0 commit comments