aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-21 19:35:55 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-21 19:35:55 +0200
commitc13ce26768e760908078244e251c7b3c19b26a8f (patch)
tree030e304c8d68fdd94ad6bd3c574725119ff3c102 /ponysay
parent194ddff8fa50b493e822012c51c026de1f76ea2d (diff)
downloadponysay-c13ce26768e760908078244e251c7b3c19b26a8f.tar.gz
ponysay-c13ce26768e760908078244e251c7b3c19b26a8f.tar.bz2
ponysay-c13ce26768e760908078244e251c7b3c19b26a8f.zip
automatic cache clean
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay26
1 files changed, 25 insertions, 1 deletions
diff --git a/ponysay b/ponysay
index fedaab6..7eb6dd5 100755
--- a/ponysay
+++ b/ponysay
@@ -24,7 +24,7 @@ from subprocess import Popen, PIPE
'''
The version of ponysay
'''
-VERSION = '2.2'
+VERSION = '2.3'
'''
@@ -533,6 +533,8 @@ class Ponysay():
if not linuxvt:
return pony
+ KMS_VERSION = '1'
+
env_kms = os.environ['PONYSAY_KMS_PALETTE'] if 'PONYSAY_KMS_PALETTE' in os.environ else None
if env_kms is None: env_kms = ''
@@ -554,6 +556,28 @@ class Ponysay():
if not os.path.isdir(cachedir):
os.makedirs(cachedir)
+ newversion = False
+ if not os.path.isfile(cachedir + '/.version'):
+ newversion = True
+ else:
+ cachev = None
+ try:
+ cachev = open(cachedir + '/.version', 'r')
+ if ''.join(cachev.readlines()) == KMS_VERSION:
+ newversion = True
+ finally:
+ if cachev is not None:
+ cachev.close()
+ if newversion:
+ for cached in os.listdir(ponydir):
+ shutil.rmtree(cachedir + '/' + cached, False)
+ try:
+ cachev = open(cachedir + '/.version', 'w+')
+ cachev.write(KMS_VERSION)
+ finally:
+ if cachev is not None:
+ cachev.close()
+
kmsponies = cachedir + '/kmsponies/' + palettefile
kmspony = (kmsponies + pony).replace('//', '/')